本文整理汇总了C++中MakeDir函数的典型用法代码示例。如果您正苦于以下问题:C++ MakeDir函数的具体用法?C++ MakeDir怎么用?C++ MakeDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initDirectorySets
/* 系统辅助函数-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);
}
示例2: CreatePath
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);
}
示例3: MakeDir
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;
}
示例4: GetTremulousPk3s
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;
}
示例5: InitSystem
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);
}
示例6: CreateDirs
/* 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;
}
示例7: MakeFileDir
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;
}
示例8: CreatePath
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);
}
示例9: DelDir
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";
}
}
示例10: MakeDir
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);
}
示例11: switch
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;
}
示例12: CreateLogFile
/******************************************************************************
* 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;
}
示例13: return
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
}
示例14: csGetPlatformConfig
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);
}
示例15: RegisterSession
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;
}