Exemple #1
0
int NxUtils::ListDirectories( std::vector<std::string> &refvecDirectory, const std::string &refcstrRootDirectory, bool bSearchSubdirectories = true)
{

#if NXGRAPHICS_PLATFORM == NXGRAPHICS_PLATFORM_WIN32
   std::string strFilePath; // Filepath
   std::string strPattern; // Pattern
   std::string strExtension; // Extension
   HANDLE hFile; // Handle to file
   WIN32_FIND_DATA FileInformation; // File information
   
   strPattern = refcstrRootDirectory + "\\*.*";
   
   hFile = ::FindFirstFile(strPattern.c_str(), &FileInformation);
   if(hFile != INVALID_HANDLE_VALUE)
   {
      do
      {
         if(FileInformation.cFileName[0] != '.')
         {
            strFilePath.erase();
            strFilePath = refcstrRootDirectory + "\\" + FileInformation.cFileName;
            
            if(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // directory
            {
				refvecDirectory.push_back( FileInformation.cFileName ); // Save directory

               if(bSearchSubdirectories)
               {
                  // Search subdirectory
                  int iRC = ListDirectories(refvecDirectory,strFilePath,bSearchSubdirectories);
				  if(iRC){ return iRC; }
               }
            }
            else // file
            {

            }
         }
      } while(::FindNextFile(hFile, &FileInformation) == TRUE);
      
      // Close handle
      ::FindClose(hFile);
      
      DWORD dwError = ::GetLastError();
	  if(dwError != ERROR_NO_MORE_FILES){ return dwError; }
   }

#endif
   
   return 0;
}
Exemple #2
0
int AskMap(char *o, char *hs = 0)
{
	GrowStringList *sl = ListDirectories("Maps");
	int x = ListDlgBox(sl, hs ? hs : "Select a map.", 0);
	if(x == -1) return 0;
	strcpy(o, "Maps\\");
	strcat(o, sl->getdp(x));
	strcat(o, "\\");
	strcat(o, sl->getdp(x));
	int e = strlen(o);
	strcpy(o+e, ".bcm");
	if(FileExists(o)) return 1;
	strcpy(o+e, ".snr");
	if(FileExists(o)) return 1;
	MessageBox(hWindow, "The selected map directory does not contain a BCM nor a SNR file.", appName, 48);
	return 0;
}
Exemple #3
0
void T29_TreeDir(char *s)
{
	GrowStringList *dirs = ListDirectories(s);
	for(int i = 0; i < dirs->len; i++)
	{
		if(ImGui::TreeNodeEx(dirs->getdp(i), ImGuiTreeNodeFlags_OpenOnArrow))
		{
			char tb[512];
			strcpy(tb, s);
			strcat(tb, "\\");
			strcat(tb, dirs->getdp(i));
			T29_TreeDir(tb);
			ImGui::TreePop();
		}
		if(ImGui::IsItemClicked())
		{
			strcpy(t29curdir, s);
			strcat(t29curdir, "\\");
			strcat(t29curdir, dirs->getdp(i));
			T29_UpdateFiles();
		}
	}
	delete dirs;
}