• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ File_Exists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中File_Exists函数的典型用法代码示例。如果您正苦于以下问题:C++ File_Exists函数的具体用法?C++ File_Exists怎么用?C++ File_Exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了File_Exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: VDI_FixDesktopInf

/**
 * Modify (or create) ST desktop configuration files so VDI boots up in
 * correct color depth
 */
static void VDI_FixDesktopInf(void)
{
	char *szDesktopFileName, *szNewDeskFileName;

	if (!GEMDOS_EMU_ON)
	{
		/* Can't modify DESKTOP.INF when not using GEMDOS hard disk emulation */
		return;
	}

	szDesktopFileName = malloc(2 * FILENAME_MAX);
	if (!szDesktopFileName)
	{
		perror("VDI_FixDesktopInf");
		return;
	}
	szNewDeskFileName = szDesktopFileName + FILENAME_MAX;

	/* Create filenames for hard-drive */
	GemDOS_CreateHardDriveFileName(2, "\\DESKTOP.INF", szDesktopFileName, FILENAME_MAX);
	GemDOS_CreateHardDriveFileName(2, "\\NEWDESK.INF", szNewDeskFileName, FILENAME_MAX);

	/* First, check if files exist(ie modify or replace) */
	if (!File_Exists(szDesktopFileName))
		VDI_SaveDesktopInf(szDesktopFileName,DesktopScript,sizeof(DesktopScript));
	VDI_ModifyDesktopInf(szDesktopFileName);

	if (!File_Exists(szNewDeskFileName))
		VDI_SaveDesktopInf(szNewDeskFileName,NewDeskScript,sizeof(NewDeskScript));
	VDI_ModifyDesktopInf(szNewDeskFileName);

	free(szDesktopFileName);
}
开发者ID:jonathanopalise,项目名称:hatari,代码行数:37,代码来源:vdi.c


示例2: VDI_FixDesktopInf

/**
 * Modify (or create) ST desktop configuration files so VDI boots up in
 * correct color depth
 */
static void VDI_FixDesktopInf(void)
{
	char *szDesktopFileName, *szNewDeskFileName;

	/* Modifying DESKTOP.INF only makes sense when we emulate the GEMDOS
	 * hard disk 'C:' (i.e. the HD we boot from) - if not, simply return */
	if (!GemDOS_IsDriveEmulated(2))
	{
		return;
	}

	szDesktopFileName = malloc(2 * FILENAME_MAX);
	if (!szDesktopFileName)
	{
		perror("VDI_FixDesktopInf");
		return;
	}
	szNewDeskFileName = szDesktopFileName + FILENAME_MAX;

	/* Create filenames for hard-drive */
	GemDOS_CreateHardDriveFileName(2, "\\DESKTOP.INF", szDesktopFileName, FILENAME_MAX);
	GemDOS_CreateHardDriveFileName(2, "\\NEWDESK.INF", szNewDeskFileName, FILENAME_MAX);

	/* First, check if files exist(ie modify or replace) */
	if (!File_Exists(szDesktopFileName))
		VDI_SaveDesktopInf(szDesktopFileName,DesktopScript,sizeof(DesktopScript));
	VDI_ModifyDesktopInf(szDesktopFileName);

	if (!File_Exists(szNewDeskFileName))
		VDI_SaveDesktopInf(szNewDeskFileName,NewDeskScript,sizeof(NewDeskScript));
	VDI_ModifyDesktopInf(szNewDeskFileName);

	free(szDesktopFileName);
}
开发者ID:libretro,项目名称:hatari,代码行数:38,代码来源:vdi.c


示例3: Load

