Move sceKernelUnlink

Will deal with this one later, was just annoyed by how it's location doesn't align with the export order.
This commit is contained in:
Stephen Miller 2025-02-17 18:29:40 -06:00
parent bb75754245
commit 3e7d1092f2

View file

@ -245,37 +245,6 @@ s64 PS4_SYSV_ABI sceKernelWrite(s32 fd, const void* buf, size_t nbytes) {
return result;
}
int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
if (path == nullptr) {
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
bool ro = false;
const auto host_path = mnt->GetHostPath(path, &ro);
if (host_path.empty()) {
return ORBIS_KERNEL_ERROR_EACCES;
}
if (ro) {
return ORBIS_KERNEL_ERROR_EROFS;
}
if (std::filesystem::is_directory(host_path)) {
return ORBIS_KERNEL_ERROR_EPERM;
}
auto* file = h->GetFile(host_path);
if (file != nullptr) {
file->f.Unlink();
}
LOG_INFO(Kernel_Fs, "Unlinked {}", path);
return ORBIS_OK;
}
size_t ReadFile(Common::FS::IOFile& file, void* buf, size_t nbytes) {
const auto* memory = Core::Memory::Instance();
// Invalidate up to the actual number of bytes that could be read.
@ -792,6 +761,37 @@ s32 PS4_SYSV_ABI sceKernelRename(const char* from, const char* to) {
return ORBIS_OK;
}
int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
if (path == nullptr) {
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
bool ro = false;
const auto host_path = mnt->GetHostPath(path, &ro);
if (host_path.empty()) {
return ORBIS_KERNEL_ERROR_EACCES;
}
if (ro) {
return ORBIS_KERNEL_ERROR_EROFS;
}
if (std::filesystem::is_directory(host_path)) {
return ORBIS_KERNEL_ERROR_EPERM;
}
auto* file = h->GetFile(host_path);
if (file != nullptr) {
file->f.Unlink();
}
LOG_INFO(Kernel_Fs, "Unlinked {}", path);
return ORBIS_OK;
}
void RegisterFileSystem(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1, open);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open);