Remove the RCSID macro
[openafs.git] / src / util / test / treaddir.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * test readdir routines.
12 * Need to ensure that opendir succeeds if the directory is empty. To that
13  * end report the NT error for any failure.
14  * Basic tests to do:
15  * 1) Read non-existent directory.
16  * 2) Read empty <drive:>
17  * 3) Try to read a file.
18  */
19 #include <afsconfig.h>
20 #include <afs/param.h>
21
22
23 #include <stdio.h>
24 #include <errno.h>
25 #include <dirent.h>
26
27 main(int ac, char **av)
28 {
29     int i;
30     DIR *dirp;
31     struct dirent *direntp;
32     int first;
33
34
35     if (ac < 2) {
36         printf("Usage: treaddir dir [dir ....]\n");
37         return -1;
38     }
39
40     for (i = 1; i < ac; i++) {
41         dirp = opendir(av[i]);
42         if (!dirp) {
43 #ifdef AFS_NT40_ENV
44             printf("Can't open directory \"%s\", errno=%d, NT error=%d\n",
45                    av[i], errno, GetLastError());
46 #else
47             printf("Can't open directory \"%s\", errno=%d\n", av[i], errno);
48 #endif
49             continue;
50         }
51
52         first = 1;
53         errno = 0;
54         while (direntp = readdir(dirp)) {
55             if (first) {
56                 first = 0;
57                 if (i > 1)
58                     printf("\n");
59             }
60             printf("%s\n", direntp->d_name);
61         }
62 #ifdef AFS_NT40_ENV
63         if (errno) {
64             printf
65                 ("readdir failed in directory %s with errno=%d, NT error=%d\n",
66                  av[i], errno, GetLastError());
67         }
68 #endif
69         (void)closedir(dirp);
70     }
71
72     return 0;
73 }