scanner.c

changeset 14
ee9333c91dda
parent 10
ecf787666f44
child 16
bc9a0fefd892
equal deleted inserted replaced
13:51b1ba3776b1 14:ee9333c91dda
25 entryname[t]=' '; 25 entryname[t]=' ';
26 } 26 }
27 entryname[spaces] = 0; 27 entryname[spaces] = 0;
28 strcat(entryname, entry->d_name); 28 strcat(entryname, entry->d_name);
29 29
30 char filename[(1+strlen(currdir)+strlen(entry->d_name))];
31 strcpy(filename, currdir);
32 strncat(filename, &settings->fileSeparator, 1);
33 strcat(filename, entry->d_name);
34
30 // Check for subdirectory 35 // Check for subdirectory
31 char subdirname[(1+strlen(currdir)+strlen(entry->d_name))]; 36 if ((subdir = opendir(filename)) != NULL) {
32 strcpy(subdirname, currdir);
33 strncat(subdirname, &settings->fileSeparator, 1);
34 strcat(subdirname, entry->d_name);
35 if ((subdir = opendir(subdirname)) != NULL) {
36 printf("%-60s\n", entryname); 37 printf("%-60s\n", entryname);
37 if (settings->recursive) { 38 if (settings->recursive) {
38 lineSum += scanDirectory(subdir, spaces+1, subdirname, settings); 39 lineSum += scanDirectory(subdir, spaces+1, filename, settings);
39 } 40 }
40 closedir(subdir); 41 closedir(subdir);
41 continue; 42 continue;
42 } 43 }
43 44
44 // Count lines 45 // Count lines
45 lines = 0; 46 lines = 0;
46 char filename[(1+strlen(currdir)+strlen(entry->d_name))]; 47 /* char filename[(1+strlen(currdir)+strlen(entry->d_name))];
47 strcpy(filename, currdir); 48 strcpy(filename, currdir);
48 strncat(filename, &settings->fileSeparator, 1); 49 strncat(filename, &settings->fileSeparator, 1);
49 strcat(filename, entry->d_name); 50 strcat(filename, entry->d_name); */
50 if (testSuffix(filename, settings)) { 51 if (testSuffix(filename, settings)) {
51 FILE *file = fopen(filename, "r"); 52 FILE *file = fopen(filename, "r");
52 if (file == NULL) { 53 if (file == NULL) {
53 perror(" File acces failed"); 54 perror(" File acces failed");
54 continue; 55 continue;

mercurial