mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-22 01:07:37 +00:00
(Core) Add filepath_exists to file.c - needed for console ports
This commit is contained in:
parent
8459f39933
commit
2cb946ec8b
18
360/main.c
18
360/main.c
@ -190,21 +190,9 @@ static void set_default_settings (void)
|
||||
g_extern.verbose = true;
|
||||
}
|
||||
|
||||
static bool file_exists(const char * filename)
|
||||
{
|
||||
unsigned long file_attr;
|
||||
|
||||
file_attr = GetFileAttributes(filename);
|
||||
|
||||
if (0xFFFFFFFF == file_attr)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void init_settings (void)
|
||||
{
|
||||
if(!file_exists(SYS_CONFIG_FILE))
|
||||
if(!filepath_exists(SYS_CONFIG_FILE))
|
||||
{
|
||||
SSNES_ERR("Config file \"%s\" desn't exist. Creating...\n", "game:\\ssnes.cfg");
|
||||
FILE * f;
|
||||
@ -230,7 +218,7 @@ static void init_settings (void)
|
||||
|
||||
static void save_settings (void)
|
||||
{
|
||||
if(!file_exists(SYS_CONFIG_FILE))
|
||||
if(!filepath_exists(SYS_CONFIG_FILE))
|
||||
{
|
||||
FILE * f;
|
||||
f = fopen(SYS_CONFIG_FILE, "w");
|
||||
@ -374,7 +362,7 @@ begin_loop:
|
||||
goto begin_loop;
|
||||
|
||||
begin_shutdown:
|
||||
if(file_exists(SYS_CONFIG_FILE))
|
||||
if(filepath_exists(SYS_CONFIG_FILE))
|
||||
save_settings();
|
||||
xdk360_video_deinit();
|
||||
}
|
||||
|
21
file.c
21
file.c
@ -938,6 +938,27 @@ void dir_list_free(char **dir_list)
|
||||
free(orig);
|
||||
}
|
||||
|
||||
#ifdef SSNES_CONSOLE
|
||||
bool filepath_exists(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD file_attr;
|
||||
|
||||
file_attr = GetFileAttributes(path);
|
||||
|
||||
if (0xFFFFFFFF == file_attr)
|
||||
return false;
|
||||
return true;
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
CellFsStat file_attr;
|
||||
if(cellFsStat(path,&file_attr) == CELL_FS_SUCCEEDED)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
bool path_is_directory(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
4
file.h
4
file.h
@ -47,6 +47,10 @@ void dir_list_free(char **dir_list);
|
||||
bool path_is_directory(const char *path);
|
||||
bool path_file_exists(const char *path);
|
||||
|
||||
#ifdef SSNES_CONSOLE
|
||||
bool filepath_exists(const char *path);
|
||||
#endif
|
||||
|
||||
// Path-name operations.
|
||||
// If any of these operation are detected to overflow, the application will be terminated.
|
||||
|
||||
|
15
ps3/main.c
15
ps3/main.c
@ -74,15 +74,6 @@ void set_text_message(const char * message, uint32_t speed)
|
||||
SET_TIMER_EXPIRATION(speed);
|
||||
}
|
||||
|
||||
static bool file_exists(const char * filename)
|
||||
{
|
||||
CellFsStat sb;
|
||||
if(cellFsStat(filename,&sb) == CELL_FS_SUCCEEDED)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static void set_default_settings(void)
|
||||
{
|
||||
// g_settings
|
||||
@ -174,7 +165,7 @@ static void set_default_settings(void)
|
||||
|
||||
static void init_settings(void)
|
||||
{
|
||||
if(!file_exists(SYS_CONFIG_FILE))
|
||||
if(!filepath_exists(SYS_CONFIG_FILE))
|
||||
{
|
||||
SSNES_ERR("Config file \"%s\" doesn't exist. Creating...\n", SYS_CONFIG_FILE);
|
||||
FILE * f;
|
||||
@ -219,7 +210,7 @@ static void init_settings(void)
|
||||
|
||||
static void save_settings(void)
|
||||
{
|
||||
if(!file_exists(SYS_CONFIG_FILE))
|
||||
if(!filepath_exists(SYS_CONFIG_FILE))
|
||||
{
|
||||
FILE * f;
|
||||
f = fopen(SYS_CONFIG_FILE, "w");
|
||||
@ -436,7 +427,7 @@ begin_loop:
|
||||
goto begin_loop;
|
||||
|
||||
begin_shutdown:
|
||||
if(file_exists(SYS_CONFIG_FILE))
|
||||
if(filepath_exists(SYS_CONFIG_FILE))
|
||||
save_settings();
|
||||
ps3_input_deinit();
|
||||
ps3_video_deinit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user