mirror of
https://github.com/libretro/libretro-common.git
synced 2024-11-23 08:09:43 +00:00
Update
This commit is contained in:
parent
69c83f835a
commit
2aab9683c5
@ -25,14 +25,20 @@
|
||||
#include <dynamic/dylib.h>
|
||||
#include <encodings/utf.h>
|
||||
|
||||
#if defined(ORBIS)
|
||||
#include <orbis/libkernel.h>
|
||||
#endif
|
||||
|
||||
#ifdef NEED_DYNAMIC
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <compat/posix_string.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#if !defined(ORBIS)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Assume W-functions do not work below Win2K and Xbox platforms */
|
||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX)
|
||||
@ -118,6 +124,9 @@ dylib_t dylib_load(const char *path)
|
||||
return NULL;
|
||||
}
|
||||
last_dyn_error[0] = 0;
|
||||
#elif defined(ORBIS)
|
||||
int res;
|
||||
dylib_t lib = (dylib_t)sceKernelLoadStartModule(path, 0, NULL, 0, NULL, &res);
|
||||
#else
|
||||
dylib_t lib = dlopen(path, RTLD_LAZY | RTLD_LOCAL);
|
||||
#endif
|
||||
@ -161,6 +170,14 @@ function_t dylib_proc(dylib_t lib, const char *proc)
|
||||
return NULL;
|
||||
}
|
||||
last_dyn_error[0] = 0;
|
||||
#elif defined(ORBIS)
|
||||
void *ptr_sym = NULL;
|
||||
sym = NULL;
|
||||
|
||||
if (lib) {
|
||||
sceKernelDlsym((SceKernelModule)lib, proc, &ptr_sym);
|
||||
memcpy(&sym, &ptr_sym, sizeof(void*));
|
||||
}
|
||||
#else
|
||||
void *ptr_sym = NULL;
|
||||
|
||||
@ -196,6 +213,9 @@ void dylib_close(dylib_t lib)
|
||||
if (!FreeLibrary((HMODULE)lib))
|
||||
set_dl_error();
|
||||
last_dyn_error[0] = 0;
|
||||
#elif defined(ORBIS)
|
||||
int res;
|
||||
sceKernelStopUnloadModule((SceKernelModule)lib, 0, NULL, 0, NULL, &res);
|
||||
#else
|
||||
#ifndef NO_DLCLOSE
|
||||
dlclose(lib);
|
||||
|
@ -75,6 +75,10 @@
|
||||
#include <psp2/rtc.h>
|
||||
#endif
|
||||
|
||||
#if defined(ORBIS)
|
||||
#include <orbis/libkernel.h>
|
||||
#endif
|
||||
|
||||
#if defined(PS2)
|
||||
#include <ps2sdkapi.h>
|
||||
#endif
|
||||
@ -195,6 +199,8 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
|
||||
__asm__ volatile( "mrs %0, cntvct_el0" : "=r"(time_ticks) );
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
time_ticks = sceKernelGetSystemTimeWide();
|
||||
#elif defined(ORBIS)
|
||||
sceRtcGetCurrentTick((SceRtcTick*)&time_ticks);
|
||||
#elif defined(PS2)
|
||||
time_ticks = ps2_clock();
|
||||
#elif defined(_3DS)
|
||||
@ -255,6 +261,8 @@ retro_time_t cpu_features_get_time_usec(void)
|
||||
return sceKernelGetSystemTimeWide();
|
||||
#elif defined(DJGPP)
|
||||
return uclock() * 1000000LL / UCLOCKS_PER_SEC;
|
||||
#elif defined(ORBIS)
|
||||
return sceKernelGetProcessTime();
|
||||
#else
|
||||
#error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue."
|
||||
#endif
|
||||
|
@ -26,10 +26,6 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef ORBIS
|
||||
#include <sys/fcntl.h>
|
||||
#include <orbisFile.h>
|
||||
#endif
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <compat/strl.h>
|
||||
#include <compat/posix_string.h>
|
||||
@ -1338,13 +1334,6 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort)
|
||||
|
||||
if (!string_is_empty(path))
|
||||
{
|
||||
#ifdef ORBIS
|
||||
int fd = orbisOpen(path,O_RDWR|O_CREAT,0644);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
config_file_dump_orbis(conf,fd);
|
||||
orbisClose(fd);
|
||||
#else
|
||||
void* buf = NULL;
|
||||
FILE *file = (FILE*)fopen_utf8(path, "wb");
|
||||
if (!file)
|
||||
@ -1359,7 +1348,6 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort)
|
||||
fclose(file);
|
||||
if (buf)
|
||||
free(buf);
|
||||
#endif
|
||||
|
||||
/* Only update modified flag if config file
|
||||
* is actually written to disk */
|
||||
@ -1371,53 +1359,6 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ORBIS
|
||||
void config_file_dump_orbis(config_file_t *conf, int fd)
|
||||
{
|
||||
struct config_entry_list *list = NULL;
|
||||
struct config_include_list *includes = conf->includes;
|
||||
|
||||
if (conf->reference)
|
||||
{
|
||||
pathname_make_slashes_portable(conf->reference);
|
||||
fprintf(file, "#reference \"%s\"\n", conf->reference);
|
||||
}
|
||||
|
||||
|
||||
list = config_file_merge_sort_linked_list(
|
||||
(struct config_entry_list*)conf->entries,
|
||||
config_file_sort_compare_func);
|
||||
conf->entries = list;
|
||||
|
||||
while (list)
|
||||
{
|
||||
if (!list->readonly && list->key)
|
||||
{
|
||||
char newlist[256];
|
||||
snprintf(newlist, sizeof(newlist),
|
||||
"%s = %s\n", list->key, list->value);
|
||||
orbisWrite(fd, newlist, strlen(newlist));
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
/* Config files are read from the top down - if
|
||||
* duplicate entries are found then the topmost
|
||||
* one in the list takes precedence. This means
|
||||
* '#include' directives must go *after* individual
|
||||
* config entries, otherwise they will override
|
||||
* any custom-set values */
|
||||
while (includes)
|
||||
{
|
||||
char cad[256];
|
||||
snprintf(cad, sizeof(cad),
|
||||
"#include %s\n", includes->path);
|
||||
orbisWrite(fd, cad, strlen(cad));
|
||||
includes = includes->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void config_file_dump(config_file_t *conf, FILE *file, bool sort)
|
||||
{
|
||||
struct config_entry_list *list = NULL;
|
||||
|
@ -32,9 +32,6 @@
|
||||
extern nbio_intf_t nbio_linux;
|
||||
extern nbio_intf_t nbio_mmap_unix;
|
||||
extern nbio_intf_t nbio_mmap_win32;
|
||||
#if defined(ORBIS)
|
||||
extern nbio_intf_t nbio_orbis;
|
||||
#endif
|
||||
extern nbio_intf_t nbio_stdio;
|
||||
|
||||
#ifndef _XBOX
|
||||
@ -61,8 +58,6 @@ static nbio_intf_t *internal_nbio = &nbio_linux;
|
||||
static nbio_intf_t *internal_nbio = &nbio_mmap_unix;
|
||||
#elif defined(HAVE_MMAP_WIN32)
|
||||
static nbio_intf_t *internal_nbio = &nbio_mmap_win32;
|
||||
#elif defined(ORBIS)
|
||||
static nbio_intf_t *internal_nbio = &nbio_orbis;
|
||||
#else
|
||||
static nbio_intf_t *internal_nbio = &nbio_stdio;
|
||||
#endif
|
||||
|
@ -214,10 +214,6 @@ bool config_file_write(config_file_t *conf, const char *path, bool val);
|
||||
* Does not close the file. */
|
||||
void config_file_dump(config_file_t *conf, FILE *file, bool val);
|
||||
|
||||
#ifdef ORBIS
|
||||
void config_file_dump_orbis(config_file_t *conf, int fd);
|
||||
#endif
|
||||
|
||||
bool config_file_exists(const char *path);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
@ -56,6 +56,8 @@
|
||||
|
||||
#include <network.h>
|
||||
|
||||
#define setsockopt net_setsockopt
|
||||
|
||||
#elif defined(VITA)
|
||||
|
||||
#include <psp2/net/net.h>
|
||||
|
@ -75,7 +75,7 @@ static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count)
|
||||
}
|
||||
|
||||
#ifndef PATH_MAX_LENGTH
|
||||
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU) || defined(ORBIS) || defined(__PSL1GHT__) || defined(__PS3__)
|
||||
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU) || defined(__PSL1GHT__) || defined(__PS3__)
|
||||
#define PATH_MAX_LENGTH 512
|
||||
#else
|
||||
#define PATH_MAX_LENGTH 4096
|
||||
|
@ -422,7 +422,7 @@ void network_deinit(void)
|
||||
|
||||
uint16_t inet_htons(uint16_t hostshort)
|
||||
{
|
||||
#if defined(VITA) || defined(__ORBIS__)
|
||||
#if defined(VITA)
|
||||
return sceNetHtons(hostshort);
|
||||
#else
|
||||
return htons(hostshort);
|
||||
@ -432,7 +432,7 @@ uint16_t inet_htons(uint16_t hostshort)
|
||||
|
||||
int inet_ptrton(int af, const char *src, void *dst)
|
||||
{
|
||||
#if defined(VITA) || defined(__ORBIS__)
|
||||
#if defined(VITA)
|
||||
return sceNetInetPton(af, src, dst);
|
||||
#elif defined(GEKKO) || defined(_WIN32)
|
||||
/* TODO/FIXME - should use InetPton on Vista and later */
|
||||
@ -597,7 +597,7 @@ static const char *isockaddr_ntop(int af,
|
||||
|
||||
const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt)
|
||||
{
|
||||
#if defined(VITA) || defined(__ORBIS__)
|
||||
#if defined(VITA)
|
||||
return sceNetInetNtop(af,src,dst,cnt);
|
||||
#elif defined(WIIU)
|
||||
return inet_ntop(af, src, dst, cnt);
|
||||
|
@ -184,9 +184,9 @@ START_TEST (test_word_wrap)
|
||||
"adipiscing elit. Nam nec enim quis orci\n"
|
||||
"euismod efficitur at nec arcu. Vivamus\n"
|
||||
"imperdiet est feugiat massa rhoncus\n"
|
||||
"porttitor at vitae ante. Nunc a orci vel\n"
|
||||
"ipsum tempor posuere sed a lacus. Ut\n"
|
||||
"erat odio, ultrices vitae iaculis\n"
|
||||
"porttitor at vitae ante. Nunc a orci\n"
|
||||
"vel ipsum tempor posuere sed a lacus.\n"
|
||||
"Ut erat odio, ultrices vitae iaculis\n"
|
||||
"fringilla, iaculis ut eros.\n"
|
||||
"Sed facilisis viverra lectus et\n"
|
||||
"ullamcorper. "
|
||||
|
@ -57,11 +57,6 @@
|
||||
# include <dirent.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
# if defined(ORBIS)
|
||||
# include <sys/fcntl.h>
|
||||
# include <sys/dirent.h>
|
||||
# include <orbisFile.h>
|
||||
# endif
|
||||
# if defined(WIIU)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
@ -74,11 +69,6 @@
|
||||
# include <psp2/io/fcntl.h>
|
||||
# include <psp2/io/dirent.h>
|
||||
# include <psp2/io/stat.h>
|
||||
#elif defined(ORBIS)
|
||||
# include <orbisFile.h>
|
||||
# include <ps4link.h>
|
||||
# include <sys/dirent.h>
|
||||
# include <sys/fcntl.h>
|
||||
#elif !defined(_WIN32)
|
||||
# if defined(PSP)
|
||||
# include <pspiofilemgr.h>
|
||||
@ -124,11 +114,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(ORBIS)
|
||||
#include <orbisFile.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/dirent.h>
|
||||
#endif
|
||||
|
||||
#if defined(PSP)
|
||||
#include <pspkernel.h>
|
||||
#endif
|
||||
@ -200,13 +186,6 @@ int64_t retro_vfs_file_seek_internal(
|
||||
#ifdef ATLEAST_VC2005
|
||||
/* VC2005 and up have a special 64-bit fseek */
|
||||
return _fseeki64(stream->fp, offset, whence);
|
||||
#elif defined(ORBIS)
|
||||
{
|
||||
int ret = orbisLseek(stream->fd, offset, whence);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#elif defined(HAVE_64BIT_OFFSETS)
|
||||
return fseeko(stream->fp, (off_t)offset, whence);
|
||||
#else
|
||||
@ -359,24 +338,20 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||
mode_str = "wb";
|
||||
|
||||
flags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||
#if !defined(ORBIS)
|
||||
#if !defined(_WIN32)
|
||||
flags |= S_IRUSR | S_IWUSR;
|
||||
#else
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
case RETRO_VFS_FILE_ACCESS_READ_WRITE:
|
||||
mode_str = "w+b";
|
||||
flags = O_RDWR | O_CREAT | O_TRUNC;
|
||||
#if !defined(ORBIS)
|
||||
#if !defined(_WIN32)
|
||||
flags |= S_IRUSR | S_IWUSR;
|
||||
#else
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
@ -385,12 +360,10 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||
mode_str = "r+b";
|
||||
|
||||
flags = O_RDWR;
|
||||
#if !defined(ORBIS)
|
||||
#if !defined(_WIN32)
|
||||
flags |= S_IRUSR | S_IWUSR;
|
||||
#else
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
@ -400,15 +373,6 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
int fd = orbisOpen(path, flags, 0644);
|
||||
if (fd < 0)
|
||||
{
|
||||
stream->fd = -1;
|
||||
goto error;
|
||||
}
|
||||
stream->fd = fd;
|
||||
#else
|
||||
FILE *fp;
|
||||
#ifdef HAVE_CDROM
|
||||
if (stream->scheme == VFS_SCHEME_CDROM)
|
||||
@ -466,7 +430,6 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||
if (stream->fp)
|
||||
setvbuf(stream->fp, stream->buf, _IOFBF, 0x4000);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -510,10 +473,6 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef ORBIS
|
||||
stream->size = orbisLseek(stream->fd, 0, SEEK_END);
|
||||
orbisLseek(stream->fd, 0, SEEK_SET);
|
||||
#else
|
||||
#ifdef HAVE_CDROM
|
||||
if (stream->scheme == VFS_SCHEME_CDROM)
|
||||
{
|
||||
@ -534,7 +493,6 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
||||
|
||||
retro_vfs_file_seek_internal(stream, 0, SEEK_SET);
|
||||
}
|
||||
#endif
|
||||
return stream;
|
||||
|
||||
error:
|
||||
@ -570,12 +528,7 @@ int retro_vfs_file_close_impl(libretro_vfs_implementation_file *stream)
|
||||
|
||||
if (stream->fd > 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
orbisClose(stream->fd);
|
||||
stream->fd = -1;
|
||||
#else
|
||||
close(stream->fd);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_CDROM
|
||||
end:
|
||||
@ -599,12 +552,7 @@ int retro_vfs_file_error_impl(libretro_vfs_implementation_file *stream)
|
||||
if (stream->scheme == VFS_SCHEME_CDROM)
|
||||
return retro_vfs_file_error_cdrom(stream);
|
||||
#endif
|
||||
#ifdef ORBIS
|
||||
/* TODO/FIXME - implement this? */
|
||||
return 0;
|
||||
#else
|
||||
return ferror(stream->fp);
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t retro_vfs_file_size_impl(libretro_vfs_implementation_file *stream)
|
||||
@ -641,14 +589,6 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
|
||||
if (stream->scheme == VFS_SCHEME_CDROM)
|
||||
return retro_vfs_file_tell_cdrom(stream);
|
||||
#endif
|
||||
#ifdef ORBIS
|
||||
{
|
||||
int64_t ret = orbisLseek(stream->fd, 0, SEEK_CUR);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#ifdef ATLEAST_VC2005
|
||||
/* VC2005 and up have a special 64-bit ftell */
|
||||
return _ftelli64(stream->fp);
|
||||
@ -656,7 +596,6 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
|
||||
return ftello(stream->fp);
|
||||
#else
|
||||
return ftell(stream->fp);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
@ -704,13 +643,7 @@ int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream,
|
||||
if (stream->scheme == VFS_SCHEME_CDROM)
|
||||
return retro_vfs_file_read_cdrom(stream, s, len);
|
||||
#endif
|
||||
#ifdef ORBIS
|
||||
if (orbisRead(stream->fd, s, (size_t)len) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
#else
|
||||
return fread(s, 1, (size_t)len, stream->fp);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS)
|
||||
@ -738,13 +671,7 @@ int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, cons
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
if (orbisWrite(stream->fd, s, (size_t)len) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
#else
|
||||
return fwrite(s, 1, (size_t)len, stream->fp);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
@ -758,11 +685,7 @@ int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream)
|
||||
{
|
||||
if (!stream)
|
||||
return -1;
|
||||
#ifdef ORBIS
|
||||
return 0;
|
||||
#else
|
||||
return fflush(stream->fp) == 0 ? 0 : -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int retro_vfs_file_remove_impl(const char *path)
|
||||
@ -801,10 +724,6 @@ int retro_vfs_file_remove_impl(const char *path)
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
#elif defined(ORBIS)
|
||||
/* Orbis
|
||||
* TODO/FIXME - stub for now */
|
||||
return 0;
|
||||
#else
|
||||
if (remove(path) == 0)
|
||||
return 0;
|
||||
@ -861,13 +780,6 @@ int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
#elif defined(ORBIS)
|
||||
/* Orbis */
|
||||
/* TODO/FIXME - Stub for now */
|
||||
if (!old_path || !*old_path || !new_path || !*new_path)
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
#else
|
||||
/* Every other platform */
|
||||
if (!old_path || !*old_path || !new_path || !*new_path)
|
||||
@ -913,21 +825,6 @@ int retro_vfs_stat_impl(const char *path, int32_t *size)
|
||||
*size = (int32_t)buf.st_size;
|
||||
|
||||
is_dir = FIO_S_ISDIR(buf.st_mode);
|
||||
#elif defined(ORBIS)
|
||||
/* Orbis */
|
||||
int dir_ret = 0;
|
||||
|
||||
if (!path || !*path)
|
||||
return 0;
|
||||
|
||||
if (size)
|
||||
*size = (int32_t)buf.st_size;
|
||||
|
||||
dir_ret = orbisDopen(path);
|
||||
is_dir = dir_ret > 0;
|
||||
orbisDclose(dir_ret);
|
||||
|
||||
is_character_special = S_ISCHR(buf.st_mode);
|
||||
#elif defined(__PSL1GHT__) || defined(__PS3__)
|
||||
/* Lowlevel Lv2 */
|
||||
sysFSStat buf;
|
||||
@ -1034,7 +931,7 @@ int retro_vfs_stat_impl(const char *path, int32_t *size)
|
||||
|
||||
#if defined(VITA)
|
||||
#define path_mkdir_error(ret) (((ret) == SCE_ERROR_ERRNO_EEXIST))
|
||||
#elif defined(PSP) || defined(PS2) || defined(_3DS) || defined(WIIU) || defined(SWITCH) || defined(ORBIS)
|
||||
#elif defined(PSP) || defined(PS2) || defined(_3DS) || defined(WIIU) || defined(SWITCH)
|
||||
#define path_mkdir_error(ret) ((ret) == -1)
|
||||
#else
|
||||
#define path_mkdir_error(ret) ((ret) < 0 && errno == EEXIST)
|
||||
@ -1059,8 +956,6 @@ int retro_vfs_mkdir_impl(const char *dir)
|
||||
int ret = mkdir(dir, 0755);
|
||||
#elif defined(VITA)
|
||||
int ret = sceIoMkdir(dir, 0777);
|
||||
#elif defined(ORBIS)
|
||||
int ret = orbisMkdir(dir, 0755);
|
||||
#elif defined(__QNX__)
|
||||
int ret = mkdir(dir, 0777);
|
||||
#elif defined(GEKKO)
|
||||
@ -1117,9 +1012,6 @@ struct libretro_vfs_implementation_dir
|
||||
int error;
|
||||
int directory;
|
||||
sysFSDirent entry;
|
||||
#elif defined(ORBIS)
|
||||
int directory;
|
||||
struct dirent entry;
|
||||
#else
|
||||
DIR *directory;
|
||||
const struct dirent *entry;
|
||||
@ -1199,8 +1091,6 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl(
|
||||
rdir->entry = NULL;
|
||||
#elif defined(__PSL1GHT__) || defined(__PS3__)
|
||||
rdir->error = sysFsOpendir(name, &rdir->directory);
|
||||
#elif defined(ORBIS)
|
||||
rdir->directory = orbisDopen(name);
|
||||
#else
|
||||
rdir->directory = opendir(name);
|
||||
rdir->entry = NULL;
|
||||
@ -1238,8 +1128,6 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir)
|
||||
uint64_t nread;
|
||||
rdir->error = sysFsReaddir(rdir->directory, &rdir->entry, &nread);
|
||||
return (nread != 0);
|
||||
#elif defined(ORBIS)
|
||||
return (orbisDread(rdir->directory, &rdir->entry) > 0);
|
||||
#else
|
||||
return ((rdir->entry = readdir(rdir->directory)) != NULL);
|
||||
#endif
|
||||
@ -1258,7 +1146,7 @@ const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir
|
||||
if (name)
|
||||
free(name);
|
||||
return (char*)rdir->entry.cFileName;
|
||||
#elif defined(VITA) || defined(ORBIS) || defined(__PSL1GHT__) || defined(__PS3__)
|
||||
#elif defined(VITA) || defined(__PSL1GHT__) || defined(__PS3__)
|
||||
return rdir->entry.d_name;
|
||||
#else
|
||||
if (!rdir || !rdir->entry)
|
||||
@ -1278,12 +1166,6 @@ bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *rdir)
|
||||
#elif defined(__PSL1GHT__) || defined(__PS3__)
|
||||
sysFSDirent *entry = (sysFSDirent*)&rdir->entry;
|
||||
return (entry->d_type == FS_TYPE_DIR);
|
||||
#elif defined(ORBIS)
|
||||
const struct dirent *entry = &rdir->entry;
|
||||
if (entry->d_type == DT_DIR)
|
||||
return true;
|
||||
if (!(entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK))
|
||||
return false;
|
||||
#else
|
||||
struct stat buf;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
@ -1316,8 +1198,6 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir)
|
||||
sceIoDclose(rdir->directory);
|
||||
#elif defined(__PSL1GHT__) || defined(__PS3__)
|
||||
rdir->error = sysFsClosedir(rdir->directory);
|
||||
#elif defined(ORBIS)
|
||||
orbisDclose(rdir->directory);
|
||||
#else
|
||||
if (rdir->directory)
|
||||
closedir(rdir->directory);
|
||||
|
@ -437,108 +437,6 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//this is enables you to copy access permissions from one file/folder to another
|
||||
//however depending on the target and where the file is being transferred to and from it may not be needed.
|
||||
//(use disgression)
|
||||
int uwp_copy_acl(const wchar_t* source, const wchar_t* target)
|
||||
{
|
||||
PSECURITY_DESCRIPTOR sidOwnerDescriptor = nullptr;
|
||||
PSECURITY_DESCRIPTOR sidGroupDescriptor = nullptr;
|
||||
PSECURITY_DESCRIPTOR daclDescriptor = nullptr;
|
||||
PSID sidOwner;
|
||||
PSID sidGroup;
|
||||
PACL dacl;
|
||||
PACL sacl;
|
||||
DWORD result;
|
||||
HANDLE original_file = CreateFileFromAppW(source, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
if (original_file != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
result = GetSecurityInfo(original_file, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, &sidOwner, &sidGroup, &dacl, &sacl, &daclDescriptor);
|
||||
if (result != 0)
|
||||
{
|
||||
LocalFree(daclDescriptor);
|
||||
CloseHandle(original_file);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = GetSecurityInfo(original_file, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, &sidOwner, &sidGroup, &dacl, &sacl, &sidOwnerDescriptor);
|
||||
if (result != 0)
|
||||
{
|
||||
LocalFree(sidOwnerDescriptor);
|
||||
LocalFree(daclDescriptor);
|
||||
CloseHandle(original_file);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = GetSecurityInfo(original_file, SE_FILE_OBJECT, GROUP_SECURITY_INFORMATION, &sidOwner, &sidGroup, &dacl, &sacl, &sidGroupDescriptor);
|
||||
|
||||
//close file handle regardless of result
|
||||
CloseHandle(original_file);
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
LocalFree(sidOwnerDescriptor);
|
||||
LocalFree(sidGroupDescriptor);
|
||||
LocalFree(daclDescriptor);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = GetNamedSecurityInfoW(source, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, &sidOwner, &sidGroup, &dacl, &sacl, &daclDescriptor);
|
||||
if (result != 0)
|
||||
{
|
||||
LocalFree(daclDescriptor);
|
||||
return result;
|
||||
}
|
||||
result = GetNamedSecurityInfoW(source, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, &sidOwner, &sidGroup, &dacl, &sacl, &sidOwnerDescriptor);
|
||||
if (result != 0)
|
||||
{
|
||||
LocalFree(sidOwnerDescriptor);
|
||||
LocalFree(daclDescriptor);
|
||||
return result;
|
||||
}
|
||||
result = GetNamedSecurityInfoW(source, SE_FILE_OBJECT, GROUP_SECURITY_INFORMATION, &sidOwner, &sidGroup, &dacl, &sacl, &sidGroupDescriptor);
|
||||
if (result != 0)
|
||||
{
|
||||
LocalFree(sidOwnerDescriptor);
|
||||
LocalFree(sidGroupDescriptor);
|
||||
LocalFree(daclDescriptor);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
SECURITY_INFORMATION info = DACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION;
|
||||
HANDLE target_file = CreateFileFromAppW(target, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (target_file != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
result = SetSecurityInfo(target_file, SE_FILE_OBJECT, info, sidOwner, sidGroup, dacl, sacl);
|
||||
CloseHandle(target_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t* temp = wcsdup(target);
|
||||
result = SetNamedSecurityInfoW(temp, SE_FILE_OBJECT, info, sidOwner, sidGroup, dacl, sacl);
|
||||
free(temp);
|
||||
}
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
LocalFree(sidOwnerDescriptor);
|
||||
LocalFree(sidGroupDescriptor);
|
||||
LocalFree(daclDescriptor);
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((sidOwnerDescriptor != nullptr && LocalFree(sidOwnerDescriptor) != nullptr) || (daclDescriptor != nullptr && LocalFree(daclDescriptor) != nullptr) || (daclDescriptor != nullptr && LocalFree(daclDescriptor) != nullptr))
|
||||
{
|
||||
//an error occured but idk what error code is right so we just return -1
|
||||
return -1;
|
||||
}
|
||||
|
||||
//woo we made it all the way to the end so we can return success
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uwp_mkdir_impl(std::experimental::filesystem::path dir)
|
||||
{
|
||||
//I feel like this should create the directory recursively but the existing implementation does not so this update won't
|
||||
@ -657,13 +555,8 @@ int uwp_move_path(std::filesystem::path old_path, std::filesystem::path new_path
|
||||
//failed to move the file
|
||||
return -1;
|
||||
}
|
||||
//set acl - this step fucking sucks or at least to before I made a whole ass function
|
||||
//idk if we actually "need" to set the acl though
|
||||
if (uwp_copy_acl(new_path.parent_path().wstring().c_str(), new_path.wstring().c_str()) != 0)
|
||||
{
|
||||
//setting acl failed
|
||||
return -1;
|
||||
}
|
||||
//set acl
|
||||
uwp_set_acl(new_path.wstring().c_str(), L"S-1-15-2-1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -722,11 +615,7 @@ int uwp_move_path(std::filesystem::path old_path, std::filesystem::path new_path
|
||||
}
|
||||
//set acl - this step fucking sucks or at least to before I made a whole ass function
|
||||
//idk if we actually "need" to set the acl though
|
||||
if (uwp_copy_acl(new_path.wstring().c_str(), temp_new.wstring().c_str()) != 0)
|
||||
{
|
||||
//setting acl failed
|
||||
fail = true;
|
||||
}
|
||||
uwp_set_acl(temp_new.wstring().c_str(), L"S-1-15-2-1");
|
||||
}
|
||||
}
|
||||
} while (FindNextFile(searchResults, &findDataResult));
|
||||
|
Loading…
Reference in New Issue
Block a user