Changeset 254 in Main for 2.03E/Common
- Timestamp:
- Oct 4, 2024, 1:08:33 PM (6 weeks ago)
- Location:
- 2.03E
- Files:
-
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
2.03E/Common/Makefile
r218 r254 15 15 16 16 common.a: $(OBJS) 17 rm -f common.a 17 18 $(AR) rcs $@ `echo $(OBJS) | $(AR_PROC)` 18 19 19 20 common.lib: $(OBJS) 21 rm -f common.lib 20 22 $(AR) $(AR_FLAGS)$@ `echo $(OBJS) | $(AR_PROC)` 21 23 -
2.03E/Common/dir.c
r219 r254 22 22 char** cm_scandir(const char* path) { 23 23 #if defined(_MSC_VER) || defined(__BORLANDC__) 24 return NULL; 24 WIN32_FIND_DATA ffd; 25 HANDLE hfind; 26 char** r = malloc(sizeof(*r)); 27 int len; 28 char** old; 29 int i; 30 char* p; 31 r[0] = NULL; 32 33 p = cm_strcat(path, "/*"); 34 hfind = FindFirstFile(p, &ffd); 35 if(INVALID_HANDLE_VALUE == hfind) { 36 return NULL; 37 } 38 do { 39 if(strcmp(ffd.cFileName, ".") != 0 && strcmp(ffd.cFileName, "..") != 0) { 40 old = r; 41 for(i = 0; old[i] != NULL; i++) 42 ; 43 r = malloc(sizeof(*r) * (i + 2)); 44 for(i = 0; old[i] != NULL; i++) r[i] = old[i]; 45 r[i] = cm_strcat(ffd.cFileName, (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? "/" : ""); 46 r[i + 1] = NULL; 47 free(old); 48 } 49 } while(FindNextFile(hfind, &ffd) != 0); 50 FindClose(hfind); 51 free(p); 52 for(len = 0; r[len] != NULL; len++) 53 ; 54 qsort(r, len, sizeof(char*), cm_sort); 55 56 old = r; 57 for(i = 0; old[i] != NULL; i++) 58 ; 59 r = malloc(sizeof(*r) * (i + 2)); 60 for(i = 0; old[i] != NULL; i++) r[i + 1] = old[i]; 61 r[0] = cm_strdup("../"); 62 r[i + 1] = NULL; 63 free(old); 64 65 return r; 25 66 #else 26 67 DIR* dir = opendir(path);
Note:
See TracChangeset
for help on using the changeset viewer.