mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Merge retro_stat and file_path
This commit is contained in:
parent
7e8aabd080
commit
6af5bd01bf
@ -174,7 +174,6 @@ OBJ += frontend/frontend.o \
|
|||||||
$(LIBRETRO_COMM_DIR)/streams/file_stream.o \
|
$(LIBRETRO_COMM_DIR)/streams/file_stream.o \
|
||||||
$(LIBRETRO_COMM_DIR)/streams/interface_stream.o \
|
$(LIBRETRO_COMM_DIR)/streams/interface_stream.o \
|
||||||
$(LIBRETRO_COMM_DIR)/streams/memory_stream.o \
|
$(LIBRETRO_COMM_DIR)/streams/memory_stream.o \
|
||||||
$(LIBRETRO_COMM_DIR)/file/retro_stat.o \
|
|
||||||
$(LIBRETRO_COMM_DIR)/lists/string_list.o \
|
$(LIBRETRO_COMM_DIR)/lists/string_list.o \
|
||||||
$(LIBRETRO_COMM_DIR)/string/stdstring.o \
|
$(LIBRETRO_COMM_DIR)/string/stdstring.o \
|
||||||
$(LIBRETRO_COMM_DIR)/memmap/memalign.o \
|
$(LIBRETRO_COMM_DIR)/memmap/memalign.o \
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <gfx/scaler/scaler.h>
|
#include <gfx/scaler/scaler.h>
|
||||||
#include <gfx/video_frame.h>
|
#include <gfx/video_frame.h>
|
||||||
#include <retro_stat.h>
|
#include <file/file_path.h>
|
||||||
|
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#include <lists/dir_list.h>
|
#include <lists/dir_list.h>
|
||||||
#include <file/archive_file.h>
|
#include <file/archive_file.h>
|
||||||
|
|
||||||
#include <retro_stat.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
1
dirs.c
1
dirs.c
@ -20,7 +20,6 @@
|
|||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
|
|
||||||
#include "dirs.h"
|
#include "dirs.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <file/config_file.h>
|
#include <file/config_file.h>
|
||||||
#include <queues/task_queue.h>
|
#include <queues/task_queue.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <rhash.h>
|
#include <rhash.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <lists/file_list.h>
|
#include <lists/file_list.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
|
@ -736,7 +736,6 @@ FILE
|
|||||||
#include "../libretro-common/streams/file_stream.c"
|
#include "../libretro-common/streams/file_stream.c"
|
||||||
#include "../libretro-common/streams/interface_stream.c"
|
#include "../libretro-common/streams/interface_stream.c"
|
||||||
#include "../libretro-common/streams/memory_stream.c"
|
#include "../libretro-common/streams/memory_stream.c"
|
||||||
#include "../libretro-common/file/retro_stat.c"
|
|
||||||
#include "../list_special.c"
|
#include "../list_special.c"
|
||||||
#include "../libretro-common/string/stdstring.c"
|
#include "../libretro-common/string/stdstring.c"
|
||||||
#include "../libretro-common/file/nbio/nbio_stdio.c"
|
#include "../libretro-common/file/nbio/nbio_stdio.c"
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#include <file/archive_file.h>
|
#include <file/archive_file.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include <compat/msvc.h>
|
#include <compat/msvc.h>
|
||||||
#include <file/config_file.h>
|
#include <file/config_file.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <rhash.h>
|
#include <rhash.h>
|
||||||
|
@ -20,14 +20,15 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <boolean.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <boolean.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
|
|
||||||
#ifndef __MACH__
|
#ifndef __MACH__
|
||||||
@ -36,10 +37,193 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <compat/strcasestr.h>
|
#include <compat/strcasestr.h>
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define setmode _setmode
|
||||||
|
#endif
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#ifdef _XBOX
|
||||||
|
#include <xtl.h>
|
||||||
|
#define INVALID_FILE_ATTRIBUTES -1
|
||||||
|
#else
|
||||||
|
#include <io.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#elif defined(VITA)
|
||||||
|
#define SCE_ERROR_ERRNO_EEXIST 0x80010011
|
||||||
|
#include <psp2/io/fcntl.h>
|
||||||
|
#include <psp2/io/dirent.h>
|
||||||
|
#include <psp2/io/stat.h>
|
||||||
|
#else
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PSP)
|
||||||
|
#include <pspkernel.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
#include <kernel/image.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__CELLOS_LV2__)
|
||||||
|
#include <cell/cell_fs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(VITA)
|
||||||
|
#define FIO_S_ISDIR SCE_S_ISDIR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP)
|
||||||
|
#include <unistd.h> /* stat() is defined here */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum stat_mode
|
||||||
|
{
|
||||||
|
IS_DIRECTORY = 0,
|
||||||
|
IS_CHARACTER_SPECIAL,
|
||||||
|
IS_VALID
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
||||||
|
{
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
SceIoStat buf;
|
||||||
|
char *tmp = strdup(path);
|
||||||
|
size_t len = strlen(tmp);
|
||||||
|
if (tmp[len-1] == '/')
|
||||||
|
tmp[len-1]='\0';
|
||||||
|
|
||||||
|
if (sceIoGetstat(tmp, &buf) < 0)
|
||||||
|
{
|
||||||
|
free(tmp);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
|
#elif defined(__CELLOS_LV2__)
|
||||||
|
CellFsStat buf;
|
||||||
|
if (cellFsStat(path, &buf) < 0)
|
||||||
|
return false;
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
struct _stat buf;
|
||||||
|
DWORD file_info = GetFileAttributes(path);
|
||||||
|
|
||||||
|
_stat(path, &buf);
|
||||||
|
|
||||||
|
if (file_info == INVALID_FILE_ATTRIBUTES)
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
struct stat buf;
|
||||||
|
if (stat(path, &buf) < 0)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = (int32_t)buf.st_size;
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case IS_DIRECTORY:
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
return FIO_S_ISDIR(buf.st_mode);
|
||||||
|
#elif defined(__CELLOS_LV2__)
|
||||||
|
return ((buf.st_mode & S_IFMT) == S_IFDIR);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
return (file_info & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
#else
|
||||||
|
return S_ISDIR(buf.st_mode);
|
||||||
|
#endif
|
||||||
|
case IS_CHARACTER_SPECIAL:
|
||||||
|
#if defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(_WIN32)
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return S_ISCHR(buf.st_mode);
|
||||||
|
#endif
|
||||||
|
case IS_VALID:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* path_is_directory:
|
||||||
|
* @path : path
|
||||||
|
*
|
||||||
|
* Checks if path is a directory.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if path is a directory, otherwise false (0).
|
||||||
|
*/
|
||||||
|
bool path_is_directory(const char *path)
|
||||||
|
{
|
||||||
|
return path_stat(path, IS_DIRECTORY, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool path_is_character_special(const char *path)
|
||||||
|
{
|
||||||
|
return path_stat(path, IS_CHARACTER_SPECIAL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool path_is_valid(const char *path)
|
||||||
|
{
|
||||||
|
return path_stat(path, IS_VALID, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t path_get_size(const char *path)
|
||||||
|
{
|
||||||
|
int32_t filesize = 0;
|
||||||
|
if (path_stat(path, IS_VALID, &filesize))
|
||||||
|
return filesize;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* path_mkdir_norecurse:
|
||||||
|
* @dir : directory
|
||||||
|
*
|
||||||
|
* Create directory on filesystem.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if directory could be created, otherwise false (0).
|
||||||
|
**/
|
||||||
|
bool mkdir_norecurse(const char *dir)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
int ret = _mkdir(dir);
|
||||||
|
#elif defined(IOS)
|
||||||
|
int ret = mkdir(dir, 0755);
|
||||||
|
#elif defined(VITA) || defined(PSP)
|
||||||
|
int ret = sceIoMkdir(dir, 0777);
|
||||||
|
#elif defined(__QNX__)
|
||||||
|
int ret = mkdir(dir, 0777);
|
||||||
|
#else
|
||||||
|
int ret = mkdir(dir, 0750);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Don't treat this as an error. */
|
||||||
|
#if defined(VITA)
|
||||||
|
if ((ret == SCE_ERROR_ERRNO_EEXIST) && path_is_directory(dir))
|
||||||
|
ret = 0;
|
||||||
|
#elif defined(PSP) || defined(_3DS) || defined(WIIU)
|
||||||
|
if ((ret == -1) && path_is_directory(dir))
|
||||||
|
ret = 0;
|
||||||
|
#else
|
||||||
|
if (ret < 0 && errno == EEXIST && path_is_directory(dir))
|
||||||
|
ret = 0;
|
||||||
|
#endif
|
||||||
|
if (ret < 0)
|
||||||
|
printf("mkdir(%s) error: %s.\n", dir, strerror(errno));
|
||||||
|
return ret == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_mkdir:
|
* path_mkdir:
|
||||||
* @dir : directory
|
* @dir : directory
|
||||||
@ -98,7 +282,7 @@ end:
|
|||||||
*/
|
*/
|
||||||
const char *path_get_archive_delim(const char *path)
|
const char *path_get_archive_delim(const char *path)
|
||||||
{
|
{
|
||||||
const char *last = find_last_slash(path);
|
const char *last = find_last_slash(path);
|
||||||
const char *delim = NULL;
|
const char *delim = NULL;
|
||||||
|
|
||||||
if (last)
|
if (last)
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <retro_common.h>
|
#include <retro_common.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_stat.h>
|
#include <file/file_path.h>
|
||||||
#include <retro_dirent.h>
|
#include <retro_dirent.h>
|
||||||
#include <encodings/utf.h>
|
#include <encodings/utf.h>
|
||||||
|
|
||||||
|
@ -1,214 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2017 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_stat.c).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <retro_miscellaneous.h>
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define setmode _setmode
|
|
||||||
#endif
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#ifdef _XBOX
|
|
||||||
#include <xtl.h>
|
|
||||||
#define INVALID_FILE_ATTRIBUTES -1
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <direct.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
#elif defined(VITA)
|
|
||||||
#define SCE_ERROR_ERRNO_EEXIST 0x80010011
|
|
||||||
#include <psp2/io/fcntl.h>
|
|
||||||
#include <psp2/io/dirent.h>
|
|
||||||
#include <psp2/io/stat.h>
|
|
||||||
#else
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PSP)
|
|
||||||
#include <pspkernel.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
|
||||||
#include <kernel/image.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__)
|
|
||||||
#include <cell/cell_fs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(VITA)
|
|
||||||
#define FIO_S_ISDIR SCE_S_ISDIR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP)
|
|
||||||
#include <unistd.h> /* stat() is defined here */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <retro_miscellaneous.h>
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
enum stat_mode
|
|
||||||
{
|
|
||||||
IS_DIRECTORY = 0,
|
|
||||||
IS_CHARACTER_SPECIAL,
|
|
||||||
IS_VALID
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
|
||||||
{
|
|
||||||
#if defined(VITA) || defined(PSP)
|
|
||||||
SceIoStat buf;
|
|
||||||
char *tmp = strdup(path);
|
|
||||||
size_t len = strlen(tmp);
|
|
||||||
if (tmp[len-1] == '/')
|
|
||||||
tmp[len-1]='\0';
|
|
||||||
|
|
||||||
if (sceIoGetstat(tmp, &buf) < 0)
|
|
||||||
{
|
|
||||||
free(tmp);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
free(tmp);
|
|
||||||
|
|
||||||
#elif defined(__CELLOS_LV2__)
|
|
||||||
CellFsStat buf;
|
|
||||||
if (cellFsStat(path, &buf) < 0)
|
|
||||||
return false;
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
DWORD file_info = GetFileAttributes(path);
|
|
||||||
struct _stat buf;
|
|
||||||
|
|
||||||
_stat(path, &buf);
|
|
||||||
|
|
||||||
if (file_info == INVALID_FILE_ATTRIBUTES)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
struct stat buf;
|
|
||||||
if (stat(path, &buf) < 0)
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (size)
|
|
||||||
*size = (int32_t)buf.st_size;
|
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case IS_DIRECTORY:
|
|
||||||
#if defined(VITA) || defined(PSP)
|
|
||||||
return FIO_S_ISDIR(buf.st_mode);
|
|
||||||
#elif defined(__CELLOS_LV2__)
|
|
||||||
return ((buf.st_mode & S_IFMT) == S_IFDIR);
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
return (file_info & FILE_ATTRIBUTE_DIRECTORY);
|
|
||||||
#else
|
|
||||||
return S_ISDIR(buf.st_mode);
|
|
||||||
#endif
|
|
||||||
case IS_CHARACTER_SPECIAL:
|
|
||||||
#if defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(_WIN32)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return S_ISCHR(buf.st_mode);
|
|
||||||
#endif
|
|
||||||
case IS_VALID:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* path_is_directory:
|
|
||||||
* @path : path
|
|
||||||
*
|
|
||||||
* Checks if path is a directory.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if path is a directory, otherwise false (0).
|
|
||||||
*/
|
|
||||||
bool path_is_directory(const char *path)
|
|
||||||
{
|
|
||||||
return path_stat(path, IS_DIRECTORY, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool path_is_character_special(const char *path)
|
|
||||||
{
|
|
||||||
return path_stat(path, IS_CHARACTER_SPECIAL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool path_is_valid(const char *path)
|
|
||||||
{
|
|
||||||
return path_stat(path, IS_VALID, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t path_get_size(const char *path)
|
|
||||||
{
|
|
||||||
int32_t filesize = 0;
|
|
||||||
if (path_stat(path, IS_VALID, &filesize))
|
|
||||||
return filesize;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* path_mkdir_norecurse:
|
|
||||||
* @dir : directory
|
|
||||||
*
|
|
||||||
* Create directory on filesystem.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if directory could be created, otherwise false (0).
|
|
||||||
**/
|
|
||||||
bool mkdir_norecurse(const char *dir)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
#if defined(_WIN32)
|
|
||||||
ret = _mkdir(dir);
|
|
||||||
#elif defined(IOS)
|
|
||||||
ret = mkdir(dir, 0755);
|
|
||||||
#elif defined(VITA) || defined(PSP)
|
|
||||||
ret = sceIoMkdir(dir, 0777);
|
|
||||||
#elif defined(__QNX__)
|
|
||||||
ret = mkdir(dir, 0777);
|
|
||||||
#else
|
|
||||||
ret = mkdir(dir, 0750);
|
|
||||||
#endif
|
|
||||||
/* Don't treat this as an error. */
|
|
||||||
#if defined(VITA)
|
|
||||||
if ((ret == SCE_ERROR_ERRNO_EEXIST) && path_is_directory(dir))
|
|
||||||
ret = 0;
|
|
||||||
#elif defined(PSP) || defined(_3DS) || defined(WIIU)
|
|
||||||
if ((ret == -1) && path_is_directory(dir))
|
|
||||||
ret = 0;
|
|
||||||
#else
|
|
||||||
if (ret < 0 && errno == EEXIST && path_is_directory(dir))
|
|
||||||
ret = 0;
|
|
||||||
#endif
|
|
||||||
if (ret < 0)
|
|
||||||
printf("mkdir(%s) error: %s.\n", dir, strerror(errno));
|
|
||||||
return ret == 0;
|
|
||||||
}
|
|
@ -457,6 +457,32 @@ void fill_pathname_application_path(char *buf, size_t size);
|
|||||||
**/
|
**/
|
||||||
bool path_mkdir(const char *dir);
|
bool path_mkdir(const char *dir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* path_is_directory:
|
||||||
|
* @path : path
|
||||||
|
*
|
||||||
|
* Checks if path is a directory.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if path is a directory, otherwise false (0).
|
||||||
|
*/
|
||||||
|
bool path_is_directory(const char *path);
|
||||||
|
|
||||||
|
bool path_is_character_special(const char *path);
|
||||||
|
|
||||||
|
bool path_is_valid(const char *path);
|
||||||
|
|
||||||
|
int32_t path_get_size(const char *path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* path_mkdir_norecurse:
|
||||||
|
* @dir : directory
|
||||||
|
*
|
||||||
|
* Create directory on filesystem.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if directory could be created, otherwise false (0).
|
||||||
|
**/
|
||||||
|
bool mkdir_norecurse(const char *dir);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
/* Copyright (C) 2010-2017 The RetroArch team
|
|
||||||
*
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
* The following license statement only applies to this file (retro_stat.h).
|
|
||||||
* ---------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge,
|
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RETRO_STAT_H
|
|
||||||
#define __RETRO_STAT_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* path_is_directory:
|
|
||||||
* @path : path
|
|
||||||
*
|
|
||||||
* Checks if path is a directory.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if path is a directory, otherwise false (0).
|
|
||||||
*/
|
|
||||||
bool path_is_directory(const char *path);
|
|
||||||
|
|
||||||
bool path_is_character_special(const char *path);
|
|
||||||
|
|
||||||
bool path_is_valid(const char *path);
|
|
||||||
|
|
||||||
int32_t path_get_size(const char *path);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* path_mkdir_norecurse:
|
|
||||||
* @dir : directory
|
|
||||||
*
|
|
||||||
* Create directory on filesystem.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if directory could be created, otherwise false (0).
|
|
||||||
**/
|
|
||||||
bool mkdir_norecurse(const char *dir);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
@ -17,7 +17,6 @@
|
|||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
#include <lists/dir_list.h>
|
#include <lists/dir_list.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
|
|
||||||
#include "nk_menu.h"
|
#include "nk_menu.h"
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <formats/image.h>
|
#include <formats/image.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
#include "menu_generic.h"
|
#include "menu_generic.h"
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include <lists/dir_list.h>
|
#include <lists/dir_list.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <file/archive_file.h>
|
#include <file/archive_file.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <features/features_cpu.h>
|
#include <features/features_cpu.h>
|
||||||
|
|
||||||
|
1
paths.c
1
paths.c
@ -19,7 +19,6 @@
|
|||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#include <audio/audio_mixer.h>
|
#include <audio/audio_mixer.h>
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <queues/message_queue.h>
|
#include <queues/message_queue.h>
|
||||||
|
@ -54,7 +54,6 @@
|
|||||||
|
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
|
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <file/archive_file.h>
|
#include <file/archive_file.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
|
|
||||||
#include "tasks_internal.h"
|
#include "tasks_internal.h"
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <net/net_compat.h>
|
#include <net/net_compat.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
|
|
||||||
#include "../verbosity.h"
|
#include "../verbosity.h"
|
||||||
#include "tasks_internal.h"
|
#include "tasks_internal.h"
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <compat/msvc.h>
|
#include <compat/msvc.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
#include <retro_stat.h>
|
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
#include <encodings/crc32.h>
|
#include <encodings/crc32.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user