bool MakeDirectory(string directoryName) { string command; int retcode; int length; if ( directoryName == "" ) return false; length = directoryName.length(); if ( directoryName[length - 1] == '/' ) directoryName.resize(length - 1); retcode = mkdir(directoryName.c_str(),0777); if ( retcode == -1 ) { if ( errno == EEXIST ) return true; if ( errno == ENOENT ) { int pos = directoryName.rfind(SLASH_STR); directoryName[pos] = 0; if ( MakeDirectory(directoryName) ) { directoryName[pos] = '/'; return MakeDirectory(directoryName); } } return false; } return true; }
/* * DownloadCheckDirs: Make sure that directories needed for downloading exist. * hParent is parent for error dialog. * Return True iff they all exist. */ Bool DownloadCheckDirs(HWND hParent) { // Make sure that necessary subdirectories exist if (MakeDirectory(download_dir) == False) { ClientError(hInst, hMain, IDS_CANTMAKEDIR, download_dir, GetLastErrorStr()); return False; } if (MakeDirectory(resource_dir) == False) { ClientError(hInst, hMain, IDS_CANTMAKEDIR, resource_dir, GetLastErrorStr()); return False; } if (MakeDirectory(help_dir) == False) { ClientError(hInst, hMain, IDS_CANTMAKEDIR, help_dir, GetLastErrorStr()); return False; } if (MakeDirectory(mail_dir) == False) { ClientError(hInst, hMain, IDS_CANTMAKEDIR, mail_dir, GetLastErrorStr()); return False; } if (MakeDirectory(ad_dir) == False) { ClientError(hInst, hMain, IDS_CANTMAKEDIR, ad_dir, GetLastErrorStr()); return False; } return True; }
//! \brief Finds the OS specific directory path to save and retrieve user config data static const std::string _SetupUserConfigPath() { #if defined _WIN32 char path[MAX_PATH]; // %APPDATA% (%USERPROFILE%\Application Data) if(SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_APPDATA, nullptr, 0, path))) { std::string user_path = std::string(path) + "/" APPUPCASEDIRNAME "/"; if(!DoesFileExist(user_path)) MakeDirectory(user_path); _CopyOldSettingsFile(user_path); return user_path; } #elif defined __APPLE__ passwd *pw = getpwuid(getuid()); if(pw) { std::string path = std::string(pw->pw_dir) + "/Library/Preferences/" APPUPCASEDIRNAME "/"; if(!DoesFileExist(path)) MakeDirectory(path); return path; } #else // Linux, BSD, other POSIX systems // Implementation of the freedesktop specs (at least partially) // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html // $XDG_CONFIG_HOME/valyriatear/ // equals to: ~/.config/valyriatear/ most of the time if (getenv("XDG_CONFIG_HOME")) { std::string path = std::string(getenv("XDG_CONFIG_HOME")) + "/" APPSHORTNAME "/"; if(!DoesFileExist(path)) MakeDirectory(path); _CopyOldSettingsFile(path); return path; } // We create a sane default: ~/.config/valyriatear passwd *pw = getpwuid(getuid()); if(pw) { std::string path = std::string(pw->pw_dir) + "/.config/"; if(!DoesFileExist(path)) MakeDirectory(path); path += "/" APPSHORTNAME "/"; if(!DoesFileExist(path)) MakeDirectory(path); _CopyOldSettingsFile(path); return path; } #endif // Default path if a specific solution could not be found. Note that this path may // not be writable by the user since it could be installed in administrator/root space PRINT_WARNING << "could not idenfity user config path, defaulting to system path" << std::endl; return "data/"; }
static bool MakeDirectoriesRecursive(StatCache* stat_cache, const PathBuffer& dir) { PathBuffer parent_dir = dir; PathStripLast(&parent_dir); // Can't go any higher. if (dir == parent_dir) return true; if (!MakeDirectoriesRecursive(stat_cache, parent_dir)) return false; char path[kMaxPathLength]; PathFormat(path, &dir); FileInfo info = StatCacheStat(stat_cache, path); if (info.Exists()) { // Just asssume this is a directory. We could check it - but there's currently no way via _stat64() calls // on Windows to check if a file is a symbolic link (to a directory). return true; } else { Log(kSpam, "create dir \"%s\"", path); bool success = MakeDirectory(path); StatCacheMarkDirty(stat_cache, path, Djb2HashPath(path)); return success; } }
DWORD FFileManagerWindows::InternalCopy( const TCHAR* DestFile, const TCHAR* SrcFile, UBOOL ReplaceExisting, UBOOL EvenIfReadOnly, UBOOL Attributes, FCopyProgress* Progress ) { if( EvenIfReadOnly ) { SetFileAttributesW(DestFile, 0); } DWORD Result; if( Progress ) { Result = FFileManagerGeneric::Copy( DestFile, SrcFile, ReplaceExisting, EvenIfReadOnly, Attributes, Progress ); } else { MakeDirectory(*FFilename(DestFile).GetPath(), TRUE); if( CopyFileW(SrcFile, DestFile, !ReplaceExisting) != 0) { Result = COPY_OK; } else { Result = COPY_MiscFail; } } if( Result==COPY_OK && !Attributes ) { SetFileAttributesW(DestFile, 0); } return Result; }
/** * Opens a file. (Thread-safe) * If opened for write, it will create any necessary directory structure. * * @param Filename Full path to the file * @param Flags A combination of EFileOpenFlags, specifying read/write access. * @return File handle **/ FFileHandle FFileManagerWindows::InternalFileOpen( const TCHAR* Filename, DWORD Flags ) { DWORD AccessFlags = (Flags & IO_READ) ? GENERIC_READ : 0; DWORD CreateFlags = 0; if ( Flags & IO_WRITE ) { MakeDirectory(*FFilename(Filename).GetPath(), TRUE); AccessFlags |= GENERIC_WRITE; CreateFlags = (Flags & IO_APPEND) ? OPEN_ALWAYS : CREATE_NEW; } else { CreateFlags = OPEN_EXISTING; } HANDLE WinHandle = CreateFile( Filename, AccessFlags, FILE_SHARE_READ, NULL, CreateFlags, FILE_ATTRIBUTE_NORMAL, NULL ); if ( WinHandle == INVALID_HANDLE_VALUE ) { WinHandle = (HANDLE) INDEX_NONE; } else if ( Flags & IO_APPEND ) { SetFilePointer( WinHandle, 0, NULL, FILE_END ); } FFileHandle Handle( PTRINT(WinHandle), 0 ); return Handle; }
UBOOL FFileManagerWindows::InternalMove( const TCHAR* Dest, const TCHAR* Src, UBOOL Replace, UBOOL EvenIfReadOnly, UBOOL Attributes ) { MakeDirectory(*FFilename(Dest).GetPath(), TRUE); INT Result = MoveFileExW(Src,Dest, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); if( !Result ) { // If the move failed, throw a warning but retry before we throw an error DWORD error = GetLastError(); warnf( NAME_Warning, TEXT("MoveFileExW was unable to move '%s' to '%s', retrying... (GetLastE-r-r-o-r: %d)"), Src, Dest, error ); // Wait just a little bit (i.e. a totally arbitrary amount)... Sleep(500); // Try again Result = MoveFileExW(Src, Dest, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); if( !Result ) { error = GetLastError(); warnf( NAME_Error, TEXT("Error moving file '%s' to '%s' (GetLastError: %d)"), Src, Dest, error ); } else { warnf( NAME_Warning, TEXT("MoveFileExW recovered during retry!") ); } } return (Result != 0); }
FArchive* FFileManagerGeneric::CreateFileWriter( const TCHAR* Filename, uint32 Flags ) { // Only allow writes to files that are not signed // Except if the file is missing( that way corrupt ini files can be autogenerated by deleting them ) if( FSHA1::GetFileSHAHash( Filename, NULL ) && FileSize( Filename ) != -1 ) { UE_LOG( LogFileManager, Log, TEXT( "Can't write to signed game file: %s" ),Filename ); return new FArchiveFileWriterDummy(); } MakeDirectory( *FPaths::GetPath(Filename), true ); if( Flags & FILEWRITE_EvenIfReadOnly ) { GetLowLevel().SetReadOnly( Filename, false ); } IFileHandle* Handle = GetLowLevel().OpenWrite( Filename, !!( Flags & FILEWRITE_Append ), !!( Flags & FILEWRITE_AllowRead ) ); if( !Handle ) { if( Flags & FILEWRITE_NoFail ) { UE_LOG( LogFileManager, Fatal, TEXT( "Failed to create file: %s" ), Filename ); } return NULL; } return new FArchiveFileWriterGeneric( Handle, Filename, Handle->Tell() ); }
int ArchivePanel::pProcessKey( int nKey, DWORD dwControlState ) { if ( (nKey == VK_F7) && (dwControlState == 0) ) { TCHAR szFolderPath[MAX_PATH]; if ( Info.InputBox ( _M(MMakeFolderTitle), _M(MMakeFolderPrompt), NULL, NULL, szFolderPath, MAX_PATH, NULL, FIB_EXPANDENV|FIB_BUTTONS ) ) { bool bResult = MakeDirectory(szFolderPath); if ( bResult ) Update(); return FALSE; } } return FALSE; }
/* * MailSaveMessage: Save given message string as given message number. * Return True iff message successfully saved. */ Bool MailSaveMessage(char *msg, int msgnum) { Bool done, saved; int outfile; char filename[MAX_PATH + FILENAME_MAX]; do { done = True; /* If mail directory doesn't exist, try to create it */ saved = MakeDirectory(MAIL_DIR); sprintf(filename, "%s\\%04d.msg", MAIL_DIR, msgnum); if ((outfile = open(filename, _O_BINARY | _O_RDWR | _O_CREAT, _S_IWRITE | _S_IREAD)) == -1) saved = False; if (write(outfile, msg, strlen(msg)) <= 0) saved = False; close(outfile); // Ask user about retrying if (!saved) if (AreYouSure(hInst, hReadMailDlg, YES_BUTTON, IDS_SAVEFAILED)) done = False; } while (!done); return saved; }
FilePath & FilePath::MakeDirectoryPathname() { DVASSERT(!IsEmpty()); absolutePathname = MakeDirectory(absolutePathname); return *this; }
void FilePath::ReplaceDirectory(const String &directory) { DVASSERT(!IsEmpty()); const String filename = GetFilename(); absolutePathname = NormalizePathname((MakeDirectory(directory) + filename)); pathType = GetPathType(absolutePathname); }
void VO_ASMNDProfiles::VO_Load ( const string& fd ) { VO_AXM::VO_Load(fd); string fn = fd+"/ASMNDProfiles"; if (!MakeDirectory(fn) ) { cout << "ASMNDProfiles subfolder is not existing. " << endl; exit(EXIT_FAILURE); } ifstream fp; string tempfn; string temp; // ASMNDProfiles tempfn = fn + "/ASMNDProfiles" + ".txt"; SafeInputFileOpen(fp, tempfn); fp >> temp >> this->m_iNbOfProfileDim; // m_iNbOfProfileDim this->m_iNbOfProfilesPerPixelAtLevels.resize(this->m_iNbOfPyramidLevels); fp >> temp >> this->m_iNbOfProfilesPerPixelAtLevels[0]; // m_iNbOfProfilesPerPixelAtLevels[0] VO_ASMNDProfiles::VO_ProduceLevelProfileNumbers(this->m_iNbOfProfilesPerPixelAtLevels, this->m_iNbOfPyramidLevels, this->m_iNbOfProfilesPerPixelAtLevels[0]); fp.close();fp.clear(); // m_vvMeanNormalizedProfile tempfn = fn + "/m_vvMeanNormalizedProfile" + ".txt"; SafeInputFileOpen(fp, tempfn); fp >> temp; this->m_vvMeanNormalizedProfile.resize(this->m_iNbOfPyramidLevels); for (unsigned int i = 0; i < this->m_iNbOfPyramidLevels; i++) { this->m_vvMeanNormalizedProfile[i].resize(this->m_iNbOfPoints); for (unsigned int j = 0; j < this->m_iNbOfPoints; j++) { fp >> this->m_vvMeanNormalizedProfile[i][j]; } } fp.close();fp.clear(); // m_vvvCVMInverseOfSg tempfn = fn + "/m_vvvCVMInverseOfSg" + ".txt"; SafeInputFileOpen(fp, tempfn); fp >> temp; this->m_vvvCVMInverseOfSg.resize(this->m_iNbOfPyramidLevels); for (unsigned int i = 0; i < this->m_iNbOfPyramidLevels; i++) { this->m_vvvCVMInverseOfSg[i].resize(this->m_iNbOfPoints); for (unsigned int j = 0; j < this->m_iNbOfPoints; j++) { this->m_vvvCVMInverseOfSg[i][j].resize(this->m_iNbOfProfileDim); for(unsigned int k = 0; k < this->m_iNbOfProfileDim; k++) { fp >> this->m_vvvCVMInverseOfSg[i][j][k]; } } } fp.close();fp.clear(); }
bool FFileManagerGeneric::Move( const TCHAR* Dest, const TCHAR* Src, bool Replace, bool EvenIfReadOnly, bool Attributes, bool bDoNotRetryOrError ) { MakeDirectory( *FPaths::GetPath(Dest), true ); // Retry on failure, unless the file wasn't there anyway. if( GetLowLevel().FileExists( Dest ) && !GetLowLevel().DeleteFile( Dest ) && !bDoNotRetryOrError ) { // If the delete failed, throw a warning but retry before we throw an error UE_LOG( LogFileManager, Warning, TEXT( "DeleteFile was unable to delete '%s', retrying in .5s..." ), Dest ); // Wait just a little bit( i.e. a totally arbitrary amount )... FPlatformProcess::Sleep( 0.5f ); // Try again if( !GetLowLevel().DeleteFile( Dest ) ) { UE_LOG( LogFileManager, Error, TEXT( "Error deleting file '%s'." ), Dest ); return false; } else { UE_LOG( LogFileManager, Warning, TEXT( "DeleteFile recovered during retry!" ) ); } } if( !GetLowLevel().MoveFile( Dest, Src ) ) { if( bDoNotRetryOrError ) { return false; } int32 RetryCount = 10; bool bSuccess = false; while (RetryCount--) { // If the move failed, throw a warning but retry before we throw an error UE_LOG(LogFileManager, Warning, TEXT("MoveFile was unable to move '%s' to '%s', retrying in .5s..."), Src, Dest); // Wait just a little bit( i.e. a totally arbitrary amount )... FPlatformProcess::Sleep(0.5f); // Try again bSuccess = GetLowLevel().MoveFile(Dest, Src); if (bSuccess) { UE_LOG(LogFileManager, Warning, TEXT("MoveFile recovered during retry!")); break; } } if (!bSuccess) { UE_LOG( LogFileManager, Error, TEXT( "Error moving file '%s' to '%s'." ), Src, Dest ); return false; } } return true; }
void MakeDirectoryRecursive(std::string dirName) { if(dirName == "" || dirName == "/") return; int parentSlashPos = dirName.rfind('/',dirName.length()-2); std::string parentDir = dirName.substr(0,parentSlashPos+1); MakeDirectoryRecursive(parentDir); MakeDirectory(dirName); }
/** * @author JIA Pei * @version 2010-04-03 * @brief Load all AAMFCIA data from a specified folder * @param fd Input - the folder that AAMFCIA to be loaded from */ void VO_AAMForwardIA::VO_Load(const string& fd) { VO_AXM::VO_Load(fd); string fn = fd+"/AAMFCIA"; if (!MakeDirectory(fn) ) { cout << "AAMFCIA subfolder is not existing. " << endl; exit(EXIT_FAILURE); } }
/** * @author JIA Pei * @version 2010-04-03 * @brief Save AAMFCIA to a specified folder * @param fn Input - the folder that AAMFCIA to be saved to */ void VO_AAMForwardIA::VO_Save(const string& fd) { VO_AXM::VO_Save(fd); string fn = fd+"/AAMFCIA"; MakeDirectory(fn); fstream fp; string tempfn; }
int main(int argc, char* argv[]) { if (argc != 2) { fprintf(stderr, "Wrong number of arguments\n"); exit(1); } ConvertPathCharacters(argv[1]); return MakeDirectory(argv[1]); }
void VO_ASMNDProfiles::VO_Save ( const string& fd ) { VO_AXM::VO_Save(fd); // create ASM subfolder for just ASM model data string fn = fd+"/ASMNDProfiles"; MakeDirectory(fn); ofstream fp; string tempfn; // ASMNDProfiles tempfn = fn + "/ASMNDProfiles" + ".txt"; fp.open(tempfn.c_str (), ios::out); fp << "m_iNbOfProfileDim" << endl << this->m_iNbOfProfileDim << endl; fp << "m_iNbOfProfilesPerPixelAtLevels[0]" << endl << this->m_iNbOfProfilesPerPixelAtLevels[0] << endl; fp.close();fp.clear(); // m_vvMeanNormalizedProfile tempfn = fn + "/m_vvMeanNormalizedProfile" + ".txt"; fp.open(tempfn.c_str (), ios::out); fp << "m_vvMeanNormalizedProfile" << endl; // fp << this->m_vvMeanNormalizedProfile; // You can output everything by the above line, but you won't have level and node description in the output file. for (unsigned int i = 0; i < this->m_iNbOfPyramidLevels; i++) { for (unsigned int j = 0; j < this->m_iNbOfPoints; j++) { fp << "level " << i << " node " << j << endl; fp << this->m_vvMeanNormalizedProfile[i][j] << endl; } } fp.close();fp.clear(); // m_vvvCVMInverseOfSg tempfn = fn + "/m_vvvCVMInverseOfSg" + ".txt"; fp.open(tempfn.c_str (), ios::out); fp << "m_vvvCVMInverseOfSg" << endl; //fp << this->m_vvvCVMInverseOfSg; // You can output everything by the above line, but you won't have level and node description in the output file. for (unsigned int i = 0; i < this->m_iNbOfPyramidLevels; i++) { for (unsigned int j = 0; j < this->m_iNbOfPoints; j++) { for(unsigned int k = 0; k < this->m_iNbOfProfileDim; k++) { fp << "level " << i << " node " << j << " dim " << k << endl; fp << this->m_vvvCVMInverseOfSg[i][j][k] << endl; } } } fp.close();fp.clear(); }
static bool CreateSavePath(char *Path, int index, const char *slotname) { PathJoin( Path, core->SavePath, SaveDir(), NULL ); //if the path exists in different case, don't make it again if (!MakeDirectory(Path)) { printMessage("SaveGameIterator", "Unable to create save game directory '%s'\n", RED, Path); return false; } //keep the first part we already determined existing char dir[_MAX_PATH]; snprintf( dir, _MAX_PATH, "%09d-%s", index, slotname ); PathJoin(Path, Path, dir, NULL); //this is required in case the old slot wasn't recognised but still there core->DelTree(Path, false); if (!MakeDirectory(Path)) { printMessage("SaveGameIterator", "Unable to create save game directory '%s'\n", RED, Path); return false; } return true; }
bool ChangeDirectory(string directoryName) { if ( directoryName == "" ) return false; if ( chdir(directoryName.c_str()) == 0 ) return true; if ( errno == ENOENT ) { if ( MakeDirectory(directoryName) && (chdir(directoryName.c_str())==0) ) return true; } return false; }
void TakeScreenshot() { CImage32 screen(GetScreenWidth(), GetScreenHeight()); DirectGrab(0, 0, GetScreenWidth(), GetScreenHeight(), screen.GetPixels()); // try to create the screenshot directory MakeDirectory(s_ScreenshotDirectory.c_str()); char filename[MAX_PATH]; sprintf(filename, "screenshot.png"); std::string save_path; save_path = s_ScreenshotDirectory + '/'; save_path += filename; screen.Save(save_path.c_str()); }
/** * @author JIA Pei * @version 2010-04-03 * @brief Load all AAMICIA data from a specified folder * @param fd Input - the folder that AAMICIA to be loaded from */ void VO_AAMForwardIA::VO_LoadParameters4Fitting(const string& fd) { VO_AXM::VO_LoadParameters4Fitting(fd); string fn = fd+"/AAMFCIA"; if (!MakeDirectory(fn) ) { cout << "AAMFCIA subfolder is not existing. " << endl; exit(EXIT_FAILURE); } fstream fp; string tempfn; string temp; }
void MakeDirectory( char *name ) { char *path; printf( WIDE("Checking %s\n"), name ); path = pathrchr( name ); if( path ) { path[0] = 0; MakeDirectory( name ); path[0] = '/'; } if( !CreateDirectory( name, NULL ) ) { if( GetLastError() != ERROR_ALREADY_EXISTS ) // 183 { fprintf( stderr, WIDE("Create Directory failed on :%s %d\n"), name, GetLastError() ); failed = 1; } } }
void HtmlExtractor::moveTemplates(const QString &path) { MakeDirectory(path); QDir dir(path); QWebElementCollection elements = getDocument().findAll("[type=\"text/template\"]"); if(elements.count()) { for(QWebElementCollection::iterator it = elements.begin(), end=elements.end(); it!=end; ++it) { QWebElement element = *it; QString filename = element.attribute("id").replace("_tpl",".tpl"); qDebug()<<"moving element : "<<filename; move(element, dir.filePath(filename), false); } } else { qDebug()<<"no element found"; } }
/** GenerateOutput: Generates IBY file for the given package file @internalComponent @released @param aPkgFile - package file name @param aParser - corresponding package file reader object */ void Sis2Iby::GenerateIby(String aPkgFile, PPKGPARSER aParser) { String ibyFile = iOutputPath; AppendFileName(ibyFile, aPkgFile); ibyFile.append(".iby"); if( !MakeDirectory(iOutputPath) ) throw SisUtilsException(iOutputPath.c_str(),"Failed to create path"); if(IsVerboseMode()) { std::cout << "Generating IBY file " << ibyFile.c_str() << std::endl; } ibyHandle.open((char*)ibyFile.data(),(std::ios::out)); if(!ibyHandle.good()) { throw SisUtilsException(ibyFile.c_str(),"Failed to create IBY file"); } // Generating Header MakeFullPath(aPkgFile); ibyHandle << "\n// Generated IBY file for the package file: "; ibyHandle << aPkgFile; // Language Supported WriteLanguages(aParser); // Package Header WritePackageHeader(aParser); // Install options list WriteInstallOptions(aParser); // Package Body WritePackageBody(aParser); ibyHandle.close(); }
bool make_path(char * tgt) { char path[MAX_PATHNAME_LEN+1]; char new_path[MAX_PATHNAME_LEN+1]; char * p; char * q; struct stat statbuf; strcpy(path, tgt); /* Make local copy as we will use strtok() */ p = path; q = new_path; if (*p == DS) /* 0355 */ { *(q++) = DS; p++; } *q = '\0'; while((q = strtok(p, DSS)) != NULL) { strcat(new_path, q); if (stat(new_path, &statbuf)) /* Directory does not exist */ { if (MakeDirectory(new_path) != 0) return FALSE; } else if (!(statbuf.st_mode & S_IFDIR)) /* Exists but not as a directory */ { return FALSE; } strcat(new_path, DSS); p = NULL; } return TRUE; }
/*static*/ bool OSCompat::MakeDirectory(const char* s) { if (mkdir(s, 0777) >= 0) { return true; }else if(errno == ENOENT){ //recursively create the base directories std::string base_dir=s; std::string::size_type pos = base_dir.rfind(PATH_SEPARATOR); if(pos != std::string::npos){ base_dir.erase(pos); if( MakeDirectory(base_dir.c_str()) ){ return mkdir(s, 0777) >= 0; }else{ return false; } } else { return false; } }else{ return (errno == EEXIST); } }
static BOOL cb_walk_campaign(char* name, uint32_t flags, uint64_t len, int64_t lastWriteTime, uint32_t* ctx) { char text1[_MAX_PATH], text2[_MAX_PATH]; BOOL fok; walk_campaign_param_t* wcp = (walk_campaign_param_t*)ctx; if (flags & FILE_ATTRIBUTE_DIRECTORY ) { sprintf(text2, "%s\\%s", wcp->ins_campaign_dir.c_str(), name); MakeDirectory(std::string(text2)); // !!不要在<data>/campaigns/{campaign}下建images目录 sprintf(text1, "%s\\%s\\images", wcp->src_campaign_dir.c_str(), name); sprintf(text2, "%s\\%s\\images", wcp->ins_campaign_dir.c_str(), name); if (is_directory(text1)) { posix_print("<data>, copy %s to %s ......\n", text1, text2); fok = copyfile(text1, text2); if (!fok) { posix_print_mb("复制目录,从%s到%s,失败", text1, text2); return FALSE; } } } return TRUE; }
bool MakePath( const char* path_ ) { char path[256]; strncpy(path, path_, sizeof(path)-1); path[sizeof(path)-1] = '\0'; for(int i = 0; path[i] != '\0'; ++i) { if(path[i] == '/' || path[i] == '\\') { path[i] = '\0'; const FileType fileType = GetFileType(path); switch(GetFileType(path)) { case FILE_TYPE_INVALID: if(MakeDirectory(path) == false) return false; break; case FILE_TYPE_DIRECTORY: // everything fine break; default: return false; } path[i] = DirSep; } } /* const FileType fileType = GetFileType(path); if(fileType == FILE_TYPE_INVALID) if(MakeDirectory(path) == false) return false; */ return true; }