bool cPreferences :: Load( const std::string &filename /* = "" */ )
{
	Reset_All();
	
	// if config file is given
	if( filename.length() )
	{
		m_config_filename = filename;
	}

	// prefer local config file
	if( File_Exists( m_config_filename ) )
	{
		printf( "Using local preferences file : %s\n", m_config_filename.c_str() );
	}
	// user dir
	else
	{
		m_config_filename.insert( 0, pResource_Manager->user_data_dir );
		/* fixme : this crashes in CEGUI::DefaultResourceProvider::loadRawDataContainer because of the é
		 * The CEGUI string encoding is UTF-8 but std::string seems to be ISO-8859-1 or Code page 1252
		*/
		//config_filename.insert( 0, "N:/Dokumente und Einstellungen/smc_Invité/Anwendungsdaten/smc/" );

		// does not exist in user dir
		if( !File_Exists( m_config_filename ) )
		{
			// only print warning if file is given
			if( !filename.empty() )
			{
				printf( "Couldn't open preferences file : %s\n", m_config_filename.c_str() );
			}
			return 0;
		}
	}

	try
	{
		//CEGUI::String str = "N:/Dokumente und Einstellungen/smc_Invité/Anwendungsdaten/smc/config.xml";
		CEGUI::System::getSingleton().getXMLParser()->parseXMLFile( *this, m_config_filename, DATA_DIR "/" GAME_SCHEMA_DIR "/Config.xsd", "" );
	}
	// catch CEGUI Exceptions
	catch( CEGUI::Exception &ex )
	{
		printf( "Preferences Loading CEGUI Exception %s\n", ex.getMessage().c_str() );
		pHud_Debug->Set_Text( _("Preferences Loading failed : ") + (const std::string)ex.getMessage().c_str() );
	}

	// if user data dir is set
	if( !m_force_user_data_dir.empty() )
	{
		pResource_Manager->Set_User_Directory( m_force_user_data_dir );
	}

	return 1;
}
开发者ID:as02700,项目名称:Eta-Chronicles,代码行数:56,代码来源:preferences.cpp


示例4: Load

bool cOverworld :: Load( void )
{
	Unload();

	// description
	m_description->Load();

	// world
	std::string world_filename = m_description->Get_Full_Path() + "/world.xml";

	if( !File_Exists( world_filename ) )
	{
		printf( "Couldn't find World file : %s from %s\n", world_filename.c_str(), m_description->m_path.c_str() );
		return 0;
	}

	try
	{
		// parse overworld
	// fixme : Workaround for std::string to CEGUI::String utf8 conversion. Check again if CEGUI 0.8 works with std::string utf8
	#ifdef _WIN32
		CEGUI::System::getSingleton().getXMLParser()->parseXMLFile( *this, (const CEGUI::utf8*)world_filename.c_str(), DATA_DIR "/" GAME_SCHEMA_DIR "/World/World.xsd", "" );
	#else
		CEGUI::System::getSingleton().getXMLParser()->parseXMLFile( *this, world_filename.c_str(), DATA_DIR "/" GAME_SCHEMA_DIR "/World/World.xsd", "" );	
	#endif
	}
	// catch CEGUI Exceptions
	catch( CEGUI::Exception &ex )
	{
		printf( "Loading World %s CEGUI Exception %s\n", world_filename.c_str(), ex.getMessage().c_str() );
		pHud_Debug->Set_Text( _("World Loading failed : ") + (const std::string)ex.getMessage().c_str() );
	}

	// engine version entry not set
	if( m_engine_version < 0 )
	{
		m_engine_version = 0;
	}

	// layer
	std::string layer_filename = m_description->Get_Full_Path() + "/layer.xml";

	if( !File_Exists( layer_filename ) )
	{
		printf( "Couldn't find World Layer file : %s from %s\n", layer_filename.c_str(), m_description->m_path.c_str() );
		return 0;
	}

	m_layer->Load( layer_filename );

	// set name
	m_hud_world_name->Set_Image( pFont->Render_Text( pFont->m_font_normal, m_description->m_name, yellow ), 1, 1 );

	return 1;
}
开发者ID:120pulsations,项目名称:SMC,代码行数:55,代码来源:overworld.cpp


示例5: ReadTileTypeFile

