mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-31 22:44:41 +00:00
Windows hacks
Windows is more limiting about how folders are opened and things like that. For now, pretend these calls didn't error. Also fixes compilation for Windows
This commit is contained in:
parent
06a2c5cb27
commit
7442af754f
@ -134,16 +134,14 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||||||
|
|
||||||
file->type = Core::FileSys::FileType::Directory;
|
file->type = Core::FileSys::FileType::Directory;
|
||||||
|
|
||||||
// If opening is a success, iterate through contents
|
// Populate directory contents
|
||||||
if (e == 0) {
|
mnt->IterateDirectory(file->m_guest_name,
|
||||||
mnt->IterateDirectory(file->m_guest_name,
|
[&file](const auto& ent_path, const auto ent_is_file) {
|
||||||
[&file](const auto& ent_path, const auto ent_is_file) {
|
auto& dir_entry = file->dirents.emplace_back();
|
||||||
auto& dir_entry = file->dirents.emplace_back();
|
dir_entry.name = ent_path.filename().string();
|
||||||
dir_entry.name = ent_path.filename().string();
|
dir_entry.isFile = ent_is_file;
|
||||||
dir_entry.isFile = ent_is_file;
|
});
|
||||||
});
|
file->dirents_index = 0;
|
||||||
file->dirents_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (read) {
|
if (read) {
|
||||||
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
||||||
@ -159,6 +157,12 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e == EACCES) {
|
||||||
|
// Windows-specific hack, ignore the error and continue as normal.
|
||||||
|
LOG_WARNING(Kernel_Fs, "Trying to open a directory on Windows");
|
||||||
|
e = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (truncate) {
|
if (truncate) {
|
||||||
// Cannot open directories with truncate
|
// Cannot open directories with truncate
|
||||||
h->DeleteHandle(handle);
|
h->DeleteHandle(handle);
|
||||||
@ -166,6 +170,13 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (std::filesystem::is_directory(file->m_host_name)) {
|
||||||
|
// Directories can be opened even if the directory flag isn't set.
|
||||||
|
file->type = Core::FileSys::FileType::Directory;
|
||||||
|
} else {
|
||||||
|
file->type = Core::FileSys::FileType::Regular;
|
||||||
|
}
|
||||||
|
|
||||||
if (read) {
|
if (read) {
|
||||||
// Read only
|
// Read only
|
||||||
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
||||||
@ -185,9 +196,15 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file->type == Core::FileSys::FileType::Directory && e == EACCES) {
|
||||||
|
// Windows-specific hack, ignore the error and continue as normal.
|
||||||
|
LOG_WARNING(Kernel_Fs, "Tried to open a directory on Windows");
|
||||||
|
e = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (truncate && e == 0) {
|
if (truncate && e == 0) {
|
||||||
// If the file was opened successfully and truncate was enabled, reduce size to 0
|
// If the file was opened successfully and truncate was enabled, reduce size to 0
|
||||||
file->f.SetSize(file->m_host_name.c_str(), 0);
|
file->f.SetSize(file->m_host_name.string().c_str(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,7 +700,7 @@ s32 PS4_SYSV_ABI posix_ftruncate(s32 fd, s64 length) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->f.SetSize(file->m_host_name.c_str(), length);
|
file->f.SetSize(file->m_host_name.string().c_str(), length);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user