Advertisement
BM_R1KO

Untitled

Oct 3rd, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. void LoadPluginsFromDir(const char *szBaseDir, const char *szLocalPath)
  3. {
  4.     LogMessageEx("LoadPluginsFromDir: '%s', '%s'", szBaseDir, szLocalPath);
  5.  
  6.     char szPath[PLATFORM_MAX_PATH], szLocalPath2[PLATFORM_MAX_PATH];
  7.  
  8.     /* Form the current path to start reading from */
  9.     if (szLocalPath == NULL)
  10.     {
  11.     //  libsys->PathFormat(szPath, sizeof(szPath), "%s", szBaseDir);
  12.         g_pSM->BuildPath(Path_SM, szPath, sizeof(szPath), "%s", szBaseDir);
  13.     }
  14.     else
  15.     {
  16.     //  libsys->PathFormat(szPath, sizeof(szPath), "%s/%s", szBaseDir, szLocalPath);
  17.         g_pSM->BuildPath(Path_SM, szPath, sizeof(szPath), "%s/%s", szBaseDir, szLocalPath);
  18.     }
  19.  
  20.     LogMessageEx("szPath = '%s'", szPath);
  21.     LogMessageEx("szLocalPath2 = '%s'", szLocalPath);
  22.  
  23.     IDirectory *dir = libsys->OpenDirectory(szPath);
  24.  
  25.     if (!dir)
  26.     {
  27.         char szError[256];
  28.         libsys->GetPlatformError(szError, sizeof(szError));
  29.         g_pSM->LogError(myself, "[SM] Failure reading from plugins path: %s", szLocalPath);
  30.         g_pSM->LogError(myself, "[SM] Platform returned error: %s", szError);
  31.         return;
  32.     }
  33.    
  34.     LogMessageEx("szLocalPath3 = '%s'", szLocalPath);
  35.  
  36.     while (dir->MoreFiles())
  37.     {
  38.         LogMessageEx("szLocalPath4 = '%s'", szLocalPath);
  39.  
  40.         LogMessageEx("GetEntryName = '%s'\t%s %s", dir->GetEntryName(), dir->IsEntryDirectory() ? "DIR":"", dir->IsEntryFile() ? "FILE" : "");
  41.  
  42.         if (dir->IsEntryDirectory()
  43.             && (strcmp(dir->GetEntryName(), ".") != 0)
  44.             && (strcmp(dir->GetEntryName(), "..") != 0)
  45.             && (strcmp(dir->GetEntryName(), "disabled") != 0)
  46.             && (strcmp(dir->GetEntryName(), "optional") != 0))
  47.         {
  48.         //  LogMessageEx("szLocalPath = '%s', != %d, == %d", szLocalPath, (szLocalPath != NULL), (szLocalPath == NULL));
  49.             if (szLocalPath != NULL)
  50.             {
  51.             //  LogMessageEx("strcmp('%s', '%s') = %d", dir->GetEntryName(), szLocalPath, strcmp(dir->GetEntryName(), szLocalPath));
  52.                 LogMessageEx("szLocalPath = '%s'", szLocalPath);
  53.                 continue;
  54.             }
  55.             LogMessageEx("IsEntryDirectory() = %d", dir->IsEntryDirectory());
  56.             LogMessageEx("IsEntryFile() = %d", dir->IsEntryFile());
  57.             LogMessageEx("IsEntryValid() = %d", dir->IsEntryValid());
  58.  
  59.             char szNewLocal[PLATFORM_MAX_PATH];
  60.             if (szLocalPath == NULL)
  61.             {
  62.                 ke::SafeSprintf(szNewLocal, sizeof(szNewLocal), "%s", dir->GetEntryName());
  63.             }
  64.             else
  65.             {
  66.                 libsys->PathFormat(szNewLocal, sizeof(szNewLocal), "%s/%s", szLocalPath, dir->GetEntryName());
  67.             }
  68.             LogMessageEx("szNewLocal = '%s'", szNewLocal);
  69.             LoadPluginsFromDir(szBaseDir, szNewLocal);
  70.             continue;
  71.         }
  72.  
  73.         //
  74.  
  75.         dir->NextEntry();
  76.     }
  77.     libsys->CloseDirectory(dir);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement