diff --git a/core/libs/prx/libkernel/File/src/Stdio.cpp b/core/libs/prx/libkernel/File/src/Stdio.cpp index ffa1d9a4b..027aa1185 100644 --- a/core/libs/prx/libkernel/File/src/Stdio.cpp +++ b/core/libs/prx/libkernel/File/src/Stdio.cpp @@ -559,6 +559,10 @@ int APS5_VABI open_nid_postfix(const char* path, int flags, int mode) { return PosixResult(sceKernelOpen(path, flags, static_cast(mode))); } +int APS5_VABI creat_nid_postfix(const char* path, int mode) { + return open_nid_postfix(path, SCE_KERNEL_O_WRONLY | SCE_KERNEL_O_CREAT | SCE_KERNEL_O_TRUNC, mode); +} + int APS5_VABI _open_nid_postfix(const char* path, int flags, ...) { int mode = 0; if (flags & SCE_KERNEL_O_CREAT) { diff --git a/core/libs/tests/GuestFilesystem.cpp b/core/libs/tests/GuestFilesystem.cpp index cb9c3cbdc..1a053eb18 100644 --- a/core/libs/tests/GuestFilesystem.cpp +++ b/core/libs/tests/GuestFilesystem.cpp @@ -33,6 +33,7 @@ int APS5_VABI sceKernelFtruncate(int, long long); int APS5_VABI sceKernelTruncate_nid_postfix(const char*, long long); int APS5_VABI sceKernelUtimes_nid_postfix(const char*, const void*); int APS5_VABI open_nid_postfix(const char*, int, int); +int APS5_VABI creat_nid_postfix(const char*, int); int APS5_VABI _open_nid_postfix(const char*, int, ...); int APS5_VABI close_nid_postfix(int); int APS5_VABI flock_nid_postfix(int, int); @@ -113,6 +114,15 @@ int main() { Require(read_nid_postfix(descriptors[0], received, sizeof(received)) == sizeof(received)); Require(std::memcmp(received, payload, sizeof(payload)) == 0); Require(read_nid_postfix(descriptors[0], received, sizeof(received)) == 0); + { + std::filesystem::remove("creat_probe.bin"); + int created = creat_nid_postfix("creat_probe.bin", 0644); + Require(created >= 0 && write_nid_postfix(created, "abc", 3) == 3); + Require(close_nid_postfix(created) == 0 && std::filesystem::file_size("creat_probe.bin") == 3); + created = creat_nid_postfix("creat_probe.bin", 0644); + Require(created >= 0 && close_nid_postfix(created) == 0 && std::filesystem::file_size("creat_probe.bin") == 0); + Require(std::filesystem::remove("creat_probe.bin")); + } Require(close_nid_postfix(descriptors[0]) == 0); const auto root = std::filesystem::path("anyps5-filesystem-test-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));