[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/libc/glibc/glibc-2.22/manual/examples/dir2.c b/ap/libc/glibc/glibc-2.22/manual/examples/dir2.c
new file mode 100644
index 0000000..1fe3615
--- /dev/null
+++ b/ap/libc/glibc/glibc-2.22/manual/examples/dir2.c
@@ -0,0 +1,46 @@
+/* Simple Program to List a Directory, Mark II
+ Copyright (C) 1991-2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*@group*/
+#include <stdio.h>
+#include <dirent.h>
+/*@end group*/
+
+static int
+one (const struct dirent *unused)
+{
+ return 1;
+}
+
+int
+main (void)
+{
+ struct dirent **eps;
+ int n;
+
+ n = scandir ("./", &eps, one, alphasort);
+ if (n >= 0)
+ {
+ int cnt;
+ for (cnt = 0; cnt < n; ++cnt)
+ puts (eps[cnt]->d_name);
+ }
+ else
+ perror ("Couldn't open the directory");
+
+ return 0;
+}