From 142b7e048b5243c42cf8b24f244187cb848ea7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 29 Dec 2019 14:01:39 +0100 Subject: [PATCH] IOS/FS: Actually implement SetMetadata --- Source/Core/Core/IOS/FS/HostBackend/FS.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index 1a364436af..fea5d16261 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -610,10 +610,30 @@ Result HostFileSystem::GetMetadata(Uid uid, Gid gid, const std::string } ResultCode HostFileSystem::SetMetadata(Uid caller_uid, const std::string& path, Uid uid, Gid gid, - FileAttribute, Modes) + FileAttribute attr, Modes modes) { if (!IsValidPath(path)) return ResultCode::Invalid; + + FstEntry* entry = GetFstEntryForPath(path); + if (!entry) + return ResultCode::NotFound; + + if (caller_uid != 0 && caller_uid != entry->data.uid) + return ResultCode::AccessDenied; + if (caller_uid != 0 && uid != entry->data.uid) + return ResultCode::AccessDenied; + + const bool is_empty = File::GetSize(BuildFilename(path)) == 0; + if (entry->data.uid != uid && entry->data.is_file && !is_empty) + return ResultCode::FileNotEmpty; + + entry->data.gid = gid; + entry->data.uid = uid; + entry->data.attribute = attr; + entry->data.modes = modes; + SaveFst(); + return ResultCode::Success; }