[FS] Add CreateDirectory for MK7 (hopefully not broken)

This commit is contained in:
wheremyfoodat 2023-04-26 03:04:45 +03:00
parent 1c3f3f8da9
commit f39069813a
5 changed files with 58 additions and 1 deletions

View file

@ -9,6 +9,30 @@ FSResult SaveDataArchive::createFile(const FSPath& path, u64 size) {
return FSResult::Success;
}
FSResult SaveDataArchive::createDirectory(const FSPath& path) {
if (!cartHasSaveData()) {
printf("Tried to create SaveData dir without save data\n");
return FSResult::FileNotFound;
}
if (path.type == PathType::UTF16) {
if (!isPathSafe<PathType::UTF16>(path))
Helpers::panic("Unsafe path in SaveData::OpenFile");
fs::path p = IOFile::getAppData() / "SaveData";
p += fs::path(path.utf16_string).make_preferred();
if (fs::is_directory(p))
return FSResult::AlreadyExists;
if (fs::is_regular_file(p)) {
Helpers::panic("File path passed to SaveData::CreateDirectory");
}
bool success = fs::create_directory(p);
return success ? FSResult::Success : FSResult::UnexpectedFileOrDir;
}
}
FSResult SaveDataArchive::deleteFile(const FSPath& path) {
Helpers::panic("[SaveData] Unimplemented DeleteFile");
return FSResult::Success;