12 int main(int argc, char *argv[]);
13 void ShowUsage(char *ProgName);
14 void ParseArguments(int argc, char *argv[]);
20 int gbShowImplicit = 0;
21 int gbViewExtended = 0;
22 int gbViewHumanReadable = 0;
24 char *gsDirectory = NULL;
25 // --- Working Set ---
30 * \fn int main(int argc, char *argv[])
33 int main(int argc, char *argv[])
41 ParseArguments(argc, argv);
44 fd = open(gsDirectory, OPENFLAG_READ|OPENFLAG_EXEC);
46 printf("Unable to open '%s' for reading\n", gsDirectory);
50 // Check that it is a directory
52 if( !(info.flags & FILEFLAG_DIRECTORY) ) {
53 fprintf(stderr, "'%s' is a directory\n", gsDirectory);
59 while( (tmp = readdir(fd, buf)) )
68 if(space == giNumFiles)
71 gFileList = realloc(gFileList, space*sizeof(char*));
72 if(gFileList == NULL) {
77 gFileList[giNumFiles++] = strdup(buf);
80 // Sort File List according to rules passed
90 * \fn void ShowUsage(char *ProgName)
92 void ShowUsage(char *ProgName)
94 fprintf(stderr, "Usage: %s [options] [<directory>]\n", ProgName);
95 fprintf(stderr, "\n");
99 * \fn void ParseArguments(int argc, char *argv[])
100 * \brief Parse the command line arguments
102 void ParseArguments(int argc, char *argv[])
106 for( i = 1; i < argc; i ++ )
122 case 'a': gbShowAll = 1; gbShowImplicit = 1; continue;
124 case 'A': gbShowAll = 1; gbShowImplicit = 0; continue;
126 case 'l': gbViewExtended = 1; continue;
127 // Human readable sizes
128 case 'h': gbViewHumanReadable = 1; continue;
130 fprintf(stderr, "%s: Unknown option '%c'\n", *str);
138 if(gsDirectory == NULL) {
139 gsDirectory = argv[i];
144 if(!gsDirectory) gsDirectory = ".";
146 printf("gsDirectory = '%s'\n", gsDirectory);
150 * \fn int strcmpp(void *p1, void *p2)
151 * \brief Compares two strings given pointers to their pointers
153 int strcmpp(const void *p1, const void *p2)
155 return strcmp( *(char **)p1, *(char **)p2 );
159 * \fn void SortFileList()
160 * \brief Sorts the filled file list
164 qsort(gFileList, giNumFiles, sizeof(char*), strcmpp);