diff options
| author | Léo Lam <leo@leolam.fr> | 2019-12-29 14:01:39 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2020-01-25 17:53:35 +0100 |
| commit | 142b7e048b5243c42cf8b24f244187cb848ea7b5 (patch) | |
| tree | feb3c899c64979facaad908b4d137378bb22e8e8 /Source/Core | |
| parent | e4dd582d1d69285da40a5524702e8cd231fbc24a (diff) | |
IOS/FS: Actually implement SetMetadata
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/IOS/FS/HostBackend/FS.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
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<Metadata> 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; } |
