MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxRunDirectory

Function fxRunDirectory

xs/tools/xst262.c:869–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

867}
868
869void fxRunDirectory(txPool* pool, char* path)
870{
871 typedef struct sxEntry txEntry;
872 struct sxEntry {
873 txEntry* nextEntry;
874 char name[1];
875 };
876
877#if mxWindows
878 size_t length;
879 HANDLE findHandle = INVALID_HANDLE_VALUE;
880 WIN32_FIND_DATA findData;
881 length = strlen(path);
882 path[length] = '\\';
883 length++;
884 path[length] = '*';
885 path[length + 1] = 0;
886 findHandle = FindFirstFile(path, &findData);
887 if (findHandle != INVALID_HANDLE_VALUE) {
888 txEntry* entry;
889 txEntry* firstEntry = NULL;
890 txEntry* nextEntry;
891 txEntry** address;
892 do {
893 if ((findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||
894 !strcmp(findData.cFileName, ".") ||
895 !strcmp(findData.cFileName, ".."))
896 continue;
897 entry = malloc(sizeof(txEntry) + strlen(findData.cFileName));
898 if (!entry)
899 break;
900 strcpy(entry->name, findData.cFileName);
901 address = &firstEntry;
902 while ((nextEntry = *address)) {
903 if (strcmp(entry->name, nextEntry->name) < 0)
904 break;
905 address = &nextEntry->nextEntry;
906 }
907 entry->nextEntry = nextEntry;
908 *address = entry;
909 } while (FindNextFile(findHandle, &findData));
910 FindClose(findHandle);
911 while (firstEntry) {
912 DWORD attributes;
913 strcpy(path + length, firstEntry->name);
914 attributes = GetFileAttributes(path);
915 if (attributes != 0xFFFFFFFF) {
916 if (attributes & FILE_ATTRIBUTE_DIRECTORY) {
917 fxPushResult(pool, firstEntry->name);
918 fxRunDirectory(pool, path);
919 fxPopResult(pool);
920 }
921 else if (fxStringEndsWith(path, ".js") && !fxStringEndsWith(path, "_FIXTURE.js"))
922 fxRunFile(pool, path);
923 }
924 nextEntry = firstEntry->nextEntry;
925 free(firstEntry);
926 firstEntry = nextEntry;

Callers 1

xst262.cFile · 0.85

Calls 5

fxPushResultFunction · 0.85
fxPopResultFunction · 0.85
fxStringEndsWithFunction · 0.85
fxRunFileFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected