equal
deleted
inserted
replaced
31 #include <windows.h> |
31 #include <windows.h> |
32 #include <malloc.h> // for alloca(). |
32 #include <malloc.h> // for alloca(). |
33 #define snprintf _snprintf |
33 #define snprintf _snprintf |
34 #else |
34 #else |
35 #include <dirent.h> |
35 #include <dirent.h> |
|
36 #include <sys/stat.h> |
36 #endif |
37 #endif |
37 |
38 |
38 #define report printf |
39 #define report printf |
39 |
40 |
|
41 static int isdir(const char *dname) |
|
42 { |
|
43 #ifdef _MSC_VER |
|
44 WIN32_FILE_ATTRIBUTE_DATA winstat; |
|
45 if (!GetFileAttributesExA(dname, GetFileExInfoStandard, &winstat)) |
|
46 return 0; |
|
47 return winstat.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; |
|
48 #else |
|
49 struct stat statbuf; |
|
50 if (stat(dname, &statbuf) == -1) |
|
51 return 0; |
|
52 return S_ISDIR(statbuf.st_mode); |
|
53 #endif |
|
54 } |
|
55 |
|
56 static int do_dir(const char *dname, const char *profile); |
|
57 |
40 static int do_file(const char *profile, const char *dname, const char *fn, int *total) |
58 static int do_file(const char *profile, const char *dname, const char *fn, int *total) |
41 { |
59 { |
42 int do_quit = 0; |
60 int do_quit = 0; |
|
61 |
|
62 if ((strcmp(fn, ".") == 0) || (strcmp(fn, "..") == 0)) |
|
63 return 1; // skip these. |
43 |
64 |
44 #if FINDERRORS_COMPILE_SHADERS |
65 #if FINDERRORS_COMPILE_SHADERS |
45 SDL_Event e; // pump event queue to keep OS happy. |
66 SDL_Event e; // pump event queue to keep OS happy. |
46 while (SDL_PollEvent(&e)) |
67 while (SDL_PollEvent(&e)) |
47 { |
68 { |
53 |
74 |
54 if (do_quit) |
75 if (do_quit) |
55 { |
76 { |
56 report("FAIL: user requested quit!\n"); |
77 report("FAIL: user requested quit!\n"); |
57 return 0; |
78 return 0; |
|
79 } // if |
|
80 |
|
81 char *fname = (char *) alloca(strlen(fn) + strlen(dname) + 2); |
|
82 sprintf(fname, "%s/%s", dname, fn); |
|
83 |
|
84 if (isdir(fname)) |
|
85 { |
|
86 *total += do_dir(fname, profile); |
|
87 return 1; |
58 } // if |
88 } // if |
59 |
89 |
60 int assembly = 0; |
90 int assembly = 0; |
61 if (strstr(fn, ".bytecode") != NULL) |
91 if (strstr(fn, ".bytecode") != NULL) |
62 assembly = 0; |
92 assembly = 0; |
65 else |
95 else |
66 return 1; |
96 return 1; |
67 |
97 |
68 (*total)++; |
98 (*total)++; |
69 |
99 |
70 char *fname = (char *) alloca(strlen(fn) + strlen(dname) + 2); |
|
71 sprintf(fname, "%s/%s", dname, fn); |
|
72 FILE *io = fopen(fname, "rb"); |
100 FILE *io = fopen(fname, "rb"); |
73 if (io == NULL) |
101 if (io == NULL) |
74 { |
102 { |
75 report("FAIL: %s fopen() failed.\n", fname); |
103 report("FAIL: %s fopen() failed.\n", fname); |
76 return 1; |
104 return 1; |