Improve error checks on posix_unlink

Just because a file isn't opened doesn't mean the file doesn't exist.
Fixes the error returned if host_path.empty(), and removes the error return for when GetFile fails.
This commit is contained in:
Stephen Miller 2025-02-20 18:50:04 -06:00
parent 6d19a8ec0c
commit 81e9a547ec

View File

@ -933,7 +933,7 @@ s32 PS4_SYSV_ABI posix_unlink(const char* path) {
bool ro = false;
const auto host_path = mnt->GetHostPath(path, &ro);
if (host_path.empty()) {
*__Error() = POSIX_EACCES;
*__Error() = POSIX_ENOENT;
return -1;
}
@ -949,8 +949,8 @@ s32 PS4_SYSV_ABI posix_unlink(const char* path) {
auto* file = h->GetFile(host_path);
if (file == nullptr) {
*__Error() = POSIX_ENOENT;
return -1;
// Cannot unlink an unopened file
return ORBIS_OK;
}
file->f.Unlink();