mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
fileio hle calls
This commit is contained in:
parent
f57f668c92
commit
23ab99924f
@ -438,6 +438,11 @@ void libcSymbolsRegister(Loader::SymbolsResolver* sym) {
|
||||
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, ps4_vsnprintf);
|
||||
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, ps4_puts);
|
||||
LIB_FUNCTION("fffwELXNVFA", "libc", 1, "libc", 1, 1, ps4_fprintf);
|
||||
LIB_FUNCTION("xeYO4u7uyJ0", "libc", 1, "libc", 1, 1, ps4_fopen);
|
||||
LIB_FUNCTION("rQFVBXp-Cxg", "libc", 1, "libc", 1, 1, ps4_fseek);
|
||||
LIB_FUNCTION("Qazy8LmXTvw", "libc", 1, "libc", 1, 1, ps4_ftell);
|
||||
LIB_FUNCTION("lbB+UlZqVG0", "libc", 1, "libc", 1, 1, ps4_fread);
|
||||
LIB_FUNCTION("uodLYyUip20", "libc", 1, "libc", 1, 1, ps4_fclose);
|
||||
|
||||
// misc
|
||||
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &g_need_sceLibc);
|
||||
|
@ -1,6 +1,10 @@
|
||||
#include "core/hle/libraries/libc/libc_stdio.h"
|
||||
|
||||
#include <core/file_sys/fs.h>
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/log.h"
|
||||
#include "core/hle/libraries/libc/libc_stdio.h"
|
||||
#include "common/singleton.h"
|
||||
|
||||
namespace Core::Libraries::LibC {
|
||||
|
||||
@ -22,12 +26,38 @@ int PS4_SYSV_ABI ps4_fprintf(FILE* file, VA_ARGS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI ps4_vsnprintf(char* s, size_t n, const char* format, VaList* arg) {
|
||||
return vsnprintf_ctx(s, n, format, arg);
|
||||
int PS4_SYSV_ABI ps4_vsnprintf(char* s, size_t n, const char* format, VaList* arg) { return vsnprintf_ctx(s, n, format, arg); }
|
||||
|
||||
int PS4_SYSV_ABI ps4_puts(const char* s) { return std::puts(s); }
|
||||
|
||||
FILE* PS4_SYSV_ABI ps4_fopen(const char* filename, const char* mode) {
|
||||
LOG_INFO_IF(log_file_libc, "fopen filename={} , mode ={}\n", filename, mode);
|
||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
||||
|
||||
u32 handle = h->createHandle();
|
||||
auto* file = h->getFile(handle);
|
||||
file->m_guest_name = filename;
|
||||
file->m_host_name = mnt->getHostFile(file->m_guest_name);
|
||||
FILE* f = std::fopen(file->m_host_name.c_str(), mode);
|
||||
if (!f) {
|
||||
LOG_ERROR_IF(log_file_libc, "fopen can't open file={}\n", filename);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI ps4_puts(const char* s) {
|
||||
return std::puts(s);
|
||||
int PS4_SYSV_ABI ps4_fseek(FILE* stream, long int offset, int origin) { return std::fseek(stream, offset, origin); }
|
||||
|
||||
long PS4_SYSV_ABI ps4_ftell(FILE* stream) { return std::ftell(stream); }
|
||||
|
||||
size_t PS4_SYSV_ABI ps4_fread(void* ptr, size_t size, size_t count, FILE* stream) { return std::fread(ptr, size, count, stream); }
|
||||
|
||||
int PS4_SYSV_ABI ps4_fclose(FILE* stream) {
|
||||
LOG_INFO_IF(log_file_libc, "fclose\n");
|
||||
if (stream != nullptr) {
|
||||
std::fclose(stream);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Core::Libraries::LibC
|
||||
|
@ -9,5 +9,10 @@ int PS4_SYSV_ABI ps4_printf(VA_ARGS);
|
||||
int PS4_SYSV_ABI ps4_vsnprintf(char* s, size_t n, const char* format, VaList* arg);
|
||||
int PS4_SYSV_ABI ps4_puts(const char* s);
|
||||
int PS4_SYSV_ABI ps4_fprintf(FILE* file, VA_ARGS);
|
||||
FILE* PS4_SYSV_ABI ps4_fopen(const char* filename, const char* mode);
|
||||
int PS4_SYSV_ABI ps4_fseek(FILE* stream, long int offset, int origin);
|
||||
long PS4_SYSV_ABI ps4_ftell(FILE* stream);
|
||||
size_t PS4_SYSV_ABI ps4_fread(void* ptr, size_t size, size_t count, FILE* stream);
|
||||
int PS4_SYSV_ABI ps4_fclose(FILE* stream);
|
||||
|
||||
} // namespace Core::Libraries::LibC
|
||||
|
Loading…
Reference in New Issue
Block a user