本文整理汇总了C++中File_Exists函数的典型用法代码示例。如果您正苦于以下问题:C++ File_Exists函数的具体用法?C++ File_Exists怎么用?C++ File_Exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了File_Exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
}
示例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;
}
}
示例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();
}
示例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]");
}
示例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;
}
示例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);
}
示例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];
}
示例15: GetSavegameCount
static uint16 GetSavegameCount(void)
{
uint16 i;
for (i = 0;; i++) {
if (!File_Exists(GenerateSavegameFilename(i))) return i;
}
}