HostFS: Add native mode to the open file

This commit is contained in:
Francisco Javier Trujillo Mata 2021-04-17 13:48:39 +02:00 committed by refractionpcsx2
parent 0dadda66cf
commit 9ecda0489b
1 changed files with 4 additions and 8 deletions

View File

@ -162,7 +162,7 @@ static int host_stat(const std::string path, fio_stat_t *host_stats)
struct stat file_stats; struct stat file_stats;
if (::stat(path.c_str(), &file_stats)) if (::stat(path.c_str(), &file_stats))
return IOP_ENOENT; return -IOP_ENOENT;
host_stats->size = file_stats.st_size; host_stats->size = file_stats.st_size;
host_stats->hisize = 0; host_stats->hisize = 0;
@ -241,11 +241,7 @@ public:
static int open(IOManFile **file, const std::string &full_path, s32 flags, u16 mode) static int open(IOManFile **file, const std::string &full_path, s32 flags, u16 mode)
{ {
const std::string path = full_path.substr(full_path.find(':') + 1); const std::string path = full_path.substr(full_path.find(':') + 1);
int native_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH; // 0644
// host: actually DOES let you write!
//if (flags != IOP_O_RDONLY)
// return -IOP_EROFS;
int native_flags = O_BINARY; // necessary in Windows. int native_flags = O_BINARY; // necessary in Windows.
switch(flags&IOP_O_RDWR) switch(flags&IOP_O_RDWR)
@ -259,7 +255,7 @@ public:
if(flags&IOP_O_CREAT) native_flags |= O_CREAT; if(flags&IOP_O_CREAT) native_flags |= O_CREAT;
if(flags&IOP_O_TRUNC) native_flags |= O_TRUNC; if(flags&IOP_O_TRUNC) native_flags |= O_TRUNC;
int hostfd = ::open(host_path(path).data(), native_flags); int hostfd = ::open(host_path(path).data(), native_flags, native_mode);
if (hostfd < 0) if (hostfd < 0)
return translate_error(hostfd); return translate_error(hostfd);