本文整理汇总了C++中CreateDir函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateDir函数的具体用法?C++ CreateDir怎么用?C++ CreateDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractMapsFromMpq
void ExtractMapsFromMpq(uint32 build)
{
char mpq_filename[1024];
char output_filename[1024];
char mpq_map_name[1024];
printf("Extracting maps...\n");
uint32 map_count = ReadMapDBC();
ReadAreaTableDBC();
ReadLiquidTypeTableDBC();
std::string path = output_path;
path += "/maps/";
CreateDir(path);
printf("Convert map files\n");
for (uint32 z = 0; z < map_count; ++z)
{
printf("Extract %s (%d/%u) \n", map_ids[z].name, z+1, map_count);
// Loadup map grid data
sprintf(mpq_map_name, "World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
WDT_file wdt;
if (!wdt.loadFile(WorldMpq, mpq_map_name, false))
continue;
for (uint32 y = 0; y < WDT_MAP_SIZE; ++y)
{
for (uint32 x = 0; x < WDT_MAP_SIZE; ++x)
{
if (!(wdt.main->adt_list[y][x].flag & 0x1))
continue;
sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
ConvertADT(mpq_filename, output_filename, y, x, build);
}
// draw progress bar
printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
}
}
printf("\n");
delete [] areas;
delete [] map_ids;
}
示例2: CreateDirInPathAndBackToCurrentDir
int CreateDirInPathAndBackToCurrentDir(char* dirName, char* path, char* currentDir)
{
if(-1 == ChangeDirectory(path)) return -1;
if (0 != access(dirName, F_OK))
{
if (ENOENT == errno) { // if file does not exist
if(-1 == CreateDir(dirName)) return -1;
}
if (ENOTDIR == errno) {
fprintf(stderr, "Not a directory!\n");
return -1;
}
}
if(-1 == ChangeDirectory(currentDir)) return -1;
return 0;
}
示例3: ExtractFileDir
bool TForm1::MakeBackup() {
UnicodeString dir = ExtractFileDir(m_strFileName) + "\\backups";
if (!DirectoryExists(dir) && !CreateDir(dir)) {
return false;
}
UnicodeString newfilename = ExtractFileName(m_strFileName);
newfilename.Delete(newfilename.Length() - ExtractFileExt(m_strFileName).Length() + 1, ExtractFileExt(m_strFileName).Length());
newfilename =
dir + L"\\" +
newfilename + " (" + TDateTime::CurrentDateTime().FormatString("yyyy-mm-dd hh_nn") + ")" +
ExtractFileExt(m_strFileName);
Log->Lines->Add("Сохраняю резервную копию файла в " + newfilename);
bool bResult = CopyFile(m_strFileName.c_str(),newfilename.c_str(),false);
return bResult;
}
示例4: CreateDir
static void CreateDir(const char *pPath)
{
if(!pPath || *pPath == 0)
return;
// strip trailing '/'
((char*)pPath)[MFString_Length(pPath)-1] = 0;
// the path is empty
if(*pPath == 0)
return;
CreateDir(MFStr_GetFilePath(pPath));
CreateDirectory(pPath, NULL);
}
示例5: client
void RequestTests::Test_PdbImport()
{
bool bExec = false;
CMtClient client("127.0.0.1", 50);
std::string sErrorMsg;
int nServerRetCode = -1;
std::string sServerResponse;
std::ostringstream stCommand;
std::wstring sPdbName;
std::wstring sSymDir;
std::wstring sOutFile;
int nCreateDir = -1;
sPdbName = Utils::GetTestDataFolder();
sPdbName += L"CrashRpt.pdb";
// Create symbol store dir
sSymDir = Utils::GetTestDataFolder();
sSymDir += L"sym";
RmDir(sSymDir, false);
nCreateDir = CreateDir(sSymDir);
TEST_ASSERT_MSG(nCreateDir==0, "Error creating directory '%s'", strconv::w2a(sSymDir).c_str());
sOutFile = sSymDir;
#ifdef _WIN32
sOutFile += L"\\CrashRpt.pdb.txt";
#else
sOutFile += L"/CrashRpt.pdb.txt";
#endif
// Format command
stCommand << "dumper --import-pdb \"" <<
strconv::w2utf8(sPdbName) << "\" \"" <<
strconv::w2utf8(sSymDir) << "\" \"" <<
strconv::w2utf8(sOutFile) << "\"\n";
// Execute daemon status command - assume success
bExec = client.ExecuteRequest(stCommand.str().c_str(), nServerRetCode, sServerResponse, sErrorMsg);
TEST_ASSERT_MSG(bExec, sErrorMsg.c_str());
TEST_ASSERT_MSG(nServerRetCode==0, "Invalid ret code %d, msg = %s", nServerRetCode, sServerResponse.c_str());
__TEST_CLEANUP__;
// Delete sym directory
RmDir(sSymDir, false);
}
示例6: GetPortableConfigDir
void ConfigManager::InitPaths()
{
#ifdef __WINDOWS__
ConfigManager::config_folder = GetPortableConfigDir();
#else
ConfigManager::config_folder = wxStandardPathsBase::Get().GetUserDataDir();
#endif
ConfigManager::home_folder = wxStandardPathsBase::Get().GetUserConfigDir();
ConfigManager::app_path = ::DetermineExecutablePath();
wxString res_path = ::DetermineResourcesPath();
// if non-empty, the app has overriden it (e.g. "--prefix" was passed in the command line)
if (data_path_global.IsEmpty())
{
if(platform::windows)
ConfigManager::data_path_global = app_path + _T("/share/codeblocks");
else if(platform::macosx)
ConfigManager::data_path_global = res_path + _T("/share/codeblocks");
else
ConfigManager::data_path_global = wxStandardPathsBase::Get().GetDataDir();
}
#ifdef CB_AUTOCONF
if (plugin_path_global.IsEmpty())
{
if(platform::windows || platform::macosx)
ConfigManager::plugin_path_global = data_path_global;
else
{
ConfigManager::plugin_path_global = wxStandardPathsBase::Get().GetPluginsDir() + _T("/plugins");
// first assume, we use standard-paths
if(!wxDirExists(ConfigManager::plugin_path_global) && wxIsPlatform64Bit())
{
// if standard-path does not exist and we are on 64-bit system, use lib64 instead
ConfigManager::plugin_path_global = ((const wxStandardPaths&)wxStandardPaths::Get()).GetInstallPrefix() + _T("/lib64/codeblocks/plugins");
}
}
}
#endif
ConfigManager::data_path_user = ConfigManager::relo ? data_path_global : config_folder + _T("/share/codeblocks");
CreateDirRecursively(ConfigManager::config_folder);
CreateDirRecursively(ConfigManager::data_path_user + _T("/plugins/"));
CreateDir(ConfigManager::data_path_user + _T("/scripts/"));
ConfigManager::temp_folder = wxStandardPathsBase::Get().GetTempDir();
};
示例7: Cfg
QString CNeoCore::GetTempDir(bool bCreate)
{
QString Path = Cfg()->GetString("Content/Temp");
if(Path.isEmpty())
{
if(Cfg()->IsPortable())
Path = Cfg()->GetAppDir();
else
QDir::homePath() + "/Downloads/NeoLoader";
Path += "/Temp/";
}
if(Path.right(1) != "/")
Path.append("/");
if(bCreate)
CreateDir(Path);
return Path;
}
示例8: CreateAllDirs
bool CreateAllDirs(std::string path)
{
std::vector<std::string> tocreate;
std::string basepath = path;
while(!PathExists(basepath))
{
tocreate.push_back(basepath);
basepath = RemoveLastPathComponent(basepath);
if(basepath.empty())
break;
}
for(int i=tocreate.size()-1;i>=0;i--)
if(!CreateDir(tocreate[i]))
return false;
return true;
}
示例9: izer
bool plFileUtils::EnsureFilePathExists( const wchar_t *filename )
{
hsWStringTokenizer izer( filename, L"\\/" );
bool lastWorked = false;
wchar_t token[ kFolderIterator_MaxPath ];
while( izer.Next( token, arrsize( token ) ) && izer.HasMoreTokens() )
{
// Want the full path from the start of the string
lastWorked = CreateDir( izer.fString );
izer.RestoreLastTerminator();
}
return lastWorked;
}
示例10: my_mkdir
/******************************************************************
* my_mkdir / my_rmdir
*
* Create/Delete directories. Return AROS host error codes for
* AmigaOS guest CreateDir/DeleteFile calls.
******************************************************************/
int my_mkdir (const TCHAR *name) {
BPTR lock;
DebOut("name: %s\n", name);
lock=CreateDir(name);
if(lock) {
UnLock(lock); /* CreateDir returns a lock, which we don't need */
return 0;
}
SetLastError(IoErr());
DebOut("return -1 (%d)\n", IoErr());
return -1;
}
示例11: MFFileNative_Open
int MFFileNative_Open(MFFile *pFile, MFOpenData *pOpenData)
{
MFCALLSTACK;
MFDebug_Assert(pOpenData->cbSize == sizeof(MFOpenDataNative), "Incorrect size for MFOpenDataNative structure. Invalid pOpenData.");
MFOpenDataNative *pNative = (MFOpenDataNative*)pOpenData;
DWORD access = ((pOpenData->openFlags&MFOF_Read) ? GENERIC_READ : NULL) | ((pOpenData->openFlags&MFOF_Write) ? GENERIC_WRITE : NULL);
MFDebug_Assert(access, "Neither MFOF_Read nor MFOF_Write specified.");
const char *pFilename = pNative->pFilename;
#if defined(MF_XBOX) || defined(MF_X360)
pFilename = FixXBoxFilename(pFilename);
#endif
if(pOpenData->openFlags & MFOF_CreateDirectory)
CreateDir(MFStr_GetFilePath(pFilename));
DWORD create = (pOpenData->openFlags & MFOF_Read) ? ((pOpenData->openFlags & MFOF_Write) ? OPEN_ALWAYS : OPEN_EXISTING) : CREATE_ALWAYS;
pFile->pFilesysData = CreateFile(pFilename, access, FILE_SHARE_READ, NULL, create, NULL, NULL);
if(pFile->pFilesysData == INVALID_HANDLE_VALUE)
{
// MFDebug_Warn(3, MFStr("Failed to open file '%s'.", pNative->pFilename));
pFile->pFilesysData = 0;
return -1;
}
pFile->createFlags = pOpenData->openFlags;
pFile->offset = 0;
DWORD excess;
uint32 fileSize = GetFileSize(pFile->pFilesysData, &excess);
MFDebug_Assert(excess == 0, "Fuji does not support files larger than 4,294,967,295 bytes.");
pFile->length = fileSize;
#if defined(_DEBUG)
MFString_Copy(pFile->fileIdentifier, pNative->pFilename);
#endif
return 0;
}
示例12: CreateAllDirs
bool CreateAllDirs(std::string path)
{
size_t pos;
std::vector<std::string> tocreate;
std::string basepath = path;
while(!PathExists(basepath))
{
tocreate.push_back(basepath);
pos = basepath.rfind('/');
if(pos == std::string::npos)
return false;
basepath = basepath.substr(0,pos);
}
for(int i=tocreate.size()-1;i>=0;i--)
CreateDir(tocreate[i]);
return true;
}
示例13: fopen
bool DataMgr::SaveToFile(const char *fileName)
{
const char * _file = NULL;
if (fileName)
{
_file = fileName;
m_save_file = fileName;
}
else
_file = m_save_file.c_str();
FILE*file = fopen(_file,"wb");
if (!file){
CreateDir(_file);
file = fopen(_file, "wb");
if (!file){
CCLog("SaveStr(%s) Failed", _file);
return false;
}
}
StringMap::iterator it = m_StringMap.begin(),itEnd = m_StringMap.end();
std::string temp;
for(;it != itEnd;++it)
{
size_t len = it->first.size();
size_t size = strlen(SAVE_TAG);
size_t pos = it->first.find(SAVE_TAG);
if (len >= size && pos == len-size)
{
temp = it->first;
temp += "=";
temp += it->second;
temp += "\n";
std::string decryptedstr = GetDecryptedStr(temp.c_str(),temp.size());
fwrite(decryptedstr.c_str(),1,(int)decryptedstr.size(),file);
}
}
fclose(file);
return true;
}
示例14: ExtractCameraFiles
void ExtractCameraFiles()
{
printf("Extracting camera files...\n");
DBCFile camdbc("DBFilesClient\\CinematicCamera.dbc");
if (!camdbc.open())
{
printf("Unable to open CinematicCamera.dbc. Camera extract aborted.\n");
return;
}
// get camera file list from DBC
std::vector<std::string> camerafiles;
size_t cam_count = camdbc.getRecordCount();
for (uint32 i = 0; i < cam_count; ++i)
{
std::string camFile(camdbc.getRecord(i).getString(1));
size_t loc = camFile.find(".mdx");
if (loc != std::string::npos)
camFile.replace(loc, 4, ".m2");
camerafiles.push_back(std::string(camFile));
}
std::string path = output_path;
path += "/Cameras/";
CreateDir(path);
// extract M2s
uint32 count = 0;
for (std::string thisFile : camerafiles)
{
std::string filename = path;
filename += (thisFile.c_str() + strlen("Cameras\\"));
if (FileExists(filename.c_str()))
continue;
if (ExtractFile(thisFile.c_str(), filename))
++count;
}
printf("Extracted %u camera files\n", count);
}
示例15: CreateDirRec
bool CreateDirRec(const char *dir)
{
if(IsDirectory(dir))
return true;
bool result = true;
StringList li;
StrSplit(dir, "/\\", li, false);
std::string d;
d.reserve(strlen(dir));
bool last;
for(StringList::iterator it = li.begin(); it != li.end(); ++it)
{
d += *it;
last = CreateDir(d.c_str());
result = last && result;
d += '/';
}
return result || last;
}