sprofile: fully reimplement sprof:bg + sprof:sp

This commit is contained in:
Michael Scire
2021-09-16 16:14:26 -07:00
committed by SciresM
parent ae54ec5981
commit 89541c8042
18 changed files with 872 additions and 59 deletions

View File

@@ -54,4 +54,31 @@ namespace ams::sprofile::srv {
return fs::WriteFile(file, 0, src, size, fs::WriteOption::Flush);
}
Result MoveFile(const char *src_path, const char *dst_path) {
/* Require that the source path is a file. */
{
fs::DirectoryEntryType type;
R_ABORT_UNLESS(fs::GetEntryType(std::addressof(type), src_path));
AMS_ABORT_UNLESS(type == fs::DirectoryEntryType_File);
}
/* Delete the destination file. */
R_TRY_CATCH(fs::DeleteFile(dst_path)) {
R_CATCH(fs::ResultPathNotFound) { /* It's okay if the dst path doesn't exist. */ }
} R_END_TRY_CATCH;
/* Move the source file to the destination file. */
R_TRY(fs::RenameFile(src_path, dst_path));
return ResultSuccess();
}
Result EnsureDirectory(const char *path) {
R_TRY_CATCH(fs::CreateDirectory(path)) {
R_CATCH(fs::ResultPathAlreadyExists) { /* It's okay if the directory already exists. */ }
} R_END_TRY_CATCH;
return ResultSuccess();
}
}