bool CTileset::ReadTileTypeFile(char * szFile)
{
	//Detect if the tiletype file already exists, if not create it
    if(File_Exists(szFile)) {
		FILE * tsf = fopen(szFile, "rb");
        if(tsf == NULL) {
			printf("ERROR: couldn't open tileset file: %s\n", szFile);
			return false;
		}
		
		iTileTypeSize = ReadInt(tsf);

        if(iTileTypeSize <= 0 || iTileTypeSize > 1024) {
			fclose(tsf);
			return false;
		}

		tiletypes = new TileType[iTileTypeSize];

        for(short i = 0; i < iTileTypeSize; i++) {
			tiletypes[i] = (TileType)ReadInt(tsf);
		}

		fclose(tsf);
    } else {
		iTileTypeSize = iWidth * iHeight;
		tiletypes = new TileType[iTileTypeSize];

        for(short i = 0; i < iTileTypeSize; i++) {
			tiletypes[i] = tile_nonsolid;
		}
	}

	return true;
}
开发者ID:BlazingSun,项目名称:super-mario-war,代码行数:35,代码来源:TilesetManager.cpp


示例6: DebugUI_MemorySnapShot_Capture

/**
 * Save/Restore snapshot of debugging session variables
 */
void DebugUI_MemorySnapShot_Capture(const char *path, bool bSave)
{
	char *filename;

	filename = malloc(strlen(path) + strlen(".debug") + 1);
	assert(filename);
	strcpy(filename, path);
	strcat(filename, ".debug");
	
	if (bSave)
	{
		/* save breakpoints as debugger input file */
		BreakCond_Save(filename);
	}
	else
	{
		/* remove current CPU and DSP breakpoints */
		BreakCond_Command("all", false);
		BreakCond_Command("all", true);

		if (File_Exists(filename))
		{
			/* and parse back the saved breakpoints */
			DebugUI_ParseFile(filename, true);
		}
	}
	free(filename);
}
开发者ID:diablodiab,项目名称:hatari,代码行数:31,代码来源:debugui.c


示例7: ReadTileTypeFile

bool CTileset::ReadTileTypeFile(char * szFile)
{
	//Detect if the tiletype file already exists, if not create it
    if (File_Exists(szFile)) {
		BinaryFile tsf(szFile, "rb");
        if (!tsf.is_open()) {
			printf("ERROR: couldn't open tileset file: %s\n", szFile);
			return false;
		}

		iTileTypeSize = tsf.read_i32();

        if (iTileTypeSize <= 0 || iTileTypeSize > 1024) {
			return false;
		}

		tiletypes = new TileType[iTileTypeSize];

        for (short i = 0; i < iTileTypeSize; i++) {
			tiletypes[i] = (TileType)tsf.read_i32();
		}
    } else {
		iTileTypeSize = iWidth * iHeight;
		tiletypes = new TileType[iTileTypeSize];

        for (short i = 0; i < iTileTypeSize; i++) {
			tiletypes[i] = tile_nonsolid;
		}
	}

	return true;
}
开发者ID:carstene1ns,项目名称:supermariowar,代码行数:32,代码来源:TilesetManager.cpp


示例8: Get_Directory_Files

void cOverworld_Manager::Load_Dir(const fs::path& dir, bool user_dir /* = false */)
{
    // set world directory
    vector<fs::path> subdirs = Get_Directory_Files(dir, "", true, false);
    std::sort(subdirs.begin(), subdirs.end());

    for (vector<fs::path>::iterator curdir = subdirs.begin(); curdir != subdirs.end(); ++curdir) {
        try {
            fs::path current_dir = *curdir;

            // only directories with an existing description
            if (File_Exists(current_dir / "description.xml")) {
                cOverworld* overworld = Get_from_Path(current_dir);

                // already available
                if (overworld) {
                    overworld->m_description->m_user = 2; // 2 = available in system *and* in user dir
                    continue;
                }

                overworld = cOverworld::Load_From_Directory(current_dir, user_dir);
                objects.push_back(overworld);
            }
        }
        catch (const std::exception& ex) {
            printf("%s %s\n", path_to_utf8(*curdir).c_str(), ex.what());
        }
    }
}
开发者ID:Clever-Boy,项目名称:TSC,代码行数:29,代码来源:world_manager.cpp


