Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SystemSaveData::CreateDirectory #287

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/fs/archive_system_save_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SystemSaveDataArchive : public ArchiveBase {

std::string name() override { return "SystemSaveData"; }

//HorizonResult createDirectory(const FSPath& path) override;
HorizonResult createDirectory(const FSPath& path) override;
HorizonResult createFile(const FSPath& path, u64 size) override;
HorizonResult deleteFile(const FSPath& path) override;

Expand Down
24 changes: 24 additions & 0 deletions src/core/fs/archive_system_save_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ HorizonResult SystemSaveDataArchive::createFile(const FSPath& path, u64 size) {
return Result::Success;
}

HorizonResult SystemSaveDataArchive::createDirectory(const FSPath& path) {
if (path.type == PathType::UTF16) {
if (!isPathSafe<PathType::UTF16>(path)) {
Helpers::panic("Unsafe path in SystemSaveData::OpenFile");
}

fs::path p = IOFile::getAppData() / ".." / "SharedFiles" / "SystemSaveData";
p += fs::path(path.utf16_string).make_preferred();

if (fs::is_directory(p)) {
return Result::FS::AlreadyExists;
}

if (fs::is_regular_file(p)) {
Helpers::panic("File path passed to SystemSaveData::CreateDirectory");
}

bool success = fs::create_directory(p);
return success ? Result::Success : Result::FS::UnexpectedFileOrDir;
} else {
Helpers::panic("Unimplemented SystemSaveData::CreateDirectory");
}
}


HorizonResult SystemSaveDataArchive::deleteFile(const FSPath& path) {
if (path.type == PathType::UTF16) {
Expand Down
Loading