/* 系统辅助函数-Init [Directory Sets] this System needs */ void initDirectorySets(void){ char dirName[MAX_PATHNAME_LEN]; char DataDirPath[MAX_PATHNAME_LEN]; char LogDirPath[MAX_PATHNAME_LEN]; GetProjectDir(dirName); sprintf(DataDirPath, "%s\\DataStorage", dirName); sprintf(LogDirPath, "%s\\Logs", dirName); int oldValue; oldValue = SetBreakOnLibraryErrors(0); int isDataDirExisted = MakeDir(DataDirPath); int isLogDirExisted = MakeDir(LogDirPath); SetBreakOnLibraryErrors (oldValue); if(isDataDirExisted == 0) addLog("Successfully create the Directory:\n\"DataStorage\" and \"Logs\"", 0, panelHdl); else if( isDataDirExisted == -9) addLog("\"DataStorage\" and \"Logs\" \nDirectory has already existed!", 0, panelHdl); }
bool CreatePath(const wchar *Path,bool SkipLastName) { if (Path==NULL || *Path==0) return(false); #if defined(_WIN_ALL) || defined(_EMX) uint DirAttr=0; #else uint DirAttr=0777; #endif bool Success=true; for (const wchar *s=Path;*s!=0;s++) { if (s-Path>=NM) break; if (*s==CPATHDIVIDER) { wchar DirName[NM]; wcsncpy(DirName,Path,s-Path); DirName[s-Path]=0; if (MakeDir(NULL,DirName,true,DirAttr)==MKDIR_SUCCESS) { #ifndef GUI char DirNameA[NM]; WideToChar(DirName,DirNameA,ASIZE(DirNameA)); DirNameA[ASIZE(DirNameA)-1]=0; mprintf(St(MCreatDir),DirNameA); mprintf(" %s",St(MOk)); #endif } else Success=false; } } if (!SkipLastName) if (!IsPathDiv(*PointToLastChar(Path))) if (MakeDir(NULL,Path,true,DirAttr)!=MKDIR_SUCCESS) Success=false; return(Success); }
BOOL CInstall::InstallFile(char *filename, BOOL bNoCopy) { char existing_name[MAXSTR]; char new_name[MAXSTR]; char dir_name[MAXSTR]; strcpy(existing_name, m_szSourceDir); strcat(existing_name, "\\"); strcat(existing_name, filename); strcpy(new_name, m_szTargetDir); strcat(new_name, "\\"); strcat(new_name, filename); strcpy(dir_name, new_name); char *p = strrchr(dir_name, '\\'); if (p) { *p = '\0'; if (!MakeDir(dir_name)) { AddMessage("Failed to make directory "); AddMessage(dir_name); AddMessage("\n"); return FALSE; } } AddMessage(" "); AddMessage(new_name); AddMessage("\n"); if (bNoCopy) { // Don't copy files. Leave them where they are. // Check that all files exist FILE *f; if ((f = fopen(existing_name, "r")) == (FILE *)NULL) { AddMessage("Missing file "); AddMessage(existing_name); AddMessage("\n"); return FALSE; } fclose(f); } else { if (!CopyFile(existing_name, new_name, FALSE)) { char message[MAXSTR+MAXSTR+100]; wsprintf(message, "Failed to copy file %s to %s\n", existing_name, new_name); AddMessage(message); return FALSE; } ResetReadonly(new_name); fputs(new_name, m_fLogNew); fputs("\n", m_fLogNew); } return TRUE; }
BOOL CInstall::Init(const char *szSourceDir, const char *szFileList) { FILE *f; strcpy(m_szSourceDir, szSourceDir); // remove trailing backslash char *p; p = m_szSourceDir + strlen(m_szSourceDir) - 1; if (*p == '\\') *p = '\0'; strcpy(m_szFileList, szFileList); m_szRegistryNew[0] = m_szRegistryOld[0] = m_szShellNew[0] = m_szShellOld[0] = m_szFileNew[0] = '\0'; // Open list of files SetCurrentDirectory(m_szSourceDir); f = fopen(m_szFileList, "r"); if (f == (FILE *)NULL) { char buf[MAXSTR]; wsprintf(buf, "Failed to open \042%s\042\n", m_szFileList); AddMessage(buf); return FALSE; } // get application and directory name m_szUninstallName[0] = '\0'; if (!fgets(m_szUninstallName, sizeof(m_szUninstallName), f)) { AddMessage("Invalid file list\n"); fclose(f); return FALSE; } if (*m_szUninstallName ) m_szUninstallName[strlen(m_szUninstallName)-1] = '\0'; m_szMainDir[0] = '\0'; if (!fgets(m_szMainDir, sizeof(m_szMainDir), f)) { AddMessage("Invalid file list\n"); fclose(f); return FALSE; } if (*m_szMainDir ) m_szMainDir[strlen(m_szMainDir)-1] = '\0'; fclose(f); // Create log directory strcpy(m_szLogDir, m_szTargetDir); strcat(m_szLogDir, "\\"); strcat(m_szLogDir, m_szMainDir); MakeDir(m_szLogDir); return TRUE; }
DEFINE_THIS_FILE /*---------------------------------------------------------------------------------------------- This is called recursively to create all the directories in the given path. If any part of the path already exists, then that is not a problem. @param pszPath Path whose directories are to be created. @return False if path did not exist and could not be created, otherwise True. ----------------------------------------------------------------------------------------------*/ bool MakeDir(const achar * pszPath) { #if WIN32 StrAppBufPath strbp(pszPath); // Look for last backslash: StrAppBuf strbSlash("\\"); #else StrAnsiBufPath strbp(pszPath); // Look for last slash: StrAnsiBuf strbSlash("/"); #endif int ichStart = strbp.ReverseFindCh(strbSlash[0]); if (ichStart > 0) { // Make path comprising all except last component: StrAppBufPath strbpSmaller; strbpSmaller.Assign(strbp.Left(ichStart).Chars()); // Check for recursion base case - no more backslashes: ichStart = strbpSmaller.ReverseFindCh(strbSlash[0]); if (ichStart > 0) { if (!MakeDir(strbpSmaller)) return false; } } // If this next call fails, it may only be because the path already exists, so we will check // our overall success afterwards: #if WIN32 _tmkdir(strbp.Chars()); DWORD nFlags = GetFileAttributes(strbp.Chars()); if (nFlags == INVALID_FILE_ATTRIBUTES || !(nFlags & FILE_ATTRIBUTE_DIRECTORY)) return false; #else mkdir(strbp.Chars(), 0777); struct stat filestats; bool statfailed = stat(strbp.Chars(), &filestats); if (!statfailed && !S_ISDIR(filestats.st_mode)) return false; #endif return true; }
bool GetTremulousPk3s(const char* destdir, const char* basegame) { std::string baseuri = "https://github.com/wtfbbqhax/tremulous-data/raw/master/"; std::vector<std::string> files = { "data-gpp1.pk3", "data-1.1.0.pk3", "map-arachnid2-1.1.0.pk3", "map-atcs-1.1.0.pk3", "map-karith-1.1.0.pk3", "map-nexus6-1.1.0.pk3", "map-niveus-1.1.0.pk3", "map-transit-1.1.0.pk3", "map-tremor-1.1.0.pk3", "map-uncreation-1.1.0.pk3" }; RestClient::init(); MakeDir(destdir, basegame); if (!PromptDownloadPk3s(basegame, files)) return false; for (auto f : files ) { std::string destpath(destdir); destpath += "/"; destpath += basegame; destpath += "/"; destpath += f; if ( is_good(destpath) ) { return false; } std::cout << "Downloading " << baseuri << f << std::endl; std::ofstream dl(destpath); //dl.open(destpath); if ( dl.fail() ) { std::cerr << "Error " << strerror(errno) << "\n"; continue; } RestClient::Response resp = RestClient::get(baseuri + f); dl << resp.body; dl.close(); } return true; }
static void InitSystem(void) { ProcessList = NULL; InitDirectory(); SetUpDirectory(Directory, NULL, NULL, NULL, P_NONE); setenv("MON_DIRECTORY_PATH", Directory, 1); if (ThisEnv == NULL) { Error("DI file parse error."); } if (!MakeDir(TempDir, 0700)) { Error("cannot make TempDirRoot:%s", TempDir); } setenv("MCP_TEMPDIR_ROOT", TempDir, 1); }
/* create all the bozo dirs */ static int CreateDirs(const char *coredir) { if ((!strncmp (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH, strlen(AFSDIR_USR_DIRPATH))) || (!strncmp (AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH, strlen(AFSDIR_USR_DIRPATH)))) { MakeDir(AFSDIR_USR_DIRPATH); } if (!strncmp (AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH, strlen(AFSDIR_SERVER_AFS_DIRPATH))) { MakeDir(AFSDIR_SERVER_AFS_DIRPATH); } MakeDir(AFSDIR_SERVER_BIN_DIRPATH); MakeDir(AFSDIR_SERVER_ETC_DIRPATH); MakeDir(AFSDIR_SERVER_LOCAL_DIRPATH); MakeDir(AFSDIR_SERVER_DB_DIRPATH); MakeDir(AFSDIR_SERVER_LOGS_DIRPATH); #ifndef AFS_NT40_ENV if (!strncmp (AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH, strlen(AFSDIR_CLIENT_VICE_DIRPATH))) { MakeDir(AFSDIR_CLIENT_VICE_DIRPATH); } MakeDir(AFSDIR_CLIENT_ETC_DIRPATH); symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH); symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH, AFSDIR_CLIENT_CELLSERVDB_FILEPATH); #endif /* AFS_NT40_ENV */ if (coredir) MakeDir(coredir); return 0; }
bool Initialize(int /*argc*/, char* argv[], const String& programName) { LOG_ASSERT(NULL != argv); LOG_ASSERT(!programName.empty()); initApplicationRootPath(argv[0]); # ifdef TA3D_PLATFORM_WINDOWS initForWindows(); # else # ifndef TA3D_PLATFORM_DARWIN initForDefaultUnixes(); # else initForDarwin(); # endif # endif // Initialize the logging mecanism ResetTheLoggingMecanism(Yuni::String(Paths::Logs) <<programName << ".log"); // Welcome Commander ! logs.checkpoint() << "Welcome to TA3D"; logs.checkpoint() << "Version: " << TA3D_VERSION_HI << "." << TA3D_VERSION_LO << "-" << TA3D_VERSION_TAG << " (r" << TA3D_CURRENT_REVISION << ")"; logs.info(); LOG_INFO(LOG_PREFIX_PATHS << "Started from: `" << ApplicationRoot << "`"); ConfigFile = Preferences; ConfigFile += "ta3d.cfg"; LOG_INFO(LOG_PREFIX_PATHS << "Preferences: `" << Preferences << "`"); LOG_INFO(LOG_PREFIX_PATHS << "Cache: `" << Caches << "`"); LOG_INFO(LOG_PREFIX_PATHS << "Savegames: `" << Savegames << "`"); LOG_INFO(LOG_PREFIX_PATHS << "Screenshots: `" << Screenshots << "`"); LOG_INFO(LOG_PREFIX_PATHS << "Logs: `" << Logs << "`"); // Informations about the log file if (!logs.logFileIsOpened()) logs.error() << "Logs: Impossible to open `" << logs.logfile() << "`"; else logs.info() << "Opened the log file: `" << logs.logfile() << "`"; bool res = MakeDir(Caches) && MakeDir(Savegames) && MakeDir(Logs) && MakeDir(Preferences) && MakeDir(Screenshots) && MakeDir(Resources) && MakeDir(String(Savegames) << "multiplayer" << Paths::Separator); if (!res) { logs.fatal() << "Some paths are missing. Aborting now..."; exit(120); } return res; }
int MakeFileDir( const char* path, int permissions ) { // First get just the directories without the file int retValue, pathLength = strlen( path ); char* dirs = (char*) malloc( pathLength+1 ); memcpy( dirs, path, pathLength+1 ); StripLastPathComponent( dirs, pathLength ); // Now we make sure the directories exist retValue = MakeDir( dirs, permissions ); free( dirs ); return retValue; }
void CreatePath(const char *Path,const wchar *PathW,bool SkipLastName) { #ifdef _WIN_32 uint DirAttr=0; #else uint DirAttr=0777; #endif int PosW=0; for (const char *s=Path;*s!=0 && PosW<NM;s=charnext(s),PosW++) { bool Wide=PathW!=NULL && *PathW!=0; if (Wide && PathW[PosW]==CPATHDIVIDER || !Wide && *s==CPATHDIVIDER) { wchar *DirPtrW=NULL; if (Wide) { wchar DirNameW[NM]; strncpyw(DirNameW,PathW,PosW); DirNameW[PosW]=0; DirPtrW=DirNameW; } char DirName[NM]; strncpy(DirName,Path,s-Path); DirName[s-Path]=0; if (MakeDir(DirName,DirPtrW,DirAttr)==MKDIR_SUCCESS) { #ifndef GUI mprintf(St(MCreatDir),DirName); mprintf(" %s",St(MOk)); #endif } } } if (!SkipLastName) MakeDir(Path,PathW,DirAttr); }
void DelDir(const std::string& in_dir_name, bool del_this) { try{ boost::filesystem::path path_ = boost::filesystem::current_path() / in_dir_name; boost::filesystem::remove_all(path_); //std::cout <<"DelDir\n"; if (!del_this) MakeDir(in_dir_name); } catch(boost::filesystem::filesystem_error e) { //std::cout <<"DelDir crash\n"; } }
static void MakeDir (const char* name) { struct stat stats; if (stat (name, &stats) == 0) return; const char* bslash = strrchr (name, '\\'); if (!bslash) return; const size_t len = bslash - name; csString upPath; upPath.Append (name, len); MakeDir (upPath); CreateDirectoryA (name, 0); }
int CFileZillaApi::Command(t_command *pCommand) { //Check if call allowed if (!m_bInitialized) return FZ_REPLY_NOTINITIALIZED; //Dispatch command to command specific functions switch(pCommand->id) { case FZ_COMMAND_LIST: if (pCommand->param1!=_MPT("")) return List(pCommand->path,pCommand->param1,pCommand->param4); else if (!pCommand->path.IsEmpty()) return List(pCommand->path,pCommand->param4); else return List(pCommand->param4); break; case FZ_COMMAND_CONNECT: return Connect(pCommand->server); break; case FZ_COMMAND_DISCONNECT: return Disconnect(); break; case FZ_COMMAND_FILETRANSFER: return FileTransfer(pCommand->transferfile); break; case FZ_COMMAND_DELETE: return Delete(pCommand->param1, pCommand->path); break; case FZ_COMMAND_REMOVEDIR: return RemoveDir(pCommand->param1, pCommand->path); break; case FZ_COMMAND_MAKEDIR: return MakeDir(pCommand->path); break; case FZ_COMMAND_RENAME: return Rename(pCommand->param1, pCommand->param2, pCommand->path, pCommand->newPath); break; case FZ_COMMAND_CUSTOMCOMMAND: return CustomCommand(pCommand->param1); break; case FZ_COMMAND_CHMOD: return Chmod(pCommand->param4, pCommand->param1, pCommand->path); break; } return FZ_REPLY_INVALIDPARAM; }
/****************************************************************************** * Function Name: CreateLogFile * * Inputs : eLogFile * Outputs : - * Returns : * Globals Used : - * * Description : *****************************************************************************/ IMG_INTERNAL IMG_BOOL CreateLogFile(LogFile eLogFile, IMG_CHAR *pszFileName) { FILE *LogFile = NULL; IMG_BOOL bChangedToLogFileDir = IMG_FALSE; if (eLogFile >= LOGFILE_LAST_LOG_FILE) { return IMG_FALSE; } if(ChangeDir("logfiles")) { if ( MakeDir("logfiles") == 0) { ChangeDir("logfiles"); bChangedToLogFileDir = IMG_TRUE; } else { bChangedToLogFileDir = IMG_FALSE; } } else { bChangedToLogFileDir = IMG_TRUE; } if (pszFileName) { LogFile = fopen(pszFileName, "wc"); } if (bChangedToLogFileDir) { ChangeDir(".."); } gLogFiles[eLogFile] = LogFile; if (!LogFile) { DEBUG_MESSAGE(("CreateLogFile: Failed to create logfile \n")); return IMG_FALSE; } return IMG_TRUE; }
tstring CConfig::GetBkCfgFilePath() const { #ifdef _WIN32 tstring strPath = ::GetAppDir(); return ( strPath + CONFIG_BK_FILE ).c_str(); #elif defined ( __SYMBIAN32__ ) return _T( "e:\\mcu\\mcucfgbk.xml" ); #else tstring strPath = _T( "/usr/share/mcu/" ); if( !IsFileExist( strPath.c_str() ) ) { MakeDir( strPath.c_str() ); } return ( strPath + CONFIG_BK_FILE ).c_str(); #endif }
csPtr<iConfigFile> csGetPlatformConfig (const char* Key) { csString path = csGetPlatformConfigPath (Key); path << ".cfg"; size_t bslash = path.FindLast ('\\'); if (bslash != (size_t)-1) path[bslash] = 0; // @@@ Would be nicer if this was only done when the config file is really // saved to disk. MakeDir (path.GetData()); if (bslash != (size_t)-1) path[bslash] = '\\'; // Create/read a config file; okay if missing; will be created when written return new csConfigFile (path); }
static void RegisterSession( SessionData *data) { SessionCtrl *ctrl; ENTER_FUNC; snprintf(data->hdr->tempdir,SIZE_PATH,"%s/%s",TempDirRoot,data->hdr->uuid); if (!MakeDir(data->hdr->tempdir,0700)) { Error("cannot make session tempdir %s",data->hdr->tempdir); } ctrl = NewSessionCtrl(SESSION_CONTROL_INSERT); ctrl->session = data; SessionEnqueue(ctrl); ctrl = (SessionCtrl*)DeQueue(ctrl->waitq); FreeSessionCtrl(ctrl); LEAVE_FUNC; }
// 设置本地缓存目录 bool LCVideoManager::SetDirPath(const string& dirPath) { bool result = false; if (!dirPath.empty()) { m_dirPath = dirPath; if (m_dirPath.at(m_dirPath.length()-1) != '/' && m_dirPath.at(m_dirPath.length()-1) != '\\') { m_dirPath += "/"; } // 创建目录 result = MakeDir(m_dirPath); } return result; }
static int lua_makeDir(lua_State* L) { int res = false; int top = 0; const char* path = NULL; top = lua_gettop(L); jn2Exit0(top == 1); path = lua_tostring(L, 1); jn2Exit0(path); res = MakeDir(path); lua_pushboolean(L, res); return 1; Exit0: return 0; }
bool GetAppDataPath(wchar *Path,size_t MaxSize,bool Create) { LPMALLOC g_pMalloc; SHGetMalloc(&g_pMalloc); LPITEMIDLIST ppidl; *Path=0; bool Success=false; if (SHGetSpecialFolderLocation(NULL,CSIDL_APPDATA,&ppidl)==NOERROR && SHGetPathFromIDList(ppidl,Path) && *Path!=0) { AddEndSlash(Path,MaxSize); wcsncatz(Path,L"WinRAR",MaxSize); Success=FileExist(Path); if (!Success && Create) Success=MakeDir(Path,false,0)==MKDIR_SUCCESS; } g_pMalloc->Free(ppidl); return Success; }
bool MkDirHier(const string& path) { vector<string> components; _SplitPath(path, components); for (size_t i = 0; i < components.size(); i++) { if (!IsDir(components[i])) { if (!MakeDir(components[i].c_str())) return false; } if (!ChangeDir(components[i])) return false; } return true; }
/** Tests the creation of a directory with 2 threads accessing different directories (the current and one with 300 files) @param aSelector Configuration in case of manual execution */ LOCAL_C TInt TestMakeMultDif(TAny* aSelector) { TInt i = 100; TBuf16<50> directory; TBuf16<50> dirtemp; TInt testStep; Validate(aSelector); CreateDirWithNFiles(300,3); directory = gSessionPath; dirtemp.Format(KDirMultipleName2, 3, 300); directory.Append(dirtemp); gDelEntryDir2 = directory; test.Printf(_L("#~TS_Title_%d,%d: MkDir with mult clients accessing dif dirs, RFs::MkDir\n"), gTestHarness, gTestCase); i = 100; testStep = 1; while(i <= KMaxFiles) { if(i == 100 || i == 1000 || i == 5000 || i == 10000) { directory = gSessionPath; dirtemp.Format(KDirMultipleName2, 2, i); directory.Append(dirtemp); gDelEntryDir = directory; DoTest2(DeleteEntryAccess); MakeDir(i, testStep++); DoTestKill(); } i += 100; } gTestCase++; return(KErrNone); }
// Initialize tiny log TINY_LOG *NewTinyLog() { char name[MAX_PATH]; SYSTEMTIME st; TINY_LOG *t; LocalTime(&st); MakeDir(TINY_LOG_DIRNAME); Format(name, sizeof(name), TINY_LOG_FILENAME, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); t = ZeroMalloc(sizeof(TINY_LOG)); StrCpy(t->FileName, sizeof(t->FileName), name); t->io = FileCreate(name); t->Lock = NewLock(); return t; }
void FileHandle::FileOperations(){ if(FetchFile() == -1 || CheckMIME() == -1) return; if(result==false) return; if(MakeDir()==-1) return; Compile(); if(result==false){ CleanUp(); return; } if(PrepareToExecute()==-1){ CleanUp(); return; } Execute(); }
static void GetAppDataPath(wchar *Path,size_t MaxSize) { LPMALLOC g_pMalloc; SHGetMalloc(&g_pMalloc); LPITEMIDLIST ppidl; *Path=0; bool Success=false; if (SHGetSpecialFolderLocation(NULL,CSIDL_APPDATA,&ppidl)==NOERROR && SHGetPathFromIDList(ppidl,Path) && *Path!=0) { AddEndSlash(Path,MaxSize); wcsncatz(Path,L"WinRAR",MaxSize); Success=FileExist(Path) || MakeDir(Path,false,0)==MKDIR_SUCCESS; } if (!Success) { GetModuleFileName(NULL,Path,(DWORD)MaxSize); RemoveNameFromPath(Path); } g_pMalloc->Free(ppidl); }
int MoveRenameFileEx (LPCTSTR szFilePathName, LPCTSTR szDestFolderPath, BOOL bRenFile, BOOL bMoveFile, BOOL bMoveRenLockedFiles) { TCHAR szNewPathName[MAX_PATH], szResult[MAX_PATH]; int ret = FL_SUCCESS; if (::GetFileAttributes (szFilePathName) == 0xffffffff) return ret;//FL_ENOFILE; ::SetFileAttributes (szFilePathName, FILE_ATTRIBUTE_NORMAL); ::lstrcpy (szResult, szFilePathName); BOOL bSuccess = TRUE; if (bRenFile) { ::lstrcpy (szNewPathName, szFilePathName); ::lstrcat (szNewPathName, _T(".vir")); bSuccess = ::MoveFileEx (szResult, szNewPathName, MOVEFILE_REPLACE_EXISTING); if (bSuccess) ::lstrcpy (szResult, szNewPathName); } if (bMoveFile && bSuccess) { if (::GetFileAttributes (szDestFolderPath) == 0xffffffff && MakeDir (szDestFolderPath) == -1) return FL_EACCESS; ::lstrcpy (szNewPathName, szDestFolderPath); ::PathAddBackslash (szNewPathName); ::lstrcat (szNewPathName, ::PathFindFileName (szResult)); bSuccess = ::MoveFileEx (szResult, szNewPathName, MOVEFILE_REPLACE_EXISTING); } if (!bSuccess) { ret = FL_EWRITE; if (bMoveRenLockedFiles) { // The file might be locked, try move/rename it at next system restart. ::MoveFileEx (szResult, szNewPathName, MOVEFILE_DELAY_UNTIL_REBOOT); } } return ret; }
void CopyDir(std::string from_dir_name, std::string to_dir_name, bool copy_this) { try{ if (false == AccessDir(from_dir_name)) { return; } // 防止拷贝自己 if (from_dir_name == to_dir_name) { return; } if ( AccessDir(to_dir_name) == false) MakeDir(to_dir_name); std::list<std::string> file_list; GetDirFileList(from_dir_name, file_list); for (std::list<std::string>::iterator it = file_list.begin(); it != file_list.end(); ++it) { std::string new_name = *it; std::string file_name = new_name.substr(from_dir_name.size() + (boost::filesystem::current_path()).string().length()); new_name = to_dir_name + file_name; FMove(from_dir_name + "\\" + file_name, new_name, false); } //std::cout <<"CopyDir\n"; } catch(boost::filesystem::filesystem_error e) { //std::cout <<"CopyDir crash\n"; } }
/** Times the creation of a directory Precondition: This test expectsthe drive already filled with the right files @param aSelector Configuration in case of manual execution */ LOCAL_C TInt TestMake(TAny* aSelector) { TInt i = 100; TInt testStep; Validate(aSelector); test.Printf(_L("#~TS_Title_%d,%d: MkDir, RFs::MkDir\n"), gTestHarness, gTestCase); i = 100; testStep = 1; while(i <= KMaxFiles) { if(i == 100 || i == 1000 || i == 5000 || i == 10000) { MakeDir(i, testStep++); } i += 100; } gTestCase++; return(KErrNone); }
void CmdExtract::ExtrCreateDir(Archive &Arc,const wchar *ArcFileName) { if (Cmd->Test) { #ifndef GUI mprintf(St(MExtrTestFile),ArcFileName); mprintf(L" %s",St(MOk)); #endif return; } MKDIR_CODE MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr); bool DirExist=false; if (MDCode!=MKDIR_SUCCESS) { DirExist=FileExist(DestFileName); if (DirExist && !IsDir(GetFileAttr(DestFileName))) { // File with name same as this directory exists. Propose user // to overwrite it. bool UserReject; FileCreate(Cmd,NULL,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime); DirExist=false; } if (!DirExist) { CreatePath(DestFileName,true); MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr); if (MDCode!=MKDIR_SUCCESS) { wchar OrigName[ASIZE(DestFileName)]; wcsncpyz(OrigName,DestFileName,ASIZE(OrigName)); MakeNameUsable(DestFileName,true); CreatePath(DestFileName,true); MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr); #ifndef SFX_MODULE if (MDCode==MKDIR_SUCCESS) uiMsg(UIERROR_RENAMING,Arc.FileName,OrigName,DestFileName); #endif } } } if (MDCode==MKDIR_SUCCESS) { #ifndef GUI mprintf(St(MCreatDir),DestFileName); mprintf(L" %s",St(MOk)); #endif PrevExtracted=true; } else if (DirExist) { if (!Cmd->IgnoreGeneralAttr) SetFileAttr(DestFileName,Arc.FileHead.FileAttr); PrevExtracted=true; } else { uiMsg(UIERROR_DIRCREATE,Arc.FileName,DestFileName); ErrHandler.SysErrMsg(); #ifdef RARDLL Cmd->DllError=ERAR_ECREATE; #endif ErrHandler.SetErrorCode(RARX_CREATE); } if (PrevExtracted) { #if defined(_WIN_ALL) && !defined(SFX_MODULE) if (Cmd->SetCompressedAttr && (Arc.FileHead.FileAttr & FILE_ATTRIBUTE_COMPRESSED)!=0 && WinNT()) SetFileCompression(DestFileName,true); #endif SetDirTime(DestFileName, Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.FileHead.mtime, Cmd->xctime==EXTTIME_NONE ? NULL:&Arc.FileHead.ctime, Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.FileHead.atime); } }