示例9: FillSavegameDesc

static void FillSavegameDesc(bool save)
{
	uint8 i;

	for (i = 0; i < 5; i++) {
		char *desc = g_savegameDesc[i];
		char *filename;
		uint8 fileId;

		*desc = '\0';

		if (s_savegameIndexBase - i < 0) continue;

		if (s_savegameIndexBase - i == s_savegameCountOnDisk) {
			if (!save) continue;

			strncpy(desc, String_Get_ByIndex(STR_EMPTY_SLOT_), 50);
			continue;
		}

		filename = GenerateSavegameFilename(s_savegameIndexBase - i);

		if (!File_Exists(filename)) continue;

		fileId = ChunkFile_Open(filename);
		ChunkFile_Read(fileId, HTOBE32(CC_NAME), desc, 50);
		ChunkFile_Close(fileId);
		continue;
	}
}
开发者ID:Haozerk,项目名称:OpenDUNE,代码行数:30,代码来源:widget_click.c


示例10: Set_Image_Dir

void cFlyon::Set_Image_Dir(fs::path dir)
{
    if (dir.empty()) {
        return;
    }

    // if not image directory
    if (!File_Exists(pResource_Manager->Get_Game_Pixmaps_Directory() / dir / utf8_to_path("closed_1.settings")) && !File_Exists(pResource_Manager->Get_Game_Pixmaps_Directory() / dir / utf8_to_path("closed_1.png"))) {
        std::cerr   << "Warning: Flyon image files not found; does the flyon directory "
                    << path_to_utf8(dir) << " exist?" << std::endl;
        return;
    }

    m_img_dir = dir;

    // clear images
    Clear_Images();
    // set images
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("closed_1.png")));
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("closed_2.png")));
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("open_1.png")));
    Add_Image(pVideo->Get_Surface(m_img_dir / utf8_to_path("open_2.png")));
    // set start image
    Set_Image_Num(0, 1);

    Set_Animation(1);
    Set_Animation_Image_Range(0, 3);
    Set_Time_All(130, 1);
    Reset_Animation();
}
开发者ID:Clever-Boy,项目名称:TSC,代码行数:30,代码来源:flyon.cpp


示例11: Configuration_Load

/**
 * Load program setting from configuration file. If psFileName is NULL, use
 * the configuration file given in configuration / last selected by user.
 */
void Configuration_Load(const char *psFileName)
{
	if (psFileName == NULL)
		psFileName = sConfigFileName;

	if (!File_Exists(psFileName))
	{
		Log_Printf(LOG_DEBUG, "Configuration file %s not found.\n", psFileName);
		return;
	}

	Configuration_LoadSection(psFileName, configs_Log, "[Log]");
    Configuration_LoadSection(psFileName, configs_ConfigDialog, "[ConfigDialog]");
	Configuration_LoadSection(psFileName, configs_Debugger, "[Debugger]");
	Configuration_LoadSection(psFileName, configs_Screen, "[Screen]");
	Configuration_LoadSection(psFileName, configs_Keyboard, "[Keyboard]");
	Configuration_LoadSection(psFileName, configs_ShortCutWithMod, "[ShortcutsWithModifiers]");
	Configuration_LoadSection(psFileName, configs_ShortCutWithoutMod, "[ShortcutsWithoutModifiers]");
    Configuration_LoadSection(psFileName, configs_Mouse, "[Mouse]");
	Configuration_LoadSection(psFileName, configs_Sound, "[Sound]");
	Configuration_LoadSection(psFileName, configs_Memory, "[Memory]");
    Configuration_LoadSection(psFileName, configs_Boot, "[Boot]");
	Configuration_LoadSection(psFileName, configs_SCSI, "[HardDisk]");
    Configuration_LoadSection(psFileName, configs_MO, "[MagnetoOptical]");
    Configuration_LoadSection(psFileName, configs_Floppy, "[Floppy]");
    Configuration_LoadSection(psFileName, configs_Ethernet, "[Ethernet]");
	Configuration_LoadSection(psFileName, configs_Rom, "[ROM]");
	Configuration_LoadSection(psFileName, configs_Printer, "[Printer]");
	Configuration_LoadSection(psFileName, configs_System, "[System]");
    Configuration_LoadSection(psFileName, configs_Dimension, "[Dimension]");
}
开发者ID:itomato,项目名称:Previous,代码行数:35,代码来源:configuration.c


