Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void LuaEngine::ScriptLoadDir(char* Dirname, LUALoadScripts* pak)
- {
- #ifdef WIN32
- Log.Notice("LuaEngine", "Scanning Directory %s", Dirname);
- HANDLE hFile;
- WIN32_FIND_DATA FindData;
- memset(&FindData, 0, sizeof(FindData));
- char SearchName[MAX_PATH];
- strcpy(SearchName, Dirname);
- strcat(SearchName, "\\*.*");
- hFile = FindFirstFile(SearchName, &FindData);
- FindNextFile(hFile, &FindData);
- while(FindNextFile(hFile, &FindData))
- {
- // custom condition
- if(FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
- continue;
- string fname = Dirname;
- fname += "\\";
- fname += FindData.cFileName;
- size_t len = strlen(fname.c_str());
- if(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //Credits for this 'if' go to Cebernic from ArcScripts Team. Thanks, you saved me some work ;-)
- {
- strcpy(SearchName, Dirname);
- // custom 1 lines
- printf("------- \n Folder: %s \n -------- \n", Dirname);
- strcat(SearchName, "\\");
- strcat(SearchName, FindData.cFileName);
- ScriptLoadDir(SearchName, pak);
- }
- else
- {
- string fname = Dirname;
- fname += "\\";
- fname += FindData.cFileName;
- size_t len = strlen(fname.c_str());
- int i = 0;
- char ext[MAX_PATH];
- while(len > 0)
- {
- ext[i++] = fname[--len];
- if(fname[len] == '.')
- break;
- }
- ext[i++] = '\0';
- if ( !_stricmp(ext,"aul.") )
- {
- pak->luaFiles.insert(fname);
- //printf("Loaded %s", fname);
- printf("Loaded %s \n", FindData.cFileName);
- }
- }
- }
- FindClose(hFile);
- #else
Advertisement
Add Comment
Please, Sign In to add comment