Archives: Made the Format function more generic.

This commit is contained in:
Subv 2015-02-07 13:31:34 -05:00 committed by Yuri Kunde Schlesner
parent 071663e074
commit 1bbf0567b1
3 changed files with 10 additions and 9 deletions

View file

@ -383,15 +383,13 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a
return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory)); return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory));
} }
ResultCode FormatSaveData() { ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) {
// Do not create the archive again if it already exists auto archive_itr = id_code_map.find(id_code);
auto archive_itr = id_code_map.find(ArchiveIdCode::SaveData);
if (archive_itr == id_code_map.end()) { if (archive_itr == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
} }
// Use an empty path, we do not use it when formatting the savedata return archive_itr->second->Format(path);
return archive_itr->second->Format(FileSys::Path());
} }
ResultCode CreateExtSaveData(u32 high, u32 low) { ResultCode CreateExtSaveData(u32 high, u32 low) {

View file

@ -162,10 +162,13 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a
const FileSys::Path& path); const FileSys::Path& path);
/** /**
* Creates a blank SaveData archive. * Erases the contents of the physical folder that contains the archive
* identified by the specified id code and path
* @param id_code The id of the archive to format
* @param path The path to the archive, if relevant.
* @return ResultCode 0 on success or the corresponding code on error * @return ResultCode 0 on success or the corresponding code on error
*/ */
ResultCode FormatSaveData(); ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path = FileSys::Path());
/** /**
* Creates a blank SharedExtSaveData archive for the specified extdata ID * Creates a blank SharedExtSaveData archive for the specified extdata ID

View file

@ -468,7 +468,7 @@ static void FormatSaveData(Service::Interface* self) {
return; return;
} }
cmd_buff[1] = FormatSaveData().raw; cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData).raw;
} }
/** /**
@ -484,7 +484,7 @@ static void FormatThisUserSaveData(Service::Interface* self) {
// TODO(Subv): Find out what the inputs and outputs of this function are // TODO(Subv): Find out what the inputs and outputs of this function are
cmd_buff[1] = FormatSaveData().raw; cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData).raw;
} }
static void CreateExtSaveData(Service::Interface* self) { static void CreateExtSaveData(Service::Interface* self) {