X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fapc%2Fscanner.c;fp=src%2Fapc%2Fscanner.c;h=580ad1271a349405d96f3d0746d8c00201245121;hp=b20a92f0223c44a3a3eaf1b0c489efb448a98fbe;hb=f3b6f51fea6877beedd0da00fa7cace4af8623fd;hpb=2dfdc5653b9f85952119122cff72320540a342d2 diff --git a/src/apc/scanner.c b/src/apc/scanner.c index b20a92f..580ad12 100644 --- a/src/apc/scanner.c +++ b/src/apc/scanner.c @@ -83,11 +83,11 @@ struct dirlist */ int scanner_init #define CWDSTR "./" -#define ROOTDIR (cargs['r'] ? cargs['r'] : CWDSTR) +#define ROOTDIR (cargs['d'] ? cargs['d'] : CWDSTR) () { DL_INIT(); DL_STACK[0].dirp = opendir(ROOTDIR); - return DL_STACK[0].dirp == NULL || dredge_current_depth() == 0; + return !chdir(ROOTDIR) && (DL_STACK[0].dirp == NULL || dredge_current_depth() == 0); } /* Scanner @@ -130,12 +130,10 @@ int scanner goto fail; } if (chdir(direntp->d_name)) //move into the new directory - goto libfail; + goto libfail; DL_PUSH(opendir(CWDSTR)); if (DL_CURDIR() == NULL) //open the cwd - { printf("DL_PUSH(opendir failed.\n"); - goto libfail; - } + goto libfail; lexer_pushtok(TOK_CLOPEN); //Push "Open Directory" token return dredge_current_depth(); //Filter and sort the current depth } @@ -181,10 +179,14 @@ int dredge_current_depth if ((direntp = readdir(cwd)) != NULL) { switch (direntp->d_type) { case DT_REG: + printf("String to tokenize %s\n", direntp->d_name); DPS_PUSH(direntp); goto scan_next; case DT_DIR: - DL_CD_PUSH(direntp); + if (*(direntp->d_name) == '.') //skip hidden files and relative dirs + goto scan_next; + printf("Pushing child directory %s\n", direntp->d_name); + DL_CD_PUSH(direntp); goto scan_next; case DT_UNKNOWN: warnx("unknown file %s: ignoring", direntp->d_name);