mirror of
https://github.com/GnoConsortium/gno.git
synced 2025-02-23 15:29:11 +00:00
added trivial test for fts routines
This commit is contained in:
parent
5aa367e6ff
commit
b998993162
35
lib/libc/tests/gen/ftstest.c
Normal file
35
lib/libc/tests/gen/ftstest.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
||||
FTS *ftsp;
|
||||
FTSENT *entp;
|
||||
int options;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("usage: %s dirname\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
options = FTS_NOCHDIR | FTS_NOSTAT;
|
||||
ftsp = fts_open(&argv[1], options, NULL);
|
||||
if (ftsp == NULL) {
|
||||
printf("fts_open failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((entp = fts_read(ftsp)) != NULL) {
|
||||
assert(entp->fts_name != NULL);
|
||||
printf("%s\n", entp->fts_name);
|
||||
}
|
||||
if (errno) {
|
||||
perror("fts_read return code");
|
||||
}
|
||||
|
||||
options = fts_close(ftsp);
|
||||
printf("fts_close returned %d\n", options);
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user