示例12: Opt_StrCpy

/**
 * If 'checkexits' is true, assume 'src' is a file and check whether it
 * exists before copying 'src' to 'dst'. Otherwise just copy option src
 * string to dst.
 * If a pointer to (bool) 'option' is given, set that option to true.
 * - However, if src is "none", leave dst unmodified & set option to false.
 *   ("none" is used to disable options related to file arguments)
 * Return false if there were errors, otherwise true
 */
static bool Opt_StrCpy(int optid, bool checkexist, char *dst, const char *src, size_t dstlen, bool *option)
{
	if (option)
	{
		*option = false;
		if(strcasecmp(src, "none") == 0)
		{
			return true;
		}
	}
	if (strlen(src) >= dstlen)
	{
		return Opt_ShowError(optid, src, "File name too long!");
	}
	if (checkexist && !File_Exists(src))
	{
		return Opt_ShowError(optid, src, "Given file doesn't exist (or has wrong file permissions)!");
	}
	if (option)
	{
		*option = true;
	}
	strcpy(dst, src);
	return true;
}
开发者ID:lordashram,项目名称:hatari-libretro,代码行数:34,代码来源:options.c


示例13: DlgDisk_BrowseDisk

/**
 * Let user browse given disk, insert disk if one selected.
 */
static void DlgDisk_BrowseDisk(char *dlgname, int drive, int diskid)
{
	char *selname, *zip_path;
	const char *tmpname, *realname;

	assert(drive >= 0 && drive < MAX_FLOPPYDRIVES);
	if (szDiskFileName[drive][0])
		tmpname = szDiskFileName[drive];
	else
		tmpname = szDiskImageDirectory;

	selname = SDLGui_FileSelect(tmpname, &zip_path, false);
	if (!selname)
		return;
	printf("in)d%d:(%s)\n",drive,selname);	
	if (File_Exists(selname))
	{printf("----------Exist)\n");	
		realname = Floppy_SetDiskFileName(drive, selname, zip_path);
		if (realname)
			File_ShrinkName(dlgname, realname, floppydlg[diskid].w);
	}
	else
	{printf("---------not found\n");	
		Floppy_SetDiskFileNameNone(drive);
		dlgname[0] = '\0';
	}
	if (zip_path)
		free(zip_path);
	free(selname);
}
开发者ID:r-type,项目名称:uae4arm-libretro,代码行数:33,代码来源:dlgFloppy.c


示例14: Floppy_SetDiskFileName

/**
 * Set given floppy drive image file name and handle
 * different image extensions.
 * Return corrected file name on success and NULL on failure.
 */
