mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-01 01:03:11 +00:00
(SSNES_CONSOLE) SSNES Salamander uses file_path.c now
This commit is contained in:
parent
687d5a2b2b
commit
6691ca2c91
@ -18,7 +18,7 @@ COPY = cp
|
||||
MOVE = mv
|
||||
|
||||
PPU_CFLAGS += -I. -D__CELLOS_LV2__
|
||||
PPU_SRCS = console/salamander/main.c compat/compat.c conf/config_file.c
|
||||
PPU_SRCS = console/salamander/main.c file_path.c compat/compat.c conf/config_file.c
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
PPU_CFLAGS += -DHAVE_LOGGER
|
||||
|
@ -25,7 +25,7 @@ CXXFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
|
||||
LDFLAGS := $(MACHDEP)
|
||||
LIBS := -lfat -lretro -lwiiuse -logc -lbte -lfreetype
|
||||
|
||||
OBJ = wii/main.o fifo_buffer.o ssnes.o driver.o gfx/fonts.o file.o settings.o message.o rewind.o movie.o patch.o compat/compat.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o wii/audio.o wii/input.o wii/video.o console/sgui/sgui.o console/sgui/list.o console/font.bmpobj console/console_ext.o console/szlib/szlib.o
|
||||
OBJ = wii/main.o fifo_buffer.o ssnes.o driver.o gfx/fonts.o file.o file_path.o settings.o message.o rewind.o movie.o patch.o compat/compat.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o wii/audio.o wii/input.o wii/video.o console/sgui/sgui.o console/sgui/list.o console/font.bmpobj console/console_ext.o console/szlib/szlib.o
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
CFLAGS += -DHAVE_LOGGER
|
||||
|
@ -18,7 +18,7 @@ PPU_TARGET_ADJUSTED := ssnes-libxenon.elf32
|
||||
LDDIRS = -L. -L$(DEVKITXENON)/usr/lib -L$(DEVKITXENON)/xenon/lib/32
|
||||
INCDIRS = -I. -I$(DEVKITXENON)/usr/include
|
||||
|
||||
OBJ = fifo_buffer.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o gfx/gfx_common.o patch.o compat/compat.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o xenon/main.o xenon/xenon360_audio.o xenon/xenon360_input.o xenon/xenon360_video.o
|
||||
OBJ = fifo_buffer.o ssnes.o driver.o file.o file_path.o settings.o message.o rewind.o movie.o gfx/gfx_common.o patch.o compat/compat.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o xenon/main.o xenon/xenon360_audio.o xenon/xenon360_input.o xenon/xenon360_video.o
|
||||
|
||||
LIBS = -lretro -lxenon -lm -lc
|
||||
DEFINES = -std=gnu99 -DHAVE_CONFIGFILE=1 -DPACKAGE_VERSION=\"0.9.5\" -DSSNES_CONSOLE -DHAVE_GETOPT_LONG=1 -Dmain=ssnes_main
|
||||
|
@ -115,6 +115,7 @@
|
||||
#include "../fileio/file_browser.c"
|
||||
#endif
|
||||
#include "../../file.c"
|
||||
#include "../../file_path.c"
|
||||
|
||||
/*============================================================
|
||||
MESSAGE
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "../../compat/strl.h"
|
||||
#include "../../conf/config_file.h"
|
||||
#include "../../file.h"
|
||||
|
||||
#if defined(_XBOX)
|
||||
#include "../../msvc/msvc_compat.h"
|
||||
@ -81,163 +82,6 @@ char LIBSNES_DIR_PATH[MAX_PATH_LENGTH];
|
||||
char SYS_CONFIG_FILE[MAX_PATH_LENGTH];
|
||||
char libretro_path[MAX_PATH_LENGTH];
|
||||
|
||||
static bool path_file_exists(const char *path)
|
||||
{
|
||||
FILE *dummy = fopen(path, "rb");
|
||||
if (dummy)
|
||||
{
|
||||
fclose(dummy);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void dir_list_free(char **dir_list)
|
||||
{
|
||||
if (!dir_list)
|
||||
return;
|
||||
|
||||
char **orig = dir_list;
|
||||
while (*dir_list)
|
||||
free(*dir_list++);
|
||||
free(orig);
|
||||
}
|
||||
|
||||
#ifdef _XBOX
|
||||
static void fill_pathname_base(char *out_dir, const char *in_path, size_t size)
|
||||
{
|
||||
const char *ptr = strrchr(in_path, '/');
|
||||
if (!ptr)
|
||||
ptr = strrchr(in_path, '\\');
|
||||
|
||||
if (ptr)
|
||||
ptr++;
|
||||
else
|
||||
ptr = in_path;
|
||||
|
||||
strlcpy(out_dir, ptr, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
static char **dir_list_new(const char *dir, const char *ext)
|
||||
{
|
||||
size_t cur_ptr = 0;
|
||||
size_t cur_size = 32;
|
||||
char **dir_list = NULL;
|
||||
|
||||
#if defined(_XBOX)
|
||||
WIN32_FIND_DATA ffd;
|
||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||
|
||||
char path_buf[PATH_MAX];
|
||||
|
||||
if (strlcpy(path_buf, dir, sizeof(path_buf)) >= sizeof(path_buf))
|
||||
goto error;
|
||||
if (strlcat(path_buf, "*", sizeof(path_buf)) >= sizeof(path_buf))
|
||||
goto error;
|
||||
|
||||
if (ext)
|
||||
{
|
||||
if (strlcat(path_buf, ext, sizeof(path_buf)) >= sizeof(path_buf))
|
||||
goto error;
|
||||
}
|
||||
|
||||
hFind = FindFirstFile(path_buf, &ffd);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
goto error;
|
||||
|
||||
dir_list = (char**)calloc(cur_size, sizeof(char*));
|
||||
if (!dir_list)
|
||||
goto error;
|
||||
|
||||
do
|
||||
{
|
||||
// Not a perfect search of course, but hopefully good enough in practice.
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
if (ext && !strstr(ffd.cFileName, ext))
|
||||
continue;
|
||||
|
||||
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
|
||||
if (!dir_list[cur_ptr])
|
||||
goto error;
|
||||
|
||||
strlcpy(dir_list[cur_ptr], dir, PATH_MAX);
|
||||
strlcat(dir_list[cur_ptr], ffd.cFileName, PATH_MAX);
|
||||
|
||||
cur_ptr++;
|
||||
if (cur_ptr + 1 == cur_size) // Need to reserve for NULL.
|
||||
{
|
||||
cur_size *= 2;
|
||||
dir_list = (char**)realloc(dir_list, cur_size * sizeof(char*));
|
||||
if (!dir_list)
|
||||
goto error;
|
||||
|
||||
// Make sure it's all NULL'd out since we cannot rely on realloc to do this.
|
||||
memset(dir_list + cur_ptr, 0, (cur_size - cur_ptr) * sizeof(char*));
|
||||
}
|
||||
}while (FindNextFile(hFind, &ffd) != 0);
|
||||
|
||||
FindClose(hFind);
|
||||
return dir_list;
|
||||
|
||||
error:
|
||||
SSNES_ERR("Failed to open directory: \"%s\"\n", dir);
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
FindClose(hFind);
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
DIR *directory = NULL;
|
||||
const struct dirent *entry = NULL;
|
||||
|
||||
directory = opendir(dir);
|
||||
if (!directory)
|
||||
goto error;
|
||||
|
||||
dir_list = (char**)calloc(cur_size, sizeof(char*));
|
||||
if (!dir_list)
|
||||
goto error;
|
||||
|
||||
while ((entry = readdir(directory)))
|
||||
{
|
||||
// Not a perfect search of course, but hopefully good enough in practice.
|
||||
if (ext && !strstr(entry->d_name, ext))
|
||||
continue;
|
||||
|
||||
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
|
||||
if (!dir_list[cur_ptr])
|
||||
goto error;
|
||||
|
||||
strlcpy(dir_list[cur_ptr], dir, PATH_MAX);
|
||||
strlcat(dir_list[cur_ptr], "/", PATH_MAX);
|
||||
strlcat(dir_list[cur_ptr], entry->d_name, PATH_MAX);
|
||||
|
||||
cur_ptr++;
|
||||
if (cur_ptr + 1 == cur_size) // Need to reserve for NULL.
|
||||
{
|
||||
cur_size *= 2;
|
||||
dir_list = (char**)realloc(dir_list, cur_size * sizeof(char*));
|
||||
if (!dir_list)
|
||||
goto error;
|
||||
|
||||
// Make sure it's all NULL'd out since we cannot rely on realloc to do this.
|
||||
memset(dir_list + cur_ptr, 0, (cur_size - cur_ptr) * sizeof(char*));
|
||||
}
|
||||
}
|
||||
|
||||
closedir(directory);
|
||||
return dir_list;
|
||||
|
||||
error:
|
||||
SSNES_ERR("Failed to open directory: \"%s\"\n", dir);
|
||||
|
||||
if (directory)
|
||||
closedir(directory);
|
||||
#endif
|
||||
|
||||
dir_list_free(dir_list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void find_and_set_first_file(void)
|
||||
{
|
||||
//Last fallback - we'll need to start the first executable file
|
||||
|
Loading…
x
Reference in New Issue
Block a user