mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 11:35:45 +00:00
added lseek in file_system
This commit is contained in:
parent
ec988b7bea
commit
28a5b1f0b3
2 changed files with 25 additions and 0 deletions
|
@ -51,10 +51,34 @@ size_t PS4_SYSV_ABI _readv(int d, const SceKernelIovec* iov, int iovcnt) {
|
|||
return total_read;
|
||||
}
|
||||
|
||||
s64 PS4_SYSV_ABI lseek(int d, s64 offset, int whence) {
|
||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||
auto* file = h->GetFile(d);
|
||||
|
||||
file->m_mutex.lock();
|
||||
|
||||
if (whence == 1) {
|
||||
offset = static_cast<int64_t>(file->f.Tell()) + offset;
|
||||
whence = 0;
|
||||
}
|
||||
|
||||
if (whence == 2) {
|
||||
offset = static_cast<int64_t>(file->f.GetSize()) + offset;
|
||||
whence = 0;
|
||||
}
|
||||
|
||||
file->f.Seek(offset);
|
||||
auto pos = static_cast<int64_t>(file->f.Tell());
|
||||
|
||||
file->m_mutex.unlock();
|
||||
return pos;
|
||||
}
|
||||
|
||||
void fileSystemSymbolsRegister(Loader::SymbolsResolver* sym) {
|
||||
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen);
|
||||
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open);
|
||||
LIB_FUNCTION("+WRlkKjZvag", "libkernel", 1, "libkernel", 1, 1, _readv);
|
||||
LIB_FUNCTION("Oy6IpwgtYOk", "libkernel", 1, "libkernel", 1, 1, lseek);
|
||||
|
||||
// openOrbis (to check if it is valid out of OpenOrbis
|
||||
LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1,
|
||||
|
|
|
@ -19,6 +19,7 @@ struct SceKernelIovec {
|
|||
int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, /* SceKernelMode*/ u16 mode);
|
||||
|
||||
int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode);
|
||||
s64 PS4_SYSV_ABI lseek(int d, s64 offset, int whence);
|
||||
|
||||
void fileSystemSymbolsRegister(Loader::SymbolsResolver* sym);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue