static boolean recurseUsingOpendir (const char *const dirName) { boolean resize = FALSE; DIR *const dir = opendir (dirName); if (dir == NULL) error (WARNING | PERROR, "cannot recurse into directory \"%s\"", dirName); else { struct dirent *entry; while ((entry = readdir (dir)) != NULL) { if (strcmp (entry->d_name, ".") != 0 && strcmp (entry->d_name, "..") != 0) { char *filePath; boolean free_p = FALSE; if (strcmp (dirName, ".") == 0) filePath = entry->d_name; else { filePath = combinePathAndFile (dirName, entry->d_name); free_p = TRUE; } resize |= createTagsForEntry (filePath); if (free_p) eFree (filePath); } } closedir (dir); } return resize; }
static boolean createTagsForAmigaWildcard (const char *const pattern) { boolean resize = FALSE; struct AnchorPath *const anchor = (struct AnchorPath *) eMalloc ((size_t) ANCHOR_SIZE); LONG result; memset (anchor, 0, (size_t) ANCHOR_SIZE); anchor->ap_Strlen = ANCHOR_BUF_SIZE; /* Allow '.' for current directory */ #ifdef APF_DODOT anchor->ap_Flags = APF_DODOT | APF_DOWILD; #else anchor->ap_Flags = APF_DoDot | APF_DoWild; #endif result = MatchFirst ((UBYTE *) pattern, anchor); while (result == 0) { resize |= createTagsForEntry ((char *) anchor->ap_Buf); result = MatchNext (anchor); } MatchEnd (anchor); eFree (anchor); return resize; }
static boolean recurseUsingOpendir (const char *const dirName) { boolean resize = FALSE; DIR *const dir = opendir (dirName); if (dir == NULL) error (WARNING | PERROR, "cannot recurse into directory \"%s\"", dirName); else { struct dirent *entry; while ((entry = readdir (dir)) != NULL) { if (strcmp (entry->d_name, ".") != 0 && strcmp (entry->d_name, "..") != 0) { vString *filePath; if (strcmp (dirName, ".") == 0) filePath = vStringNewInit (entry->d_name); else filePath = combinePathAndFile (dirName, entry->d_name); resize |= createTagsForEntry (vStringValue (filePath)); vStringDelete (filePath); } } closedir (dir); } return resize; }
static boolean createTagsForWildcardEntry ( const char *const pattern, const size_t dirLength, const char *const entryName) { boolean resize = FALSE; /* we must not recurse into the directories "." or ".." */ if (strcmp (entryName, ".") != 0 && strcmp (entryName, "..") != 0) { vString *const filePath = vStringNew (); vStringNCopyS (filePath, pattern, dirLength); vStringCatS (filePath, entryName); resize = createTagsForEntry (vStringValue (filePath)); vStringDelete (filePath); } return resize; }
static boolean createTagsForArgs (cookedArgs *const args) { boolean resize = FALSE; /* Generate tags for each argument on the command line. */ while (! cArgOff (args)) { const char *const arg = cArgItem (args); #ifdef MANUAL_GLOBBING resize |= createTagsForWildcardArg (arg); #else resize |= createTagsForEntry (arg); #endif cArgForth (args); parseOptions (args); } return resize; }
/* Read from an opened file a list of file names for which to generate tags. */ static boolean createTagsFromFileInput (FILE *const fp, const boolean filter) { boolean resize = FALSE; if (fp != NULL) { cookedArgs *args = cArgNewFromLineFile (fp); parseOptions (args); while (! cArgOff (args)) { resize |= createTagsForEntry (cArgItem (args)); if (filter) { if (Option.filterTerminator != NULL) fputs (Option.filterTerminator, stdout); fflush (stdout); } cArgForth (args); parseOptions (args); } cArgDelete (args); } return resize; }