Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void LoadPluginsFromDir(const char *szBaseDir, const char *szLocalPath)
- {
- LogMessageEx("LoadPluginsFromDir: '%s', '%s'", szBaseDir, szLocalPath);
- char szPath[PLATFORM_MAX_PATH], szLocalPath2[PLATFORM_MAX_PATH];
- /* Form the current path to start reading from */
- if (szLocalPath == NULL)
- {
- // libsys->PathFormat(szPath, sizeof(szPath), "%s", szBaseDir);
- g_pSM->BuildPath(Path_SM, szPath, sizeof(szPath), "%s", szBaseDir);
- }
- else
- {
- // libsys->PathFormat(szPath, sizeof(szPath), "%s/%s", szBaseDir, szLocalPath);
- g_pSM->BuildPath(Path_SM, szPath, sizeof(szPath), "%s/%s", szBaseDir, szLocalPath);
- }
- LogMessageEx("szPath = '%s'", szPath);
- LogMessageEx("szLocalPath2 = '%s'", szLocalPath);
- IDirectory *dir = libsys->OpenDirectory(szPath);
- if (!dir)
- {
- char szError[256];
- libsys->GetPlatformError(szError, sizeof(szError));
- g_pSM->LogError(myself, "[SM] Failure reading from plugins path: %s", szLocalPath);
- g_pSM->LogError(myself, "[SM] Platform returned error: %s", szError);
- return;
- }
- LogMessageEx("szLocalPath3 = '%s'", szLocalPath);
- while (dir->MoreFiles())
- {
- LogMessageEx("szLocalPath4 = '%s'", szLocalPath);
- LogMessageEx("GetEntryName = '%s'\t%s %s", dir->GetEntryName(), dir->IsEntryDirectory() ? "DIR":"", dir->IsEntryFile() ? "FILE" : "");
- if (dir->IsEntryDirectory()
- && (strcmp(dir->GetEntryName(), ".") != 0)
- && (strcmp(dir->GetEntryName(), "..") != 0)
- && (strcmp(dir->GetEntryName(), "disabled") != 0)
- && (strcmp(dir->GetEntryName(), "optional") != 0))
- {
- // LogMessageEx("szLocalPath = '%s', != %d, == %d", szLocalPath, (szLocalPath != NULL), (szLocalPath == NULL));
- if (szLocalPath != NULL)
- {
- // LogMessageEx("strcmp('%s', '%s') = %d", dir->GetEntryName(), szLocalPath, strcmp(dir->GetEntryName(), szLocalPath));
- LogMessageEx("szLocalPath = '%s'", szLocalPath);
- continue;
- }
- LogMessageEx("IsEntryDirectory() = %d", dir->IsEntryDirectory());
- LogMessageEx("IsEntryFile() = %d", dir->IsEntryFile());
- LogMessageEx("IsEntryValid() = %d", dir->IsEntryValid());
- char szNewLocal[PLATFORM_MAX_PATH];
- if (szLocalPath == NULL)
- {
- ke::SafeSprintf(szNewLocal, sizeof(szNewLocal), "%s", dir->GetEntryName());
- }
- else
- {
- libsys->PathFormat(szNewLocal, sizeof(szNewLocal), "%s/%s", szLocalPath, dir->GetEntryName());
- }
- LogMessageEx("szNewLocal = '%s'", szNewLocal);
- LoadPluginsFromDir(szBaseDir, szNewLocal);
- continue;
- }
- //
- dir->NextEntry();
- }
- libsys->CloseDirectory(dir);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement