diff --git a/Utilities/rFile.cpp b/Utilities/rFile.cpp index 2ce5fdcbfe..20acd70efd 100644 --- a/Utilities/rFile.cpp +++ b/Utilities/rFile.cpp @@ -153,13 +153,7 @@ bool rFile::Open(const std::string &filename, rFile::OpenMode mode, int access) bool rFile::Exists(const std::string &file) { -#ifdef _WIN32 - std::wstring wstr = ConvertUTF8ToWString(file); - return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF; -#else - struct stat buffer; - return (stat (file.c_str(), &buffer) == 0); -#endif + rExists(file); } bool rFile::IsOpened() const @@ -215,6 +209,27 @@ bool rRmdir(const std::string &dir) #endif } +bool rRename(const std::string &from, const std::string &to) +{ + // TODO: Deal with case-sensitivity +#ifdef _WIN32 + return (MoveFile(ConvertUTF8ToWString(from).c_str(), ConvertUTF8ToWString(to).c_str()) == TRUE); +#else + return (0 == rename(from.c_str(), to.c_str())); +#endif +} + +bool rExists(const std::string &file) +{ +#ifdef _WIN32 + std::wstring wstr = ConvertUTF8ToWString(file); + return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF; +#else + struct stat buffer; + return (stat (file.c_str(), &buffer) == 0); +#endif +} + bool rDirExists(const std::string &path) { return wxDirExists(fmt::FromUTF8(path)); @@ -287,8 +302,6 @@ bool rDir::GetNext(std::string *filename) const *filename = str.ToStdString(); return res; } - - rFileName::rFileName() { diff --git a/Utilities/rFile.h b/Utilities/rFile.h index 35cb332661..55a760abef 100644 --- a/Utilities/rFile.h +++ b/Utilities/rFile.h @@ -45,6 +45,8 @@ std::string rGetCwd(); bool rRmdir(const std::string& dir); bool rMkdir(const std::string& dir); bool rMkpath(const std::string& path); +bool rRename(const std::string &from, const std::string &to); +bool rExists(const std::string &path); bool rDirExists(const std::string &path); bool rFileExists(const std::string &path); bool rRemoveFile(const std::string &path); diff --git a/rpcs3/Emu/FS/vfsDir.cpp b/rpcs3/Emu/FS/vfsDir.cpp index a161183549..e648745fe8 100644 --- a/rpcs3/Emu/FS/vfsDir.cpp +++ b/rpcs3/Emu/FS/vfsDir.cpp @@ -8,6 +8,9 @@ vfsDir::vfsDir() : vfsDirBase(nullptr) , m_stream(nullptr) { + // TODO: proper implementation + // m_stream is nullptr here. So open root until a proper dir is given + Open("/"); } vfsDir::vfsDir(const std::string& path) @@ -33,7 +36,7 @@ bool vfsDir::Create(const std::string& path) bool vfsDir::IsExists(const std::string& path) const { - return m_stream->IsExists(path); // Crash (Access violation reading location 0x0000000000000000) + return m_stream->IsExists(path); } const std::vector& vfsDir::GetEntries() const diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp index b08dda80f4..34e1f4abf7 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp @@ -159,31 +159,31 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_treserved2 = 0; u64 stamp0 = get_system_time(); - auto pY = std::unique_ptr{ new u8[w*h] }.get(); // color planes - auto pU = std::unique_ptr{ new u8[w*h/4] }.get(); - auto pV = std::unique_ptr{ new u8[w*h/4] }.get(); - auto pA = std::unique_ptr{ new u8[w*h] }.get(); - auto res = std::unique_ptr{ new u32[ow*oh*4] }.get(); // RGBA interleaved output + std::unique_ptr pY(new u8[w*h]); // color planes + std::unique_ptr pU(new u8[w*h/4]); + std::unique_ptr pV(new u8[w*h/4]); + std::unique_ptr pA(new u8[w*h]); + std::unique_ptr res(new u32[ow*oh*4]); // RGBA interleaved output - if (!Memory.CopyToReal(pY, inPicBuff_addr, w*h)) + if (!Memory.CopyToReal(pY.get(), inPicBuff_addr, w*h)) { cellVpost->Error("cellVpostExec: data copying failed(pY)"); Emu.Pause(); } - if (!Memory.CopyToReal(pU, inPicBuff_addr + w*h, w*h/4)) + if (!Memory.CopyToReal(pU.get(), inPicBuff_addr + w*h, w*h/4)) { cellVpost->Error("cellVpostExec: data copying failed(pU)"); Emu.Pause(); } - if (!Memory.CopyToReal(pV, inPicBuff_addr + w*h + w*h/4, w*h/4)) + if (!Memory.CopyToReal(pV.get(), inPicBuff_addr + w*h + w*h/4, w*h/4)) { cellVpost->Error("cellVpostExec: data copying failed(pV)"); Emu.Pause(); } - memset(pA, (const u8)ctrlParam->outAlpha, w*h); + memset(pA.get(), (const u8)ctrlParam->outAlpha, w*h); u64 stamp1 = get_system_time(); @@ -191,9 +191,9 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t(ow*4), 0, 0, 0 }; sws_scale(sws, in_data, in_line, 0, h, out_data, out_line); @@ -202,7 +202,7 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_tError("cellVpostExec: data copying failed(result)"); Emu.Pause(); diff --git a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp index ed40ca711e..b62df5b512 100644 --- a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp +++ b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp @@ -19,17 +19,9 @@ enum IDFlag_Dir = 2, }; -struct FsRingBuffer -{ - u64 m_ringbuf_size; - u64 m_block_size; - u64 m_transfer_rate; - u32 m_copy; -}; - struct FsRingBufferConfig { - FsRingBuffer m_ring_buffer; + CellFsRingBuffer m_ring_buffer; // Currently unused after assignment u32 m_buffer; u64 m_fs_status; u64 m_regid; @@ -41,15 +33,9 @@ struct FsRingBufferConfig , m_regid(0) , m_alloc_mem_size(0) , m_current_addr(0) - { - memset(&m_ring_buffer, 0, sizeof(FsRingBuffer)); - } + , m_ring_buffer() { } - ~FsRingBufferConfig() - { - memset(&m_ring_buffer, 0, sizeof(FsRingBuffer)); - } -} m_fs_config; +} fs_config; s32 cellFsOpen(u32 path_addr, s32 flags, mem32_t fd, mem32_t arg, u64 size) @@ -563,22 +549,17 @@ s32 cellFsStReadInit(u32 fd, mem_ptr_t ringbuf) if(!ringbuf.IsGood()) return CELL_EFAULT; - FsRingBuffer& buffer = m_fs_config.m_ring_buffer; + fs_config.m_ring_buffer = *ringbuf; - buffer.m_block_size = ringbuf->block_size; - buffer.m_copy = ringbuf->copy; - buffer.m_ringbuf_size = ringbuf->ringbuf_size; - buffer.m_transfer_rate = ringbuf->transfer_rate; - - if(buffer.m_ringbuf_size < 0x40000000) // If the size is less than 1MB - m_fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 64 * 1024 - 1) / (64 * 1024)) * (64 * 1024); - m_fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 1024 * 1024 - 1) / (1024 * 1024)) * (1024 * 1024); + if(ringbuf->ringbuf_size < 0x40000000) // If the size is less than 1MB + fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 64 * 1024 - 1) / (64 * 1024)) * (64 * 1024); + fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 1024 * 1024 - 1) / (1024 * 1024)) * (1024 * 1024); // alloc memory - m_fs_config.m_buffer = Memory.Alloc(m_fs_config.m_alloc_mem_size, 1024); - memset(Memory + m_fs_config.m_buffer, 0, m_fs_config.m_alloc_mem_size); + fs_config.m_buffer = Memory.Alloc(fs_config.m_alloc_mem_size, 1024); + memset(Memory + fs_config.m_buffer, 0, fs_config.m_alloc_mem_size); - m_fs_config.m_fs_status = CELL_FS_ST_INITIALIZED; + fs_config.m_fs_status = CELL_FS_ST_INITIALIZED; return CELL_OK; } @@ -590,8 +571,8 @@ s32 cellFsStReadFinish(u32 fd) vfsStream* file; if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; - Memory.Free(m_fs_config.m_buffer); - m_fs_config.m_fs_status = CELL_FS_ST_NOT_INITIALIZED; + Memory.Free(fs_config.m_buffer); + fs_config.m_fs_status = CELL_FS_ST_NOT_INITIALIZED; return CELL_OK; } @@ -606,15 +587,10 @@ s32 cellFsStReadGetRingBuf(u32 fd, mem_ptr_t ringbuf) if(!ringbuf.IsGood()) return CELL_EFAULT; - FsRingBuffer& buffer = m_fs_config.m_ring_buffer; + *ringbuf = fs_config.m_ring_buffer; - ringbuf->block_size = buffer.m_block_size; - ringbuf->copy = buffer.m_copy; - ringbuf->ringbuf_size = buffer.m_ringbuf_size; - ringbuf->transfer_rate = buffer.m_transfer_rate; - - sys_fs->Warning("*** fs stream config: block_size=0x%llx, copy=%d, ringbuf_size = 0x%llx, transfer_rate = 0x%llx", ringbuf->block_size, ringbuf->copy, - ringbuf->ringbuf_size, ringbuf->transfer_rate); + sys_fs->Warning("*** fs stream config: block_size=0x%llx, copy=%d, ringbuf_size = 0x%llx, transfer_rate = 0x%llx", + ringbuf->block_size, ringbuf->copy,ringbuf->ringbuf_size, ringbuf->transfer_rate); return CELL_OK; } @@ -625,7 +601,7 @@ s32 cellFsStReadGetStatus(u32 fd, mem64_t status) vfsStream* file; if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; - status = m_fs_config.m_fs_status; + status = fs_config.m_fs_status; return CELL_OK; } @@ -637,7 +613,7 @@ s32 cellFsStReadGetRegid(u32 fd, mem64_t regid) vfsStream* file; if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; - regid = m_fs_config.m_regid; + regid = fs_config.m_regid; return CELL_OK; } @@ -649,8 +625,8 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size) vfsStream* file; if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; - m_fs_config.m_current_addr = m_fs_config.m_buffer + (u32)offset; - m_fs_config.m_fs_status = CELL_FS_ST_PROGRESS; + fs_config.m_current_addr = fs_config.m_buffer + (u32)offset; + fs_config.m_fs_status = CELL_FS_ST_PROGRESS; return CELL_OK; } @@ -662,7 +638,7 @@ s32 cellFsStReadStop(u32 fd) vfsStream* file; if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; - m_fs_config.m_fs_status = CELL_FS_ST_STOP; + fs_config.m_fs_status = CELL_FS_ST_STOP; return CELL_OK; } @@ -676,8 +652,8 @@ s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, mem64_t rsize) if (rsize.GetAddr() && !rsize.IsGood()) return CELL_EFAULT; - m_fs_config.m_regid += size; - rsize = m_fs_config.m_regid; + fs_config.m_regid += size; + rsize = fs_config.m_regid; return CELL_OK; }