当前位置: 首页>>代码示例>>C++>>正文


C++ CreateDir函数代码示例

本文整理汇总了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;
}
开发者ID:AtVirus,项目名称:Forgotten-Lands-Source,代码行数:48,代码来源:System.cpp

示例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;
}
开发者ID:dzitkowskik,项目名称:osx-system-data-logger,代码行数:16,代码来源:files_management.c

示例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;
}
开发者ID:sea-kg,项目名称:homemoney,代码行数:16,代码来源:main.cpp

示例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);
}
开发者ID:RemedyGameJam,项目名称:fuji,代码行数:16,代码来源:MFFileSystemNative_WIN32.cpp

示例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);

}
开发者ID:WarfaceKievTechOps,项目名称:crashfix,代码行数:47,代码来源:RequestTests.cpp

示例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();
};
开发者ID:469306621,项目名称:Languages,代码行数:47,代码来源:configmanager.cpp

示例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;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:17,代码来源:NeoCore.cpp

示例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;
}
开发者ID:AnnXGame,项目名称:Minetest,代码行数:17,代码来源:filesys.cpp

示例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;
}
开发者ID:branan,项目名称:Plasma-nobink,代码行数:17,代码来源:plFileUtils.cpp

示例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;
}
开发者ID:Kalamatee,项目名称:WinUAE,代码行数:23,代码来源:fsdb_aros.cpp

示例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;
}
开发者ID:RemedyGameJam,项目名称:fuji,代码行数:45,代码来源:MFFileSystemNative_WIN32.cpp

示例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;
}
开发者ID:Oblomov,项目名称:minetest-delta,代码行数:18,代码来源:filesys.cpp

示例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;
}
开发者ID:guomars,项目名称:project,代码行数:44,代码来源:DataMgr.cpp

示例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);
}
开发者ID:cmangos,项目名称:mangos-classic,代码行数:43,代码来源:System.cpp

示例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;
}
开发者ID:4nakin,项目名称:Aquaria_clean,代码行数:19,代码来源:VFSTools.cpp


注:本文中的CreateDir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。