diff --git a/Utilities/AutoPause.cpp b/Utilities/AutoPause.cpp index 94e4f058bf..f92ccd1cc0 100644 --- a/Utilities/AutoPause.cpp +++ b/Utilities/AutoPause.cpp @@ -77,10 +77,7 @@ void AutoPause::Reload(void) } } } - else - { - LOG_WARNING(HLE, "No pause.bin found, Auto Pause will not work."); - } + m_pause_syscall_enable = Ini.DBGAutoPauseSystemCall.GetValue(); m_pause_function_enable = Ini.DBGAutoPauseFunctionCall.GetValue(); initialized = true; @@ -123,4 +120,4 @@ void AutoPause::TryPause(u32 code) { } } } -} \ No newline at end of file +} diff --git a/Utilities/rFile.cpp b/Utilities/rFile.cpp index 5311285f89..6ed5bf3bee 100644 --- a/Utilities/rFile.cpp +++ b/Utilities/rFile.cpp @@ -395,8 +395,8 @@ bool rfile_t::open(const std::string& filename, u32 mode) switch (mode & (o_read | o_write)) { - case o_read: flags |= O_READ; break; - case o_write: flags |= O_WRITE; break; + case o_read: flags |= O_RDONLY; break; + case o_write: flags |= O_WRONLY; break; case o_read | o_write: flags |= O_RDWR; break; default: { @@ -476,7 +476,7 @@ u64 rfile_t::read(void* buffer, u64 count) const return nread; #else - return read64(fd, buffer, count); + return ::read(fd, buffer, count); #endif } @@ -491,7 +491,7 @@ u64 rfile_t::write(const void* buffer, u64 count) const return nwritten; #else - return write64(fd, buffer, count); + return ::write(fd, buffer, count); #endif } diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index c2e6594609..f43c0b4c51 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -6,7 +6,6 @@ #include "Ini.h" #include "Emu/System.h" #include "Utilities/Log.h" -#include // To check whether directory exists #undef CreateFile #undef CopyFile @@ -496,33 +495,30 @@ void VFS::SaveLoadDevices(std::vector& res, bool is_load) entries_count.SaveValue(count); } - // Custom EmulationDir. - // TODO:: should have a better log that would show results before loading a game? + // Custom EmulationDir if (Ini.SysEmulationDirPathEnable.GetValue()) { - std::string EmulationDir = Ini.SysEmulationDirPath.GetValue(); - if (EmulationDir.empty()) - Ini.SysEmulationDirPath.SetValue(Emu.GetEmulatorPath()); - struct stat fstatinfo; - if ((stat(EmulationDir.c_str(), &fstatinfo))) + std::string dir = Ini.SysEmulationDirPath.GetValue(); + + if (dir.empty()) { - LOG_NOTICE(GENERAL, "Custom EmualtionDir: Tried %s but it doesn't exists. Maybe you add some not needed chars like '\"'?"); - Ini.SysEmulationDirPathEnable.SetValue(false); + Ini.SysEmulationDirPath.SetValue(Emu.GetEmulatorPath()); + } + + FileInfo info; + if (!get_file_info(dir, info) || !info.exists) + { + LOG_ERROR(GENERAL, "Custom EmulationDir: '%s' not found", dir); + } + else if (!info.isDirectory) + { + LOG_ERROR(GENERAL, "Custom EmulationDir: '%s' is not a valid directory", dir); } - else if (fstatinfo.st_mode & S_IFDIR) - LOG_NOTICE(GENERAL, "Custom EmualtionDir: On, Binded $(EmulatorDir) to %s.", EmulationDir); else { - // If that is not directory turn back to use original one. - LOG_NOTICE(GENERAL, "Custom EmulationDir: Cause path %s is not a valid directory.", EmulationDir); - Ini.SysEmulationDirPathEnable.SetValue(false); + LOG_NOTICE(GENERAL, "Custom EmulationDir: $(EmulatorDir) bound to '%s'", dir); } } - // I left this to check again just to catch those failed in directory checks. - if (!Ini.SysEmulationDirPathEnable.GetValue()) - { - LOG_NOTICE(GENERAL, "Custom EmualtionDir: Off, Binded $(EmulatorDir) to %s.", Emu.GetEmulatorPath()); - } for(int i=0; ifileType) { case CELL_SAVEDATA_FILETYPE_SECUREFILE: case CELL_SAVEDATA_FILETYPE_NORMALFILE: { - filepath = fileSet->fileName.get_ptr(); + file_path = fileSet->fileName.get_ptr(); break; } case CELL_SAVEDATA_FILETYPE_CONTENT_ICON0: { - filepath = "ICON0.PNG"; + file_path = "ICON0.PNG"; break; } case CELL_SAVEDATA_FILETYPE_CONTENT_ICON1: { - filepath = "ICON1.PAM"; + file_path = "ICON1.PAM"; break; } case CELL_SAVEDATA_FILETYPE_CONTENT_PIC1: { - filepath = "PIC1.PNG"; + file_path = "PIC1.PNG"; break; } case CELL_SAVEDATA_FILETYPE_CONTENT_SND0: { - filepath = "SND0.AT3"; + file_path = "SND0.AT3"; break; } @@ -560,43 +560,43 @@ __noinline s32 savedata_op( } } - psf.SetInteger("*" + filepath, fileSet->fileType.data() == se32(CELL_SAVEDATA_FILETYPE_SECUREFILE)); + psf.SetInteger("*" + file_path, fileSet->fileType.data() == se32(CELL_SAVEDATA_FILETYPE_SECUREFILE)); - filepath = dir_path + filepath; + std::string local_path; - std::unique_ptr file; + Emu.GetVFS().GetDevice(dir_path + file_path, local_path); switch (const u32 op = fileSet->fileOperation) { case CELL_SAVEDATA_FILEOP_READ: { - file.reset(Emu.GetVFS().OpenFile(filepath, o_read)); - file->Seek(fileSet->fileOffset); - fileGet->excSize = file->Read(fileSet->fileBuf.get_ptr(), std::min(fileSet->fileSize, fileSet->fileBufSize)); + rfile_t file(local_path, o_read); + file.seek(fileSet->fileOffset); + fileGet->excSize = static_cast(file.read(fileSet->fileBuf.get_ptr(), std::min(fileSet->fileSize, fileSet->fileBufSize))); break; } case CELL_SAVEDATA_FILEOP_WRITE: { - file.reset(Emu.GetVFS().OpenFile(filepath, o_write | o_create)); - file->Seek(fileSet->fileOffset); - fileGet->excSize = file->Write(fileSet->fileBuf.get_ptr(), std::min(fileSet->fileSize, fileSet->fileBufSize)); - // TODO: truncate this fucked shit + rfile_t file(local_path, o_write | o_create); + file.seek(fileSet->fileOffset); + fileGet->excSize = static_cast(file.write(fileSet->fileBuf.get_ptr(), std::min(fileSet->fileSize, fileSet->fileBufSize))); + file.trunc(file.seek(0, from_cur)); // truncate break; } case CELL_SAVEDATA_FILEOP_DELETE: { - Emu.GetVFS().RemoveFile(filepath); + rRemoveFile(local_path); fileGet->excSize = 0; break; } case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC: { - file.reset(Emu.GetVFS().OpenFile(filepath, o_write | o_create)); - file->Seek(fileSet->fileOffset); - fileGet->excSize = file->Write(fileSet->fileBuf.get_ptr(), std::min(fileSet->fileSize, fileSet->fileBufSize)); + rfile_t file(local_path, o_write | o_create); + file.seek(fileSet->fileOffset); + fileGet->excSize = static_cast(file.write(fileSet->fileBuf.get_ptr(), std::min(fileSet->fileSize, fileSet->fileBufSize))); break; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp b/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp index 68c74cca91..94154df1c4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_fs.cpp @@ -14,6 +14,7 @@ #include "Emu/FS/VFS.h" #include "Emu/FS/vfsFile.h" +#include "Emu/FS/vfsLocalFile.h" #include "Emu/FS/vfsDir.h" #include "sys_fs.h" @@ -471,18 +472,29 @@ s32 sys_fs_truncate(vm::ptr path, u64 size) s32 sys_fs_ftruncate(u32 fd, u64 size) { - sys_fs.Todo("sys_fs_ftruncate(fd=0x%x, size=0x%llx)", fd, size); + sys_fs.Warning("sys_fs_ftruncate(fd=0x%x, size=0x%llx)", fd, size); const auto file = Emu.GetIdManager().GetIDData(fd); - if (!file) + if (!file || !(file->flags & CELL_FS_O_ACCMODE)) { return CELL_FS_EBADF; } std::lock_guard lock(file->mutex); - // must use rfile_t::trunc() + const auto local_file = dynamic_cast(file->file.get()); + + if (!local_file) + { + sys_fs.Error("sys_fs_ftruncate(fd=0x%x): not a local file"); + return CELL_FS_ENOTSUP; + } + + if (!local_file->GetFile().trunc(size)) + { + return CELL_FS_EIO; // ??? + } return CELL_OK; } diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index d0acf68a9c..80e2f90be3 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -40,7 +40,6 @@ #include #include -#include #include "Utilities/GNU.h" typedef unsigned int uint;