const char* Floppy_SetDiskFileName(int Drive, const char *pszFileName, const char *pszZipPath)
{
	char *filename;
	int i;

	/* setting to empty or "none" ejects */
	if (!*pszFileName || strcasecmp(pszFileName, "none") == 0)
	{
		return Floppy_SetDiskFileNameNone(Drive);
	}
	/* See if file exists, and if not, get/add correct extension */
	if (!File_Exists(pszFileName))
		filename = File_FindPossibleExtFileName(pszFileName, pszDiskImageNameExts);
	else
		filename = strdup(pszFileName);
	if (!filename)
	{
		Log_AlertDlg((const char *)LOG_INFO, "Image '%s' not found", pszFileName);
		return NULL;
	}
#if 0
	/* If we insert a disk into Drive A, should we try to put disk 2 into drive B? */
	if (Drive == 0 && ConfigureParams.DiskImage.bAutoInsertDiskB)
	{
		/* Attempt to make up second filename, eg was 'auto_100a' to 'auto_100b' */
		char *szDiskBFileName = Floppy_CreateDiskBFileName(filename);
		if (szDiskBFileName)
		{
			/* recurse with Drive B */
			Floppy_SetDiskFileName(1, szDiskBFileName, pszZipPath);
			free(szDiskBFileName);
		}
	}
#endif

	/* validity checks */
	assert(Drive >= 0 && Drive < MAX_FLOPPYDRIVES);
	for (i = 0; i < MAX_FLOPPYDRIVES; i++)
	{
		if (i == Drive)
			continue;
		/* prevent inserting same image to multiple drives */
		if (strcmp(filename, /*ConfigureParams.DiskImage.*/szDiskFileName[i]) == 0)
		{
			Log_AlertDlg((const char *)LOG_ERROR, "ERROR: Cannot insert same floppy to multiple drives!");
			return NULL;
		}
	}

	/* do the changes */
	if (pszZipPath)
		strcpy(szDiskZipPath[Drive], pszZipPath);
	else
		szDiskZipPath[Drive][0] = '\0';
	strcpy(szDiskFileName[Drive], filename);
	free(filename);
	//File_MakeAbsoluteName(ConfigureParams.DiskImage.szDiskFileName[Drive]);
	return szDiskFileName[Drive];
}
开发者ID:r-type,项目名称:uae4arm-libretro,代码行数:64,代码来源:dlgFloppy.c


示例15: GetSavegameCount

static uint16 GetSavegameCount(void)
{
	uint16 i;

	for (i = 0;; i++) {
		if (!File_Exists(GenerateSavegameFilename(i))) return i;
	}
}
开发者ID:Haozerk,项目名称:OpenDUNE,代码行数:8,代码来源:widget_click.c


示例16: File_Exists_And_Is_A_Socket

bool File_Exists_And_Is_A_Socket(std::string path_to_file){
    if (File_Exists(path_to_file)){
        if (Is_A_Socket(path_to_file)){
            return true;
        }
    }
    return false;
}
开发者ID:UniLang,项目名称:control-structure-printer,代码行数:8,代码来源:observers.cpp


示例17: File_Exists_And_Is_Regular_File

bool File_Exists_And_Is_Regular_File(std::string path_to_file){
    if (File_Exists(path_to_file)){
        if (Is_Regular_File(path_to_file)){
            return true;
        }
    }
    return false;
}
开发者ID:UniLang,项目名称:control-structure-printer,代码行数:8,代码来源:observers.cpp


示例18: File_Exists_And_Is_Directory

bool File_Exists_And_Is_Directory(std::string path_to_file){
    if (File_Exists(path_to_file)){
        if (Is_Directory(path_to_file)){
            return true;
        }
    }
    return false;
}
开发者ID:UniLang,项目名称:control-structure-printer,代码行数:8,代码来源:observers.cpp


示例19: File_Exists_And_Is_Symbolic_Link

bool File_Exists_And_Is_Symbolic_Link(std::string path_to_file){
    if (File_Exists(path_to_file)){
        if (Is_Symbolic_Link(path_to_file)){
            return true;
        }
    }
    return false;
}
开发者ID:UniLang,项目名称:control-structure-printer,代码行数:8,代码来源:observers.cpp


示例20: Create_Path_If_It_Doesnt_Already_Exist

//+--------------+
//| Transformers |
//+--------------+
 void Create_Path_If_It_Doesnt_Already_Exist(std::string const& path){

	if (!File_Exists(path)){
		execute_quietly(("mkdir -p " + path).c_str());
	}

	return;
 }
开发者ID:Jstd,项目名称:Jstd-Bootstrap,代码行数:11,代码来源:paths.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Fill函数代码示例发布时间:2022-05-30
下一篇:
C++ File_Close函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap