mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
IOPBios: Implement the different iomanx stat file modes
This commit is contained in:
parent
638f2e09ed
commit
14e0aeb4f3
@ -109,13 +109,45 @@ namespace R3000A
|
|||||||
#define Ra2 (iopMemReadString(a2))
|
#define Ra2 (iopMemReadString(a2))
|
||||||
#define Ra3 (iopMemReadString(a3))
|
#define Ra3 (iopMemReadString(a3))
|
||||||
|
|
||||||
#define FIO_SO_IXOTH 0x0001
|
// Stat values differ between iomanX and ioman
|
||||||
#define FIO_SO_IWOTH 0x0002
|
// These values have been taken from the PS2SDK
|
||||||
#define FIO_SO_IROTH 0x0004
|
// Specifically iox_stat.h
|
||||||
|
struct fio_stat_flags
|
||||||
|
{
|
||||||
|
// Access flags
|
||||||
|
// Execute
|
||||||
|
int IXOTH;
|
||||||
|
// Write
|
||||||
|
int IWOTH;
|
||||||
|
// Read
|
||||||
|
int IROTH;
|
||||||
|
|
||||||
#define FIO_SO_IFLNK 0x0008
|
// File mode flags
|
||||||
#define FIO_SO_IFREG 0x0010
|
// Symlink
|
||||||
#define FIO_SO_IFDIR 0x0020
|
int IFLNK;
|
||||||
|
// Regular file
|
||||||
|
int IFREG;
|
||||||
|
// Directory
|
||||||
|
int IFDIR;
|
||||||
|
};
|
||||||
|
|
||||||
|
fio_stat_flags ioman_stat{
|
||||||
|
0x01,
|
||||||
|
0x02,
|
||||||
|
0x04,
|
||||||
|
0x08,
|
||||||
|
0x10,
|
||||||
|
0x20,
|
||||||
|
};
|
||||||
|
|
||||||
|
fio_stat_flags iomanx_stat{
|
||||||
|
0x01,
|
||||||
|
0x02,
|
||||||
|
0x04,
|
||||||
|
0x4000,
|
||||||
|
0x2000,
|
||||||
|
0x1000,
|
||||||
|
};
|
||||||
|
|
||||||
static std::string host_path(const std::string& path, bool allow_open_host_root)
|
static std::string host_path(const std::string& path, bool allow_open_host_root)
|
||||||
{
|
{
|
||||||
@ -161,7 +193,7 @@ namespace R3000A
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int host_stat(const std::string path, fio_stat_t* host_stats)
|
static int host_stat(const std::string path, fio_stat_t* host_stats, fio_stat_flags& stat = ioman_stat)
|
||||||
{
|
{
|
||||||
struct stat file_stats;
|
struct stat file_stats;
|
||||||
const std::string file_path(host_path(path, true));
|
const std::string file_path(host_path(path, true));
|
||||||
@ -173,20 +205,20 @@ namespace R3000A
|
|||||||
host_stats->hisize = 0;
|
host_stats->hisize = 0;
|
||||||
|
|
||||||
// Convert the mode.
|
// Convert the mode.
|
||||||
host_stats->mode = (file_stats.st_mode & (FIO_SO_IROTH | FIO_SO_IWOTH | FIO_SO_IXOTH));
|
host_stats->mode = (file_stats.st_mode & (stat.IROTH | stat.IWOTH | stat.IXOTH));
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (S_ISLNK(file_stats.st_mode))
|
if (S_ISLNK(file_stats.st_mode))
|
||||||
{
|
{
|
||||||
host_stats->mode |= FIO_SO_IFLNK;
|
host_stats->mode |= stat.IFLNK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (S_ISREG(file_stats.st_mode))
|
if (S_ISREG(file_stats.st_mode))
|
||||||
{
|
{
|
||||||
host_stats->mode |= FIO_SO_IFREG;
|
host_stats->mode |= stat.IFREG;
|
||||||
}
|
}
|
||||||
if (S_ISDIR(file_stats.st_mode))
|
if (S_ISDIR(file_stats.st_mode))
|
||||||
{
|
{
|
||||||
host_stats->mode |= FIO_SO_IFDIR;
|
host_stats->mode |= stat.IFDIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the creation time.
|
// Convert the creation time.
|
||||||
@ -222,7 +254,7 @@ namespace R3000A
|
|||||||
|
|
||||||
static int host_stat(const std::string path, fxio_stat_t* host_stats)
|
static int host_stat(const std::string path, fxio_stat_t* host_stats)
|
||||||
{
|
{
|
||||||
return host_stat(path, &host_stats->_fioStat);
|
return host_stat(path, &host_stats->_fioStat, iomanx_stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: sandbox option, other permissions
|
// TODO: sandbox option, other permissions
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user