This commit is contained in:
twinaphex 2019-01-08 20:32:40 +01:00
parent b74b24e648
commit 6bd4d91038
4 changed files with 38 additions and 56 deletions

View File

@ -126,14 +126,14 @@ enum stat_mode
static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
{
#if defined(ORBIS)
return false; //by now
return false; /* for now */
#endif
#if defined(VITA) || defined(PSP)
SceIoStat buf;
char *tmp = strdup(path);
size_t len = strlen(tmp);
if (tmp[len-1] == '/')
tmp[len-1]='\0';
tmp[len-1] = '\0';
if (sceIoGetstat(tmp, &buf) < 0)
{
@ -146,7 +146,7 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
char *tmp = strdup(path);
size_t len = strlen(tmp);
if (tmp[len-1] == '/')
tmp[len-1]='\0';
tmp[len-1] = '\0';
if (fileXioGetStat(tmp, &buf) < 0)
{
@ -159,10 +159,10 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
if (cellFsStat(path, &buf) < 0)
return false;
#elif defined(_WIN32)
struct _stat buf;
char *path_local;
wchar_t *path_wide;
DWORD file_info;
struct _stat buf;
char *path_local = NULL;
wchar_t *path_wide = NULL;
if (!path || !*path)
return false;
@ -219,7 +219,7 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
#endif
case IS_CHARACTER_SPECIAL:
#if defined(VITA) || defined(PSP) || defined(PS2) || defined(__CELLOS_LV2__) || defined(_WIN32)
return false;
break;
#else
return S_ISCHR(buf.st_mode);
#endif
@ -241,15 +241,12 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
bool path_is_directory(const char *path)
{
#ifdef ORBIS
int dfd;
if (!path)
{
return false;
}
int dfd = orbisDopen(path);
return false;
dfd = orbisDopen(path);
if (dfd < 0)
{
return false;
}
return false;
orbisDclose(dfd);
return true;
#else

View File

@ -47,16 +47,20 @@ struct nbio_orbis_t
static void *nbio_orbis_open(const char * filename, unsigned int mode)
{
RARCH_LOG("[NBIO_ORBIS] open %s\n" , filename);
static const int o_flags[] = { O_RDONLY, O_RDWR|O_CREAT|O_TRUNC, O_RDWR, O_RDONLY, O_RDWR|O_CREAT|O_TRUNC };
static const int o_flags[] = { O_RDONLY, O_RDWR | O_CREAT | O_TRUNC,
O_RDWR, O_RDONLY, O_RDWR | O_CREAT | O_TRUNC };
void *buf = NULL;
struct nbio_orbis_t* handle = NULL;
size_t len = 0;
int fd = orbisOpen(filename, o_flags[mode], 0644);
RARCH_LOG("[NBIO_ORBIS] open %s\n" , filename);
if (fd < 0)
return NULL;
handle = (struct nbio_orbis_t*)malloc(sizeof(struct nbio_orbis_t));
if (!handle)
goto error;
@ -77,10 +81,12 @@ static void *nbio_orbis_open(const char * filename, unsigned int mode)
if (len)
buf = malloc(len);
if (!buf)
{
RARCH_LOG("[NBIO_ORBIS] open error malloc %d bytes\n",len);
}
if (len && !buf)
goto error;
@ -110,7 +116,6 @@ static void nbio_orbis_begin_read(void *data)
if (handle->op >= 0)
{
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file read operation while busy\n");
//abort();
return;
}
@ -130,7 +135,6 @@ static void nbio_orbis_begin_write(void *data)
if (handle->op >= 0)
{
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file write operation while busy\n");
//abort();
return;
}
@ -208,19 +212,17 @@ static void nbio_orbis_resize(void *data, size_t len)
if (handle->op >= 0)
{
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file resize operation while busy\n");
//abort();
return;
}
if (len < handle->len)
{
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file shrink operation, not implemented");
//abort();
return;
}
handle->len = len;
handle->data = realloc(handle->data, handle->len);
handle->op = -1;
handle->len = len;
handle->data = realloc(handle->data, handle->len);
handle->op = -1;
handle->progress = handle->len;
}
@ -257,7 +259,6 @@ static void nbio_orbis_free(void *data)
if (handle->op >= 0)
{
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted free() while busy\n");
//abort();
return;
}
RARCH_LOG("[NBIO_ORBIS] free close fd=%d\n",handle->fd);

View File

@ -285,9 +285,7 @@ bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
#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

View File

@ -136,17 +136,13 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i
#elif defined(PS2)
return fioLseek(fileno(stream->fp), (off_t)offset, whence);
#elif defined(ORBIS)
int ret;
ret = orbisLseek(stream->fd, offset, whence);
int ret = orbisLseek(stream->fd, offset, whence);
RARCH_LOG("[VFS]retro_vfs_file_seek_internal orbisLseek return %d on fd=%d filename=%s\n", ret, stream->fd, stream->orig_path);
if (ret < 0)
{
return -1;
}
else
{
return 0;
}
return 0;
#else
return fseeko(stream->fp, (off_t)offset, whence);
#endif
@ -471,13 +467,8 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
int64_t ret = orbisLseek(stream->fd, 0, SEEK_CUR);
RARCH_LOG("[VFS]retro_vfs_file_tell_impl orbisLseek fd=%d path=%s ret=%d\n", stream->fd, stream->orig_path, ret);
if(ret < 0)
{
return -1;
}
else
{
return ret;
}
return ret;
#else
/* VC2005 and up have a special 64-bit ftell */
#ifdef ATLEAST_VC2005
@ -499,7 +490,8 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
return 0;
}
int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file *stream, int64_t offset, int seek_position)
int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file *stream,
int64_t offset, int seek_position)
{
int whence = -1;
switch (seek_position)
@ -518,7 +510,8 @@ int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file *stream, int64
return retro_vfs_file_seek_internal(stream, offset, whence);
}
int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream, void *s, uint64_t len)
int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream,
void *s, uint64_t len)
{
if (!stream || !s)
goto error;
@ -527,15 +520,11 @@ int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream, void
{
#ifdef ORBIS
int64_t ret = orbisRead(stream->fd, s, (size_t)len);
RARCH_LOG("[VFS]retro_vfs_file_read_impl orbisRead fd=%d path=%s bytesread=%d\n", stream->fd, stream->orig_path, ret);
if( ret < 0)
{
return -1;
}
else
{
return 0;
}
return 0;
#else
return fread(s, 1, (size_t)len, stream->fp);
#endif
@ -571,15 +560,12 @@ int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, cons
{
#ifdef ORBIS
int64_t ret = orbisWrite(stream->fd, s, (size_t)len);
RARCH_LOG("[VFS]retro_vfs_file_write_impl orbisWrite fd=%d path=%s byteswrite=%d\n", stream->fd, stream->orig_path, ret);
if( ret < 0)
{
return -1;
}
else
{
return 0;
}
return 0;
#else
return fwrite(s, 1, (size_t)len, stream->fp);
#endif
@ -642,7 +628,7 @@ int retro_vfs_file_remove_impl(const char *path)
#endif
#else
#ifdef ORBIS
//by now no remove
/* stub for now */
return 0;
#else
if (remove(path) == 0)
@ -710,7 +696,7 @@ int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
return -1;
#else
#ifdef ORBIS
//by now no remove
/* stub for now */
return 0;
#else
return rename(old_path, new_path)==0 ? 0 : -1;