fs: revise allocation-fail result names

This commit is contained in:
Michael Scire 2022-03-13 01:51:42 -08:00 committed by SciresM
parent 11e4bed199
commit e13b81aa9e
50 changed files with 304 additions and 218 deletions

View file

@ -39,7 +39,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInApplicationA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInApplicationA());
/* Register. */
R_RETURN(fsa::Register(name, std::move(fsa)));

View file

@ -66,11 +66,11 @@ namespace ams::fs {
/* Allocate a new mountname generator. */
auto generator = std::make_unique<BisCommonMountNameGenerator>(id);
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInBisA());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedInBisA());
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInBisB());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInBisB());
/* Register. */
R_RETURN(fsa::Register(name, std::move(fsa), std::move(generator)));
@ -122,7 +122,7 @@ namespace ams::fs {
/* Allocate a new storage wrapper. */
auto storage = std::make_unique<impl::StorageServiceObjectAdapter>(std::move(s));
AMS_FS_R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInBisC());
AMS_FS_R_UNLESS(storage != nullptr, fs::ResultAllocationMemoryFailedInBisC());
*out = std::move(storage);
R_SUCCEED();

View file

@ -83,7 +83,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInCodeA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInCodeA());
*out = std::move(fsa);
R_SUCCEED();
@ -97,7 +97,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInCodeA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInCodeA());
*out = std::move(fsa);
R_SUCCEED();
@ -135,11 +135,11 @@ namespace ams::fs {
/* Create a file storage for the program's package. */
auto package_storage = std::make_shared<FileStorage>(std::move(package_file));
R_UNLESS(package_storage != nullptr, fs::ResultAllocationFailureInCodeA());
R_UNLESS(package_storage != nullptr, fs::ResultAllocationMemoryFailedInCodeA());
/* Create a partition filesystem. */
auto package_fs = std::make_unique<fssystem::PartitionFileSystem>();
R_UNLESS(package_fs != nullptr, fs::ResultAllocationFailureInCodeA());
R_UNLESS(package_fs != nullptr, fs::ResultAllocationMemoryFailedInCodeA());
/* Initialize the partition filesystem. */
R_TRY(package_fs->Initialize(package_storage));
@ -178,7 +178,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_shared<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInCodeA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInCodeA());
*out = std::move(fsa);
R_SUCCEED();
@ -427,7 +427,7 @@ namespace ams::fs {
/* Create an AtmosphereCodeFileSystem. */
auto ams_code_fs = std::make_unique<AtmosphereCodeFileSystem>();
R_UNLESS(ams_code_fs != nullptr, fs::ResultAllocationFailureInCodeA());
R_UNLESS(ams_code_fs != nullptr, fs::ResultAllocationMemoryFailedInCodeA());
/* Initialize the code file system. */
R_TRY(ams_code_fs->Initialize(out, path, program_id, is_hbl, is_specific));
@ -462,7 +462,7 @@ namespace ams::fs {
/* Create a wrapper fs. */
auto wrap_fsa = std::make_unique<SdCardRedirectionCodeFileSystem>(std::move(fsa), program_id, false);
R_UNLESS(wrap_fsa != nullptr, fs::ResultAllocationFailureInCodeA());
R_UNLESS(wrap_fsa != nullptr, fs::ResultAllocationMemoryFailedInCodeA());
/* Register. */
R_RETURN(fsa::Register(name, std::move(wrap_fsa)));

View file

@ -50,7 +50,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInContentA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInContentA());
/* Register. */
R_RETURN(fsa::Register(name, std::move(fsa)));

View file

@ -90,11 +90,11 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInContentStorageA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInContentStorageA());
/* Allocate a new mountname generator. */
auto generator = std::make_unique<ContentStorageCommonMountNameGenerator>(id);
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInContentStorageB());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedInContentStorageB());
/* Register. */
R_RETURN(fsa::Register(name, std::move(fsa), std::move(generator)));

View file

@ -36,7 +36,7 @@ namespace ams::fs::impl {
AMS_FS_R_TRY(OpenDataStorageByDataIdImpl(std::addressof(s), data_id, storage_id));
auto storage = std::make_unique<impl::StorageServiceObjectAdapter>(std::move(s));
R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInDataA());
R_UNLESS(storage != nullptr, fs::ResultAllocationMemoryFailedInDataA());
*out = std::move(storage);
return ResultSuccess();
@ -47,7 +47,7 @@ namespace ams::fs::impl {
R_TRY(OpenDataStorageByDataId(std::addressof(storage), data_id, storage_id));
auto fs = std::make_unique<RomFsFileSystem>();
R_UNLESS(fs != nullptr, fs::ResultAllocationFailureInDataB());
R_UNLESS(fs != nullptr, fs::ResultAllocationMemoryFailedInDataB());
R_TRY(fs->Initialize(std::move(storage), cache_buffer, cache_size, use_cache));
return fsa::Register(name, std::move(fs), nullptr, use_data_cache, use_path_cache, false);

View file

@ -35,7 +35,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInDeviceSaveDataA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInDeviceSaveDataA());
/* Register. */
return fsa::Register(name, std::move(fsa));

View file

@ -81,11 +81,11 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInGameCardC());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInGameCardC());
/* Allocate a new mountname generator. */
auto generator = std::make_unique<GameCardCommonMountNameGenerator>(handle, partition);
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInGameCardD());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedInGameCardD());
/* Register. */
R_RETURN(fsa::Register(name, std::move(fsa), std::move(generator)));

View file

@ -76,7 +76,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInHostA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInHostA());
/* Set the output. */
*out = std::move(fsa);
@ -95,7 +95,7 @@ namespace ams::fs {
/* Create a new HostCommonMountNameGenerator. */
*out = std::make_unique<HostCommonMountNameGenerator>(path);
R_UNLESS(out->get() != nullptr, fs::ResultAllocationFailureInHostB());
R_UNLESS(out->get() != nullptr, fs::ResultAllocationMemoryFailedInHostB());
R_SUCCEED();
}
@ -191,7 +191,7 @@ namespace ams::fs {
auto register_impl = [&]() -> Result {
/* Allocate a new mountname generator. */
auto generator = std::make_unique<HostRootCommonMountNameGenerator>();
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInHostC());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedInHostC());
/* Register. */
R_RETURN(fsa::Register(impl::HostRootFileSystemMountName, std::move(fsa), std::move(generator)));
@ -219,7 +219,7 @@ namespace ams::fs {
auto register_impl = [&]() -> Result {
/* Allocate a new mountname generator. */
auto generator = std::make_unique<HostRootCommonMountNameGenerator>();
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInHostC());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedInHostC());
/* Register. */
R_RETURN(fsa::Register(impl::HostRootFileSystemMountName, std::move(fsa), std::move(generator)));

View file

@ -32,7 +32,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInImageDirectoryA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInImageDirectoryA());
/* Register. */
R_RETURN(fsa::Register(name, std::move(fsa)));

View file

@ -281,7 +281,7 @@ namespace ams::fs {
constexpr size_t NameBufferSize = fs::EntryNameLengthMax + 1;
char *name_buf = static_cast<char *>(::ams::fs::impl::Allocate(NameBufferSize));
R_UNLESS(name_buf != nullptr, fs::ResultAllocationFailureInRomFsFileSystemE());
R_UNLESS(name_buf != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemE());
ON_SCOPE_EXIT { ::ams::fs::impl::Deallocate(name_buf, NameBufferSize); };
s32 i = 0;
@ -393,10 +393,10 @@ namespace ams::fs {
}
/* Ensure we allocated storages successfully. */
R_UNLESS(m_dir_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA());
R_UNLESS(m_dir_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA());
R_UNLESS(m_file_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA());
R_UNLESS(m_file_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA());
R_UNLESS(m_dir_bucket_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemA());
R_UNLESS(m_dir_entry_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemA());
R_UNLESS(m_file_bucket_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemA());
R_UNLESS(m_file_entry_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemA());
/* Initialize the rom table. */
{
@ -505,7 +505,7 @@ namespace ams::fs {
R_TRY(this->GetFileInfo(std::addressof(file_info), path.GetString()));
auto file = std::make_unique<RomFsFile>(this, m_entry_size + file_info.offset.Get(), m_entry_size + file_info.offset.Get() + file_info.size.Get());
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB());
R_UNLESS(file != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemB());
*out_file = std::move(file);
return ResultSuccess();
@ -521,7 +521,7 @@ namespace ams::fs {
} R_END_TRY_CATCH;
auto dir = std::make_unique<RomFsDirectory>(this, find, mode);
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInRomFsFileSystemC());
R_UNLESS(dir != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemC());
*out_dir = std::move(dir);
return ResultSuccess();

View file

@ -58,12 +58,12 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInSdCardA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInSdCardA());
/* Allocate a new mountname generator. */
/* NOTE: Nintendo does not attach a generator. */
auto generator = std::make_unique<SdCardCommonMountNameGenerator>();
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInSdCardA());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedInSdCardA());
/* Register. */
return fsa::Register(name, std::move(fsa), std::move(generator));
@ -80,7 +80,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_shared<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInSdCardA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInSdCardA());
/* Ensure that the error report directory exists. */
constexpr fs::Path fs_path = fs::MakeConstantPath(AtmosphereErrorReportDirectory);
@ -88,7 +88,7 @@ namespace ams::fs {
/* Create a subdirectory filesystem. */
auto subdir_fs = std::make_unique<fssystem::SubDirectoryFileSystem>(std::move(fsa));
R_UNLESS(subdir_fs != nullptr, fs::ResultAllocationFailureInSdCardA());
R_UNLESS(subdir_fs != nullptr, fs::ResultAllocationMemoryFailedInSdCardA());
R_TRY(subdir_fs->Initialize(fs_path));
/* Register. */
@ -104,7 +104,7 @@ namespace ams::fs {
/* Create an event notifier adapter. */
auto adapter = std::make_unique<impl::EventNotifierObjectAdapter>(std::move(notifier));
AMS_FS_R_UNLESS(adapter != nullptr, fs::ResultAllocationFailureInSdCardB());
AMS_FS_R_UNLESS(adapter != nullptr, fs::ResultAllocationMemoryFailedInSdCardB());
*out = std::move(adapter);
return ResultSuccess();

View file

@ -47,7 +47,7 @@ namespace ams::fs {
/* Allocate a new filesystem wrapper. */
auto fsa = std::make_unique<impl::FileSystemServiceObjectAdapter>(std::move(fs));
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInSystemSaveDataA());
R_UNLESS(fsa != nullptr, fs::ResultAllocationMemoryFailedInSystemSaveDataA());
/* Register. */
return fsa::Register(name, std::move(fsa));

View file

@ -223,7 +223,7 @@ namespace ams::fs::impl {
R_TRY(m_impl->OpenFile(std::addressof(file), normalized_path, mode));
auto accessor = new FileAccessor(std::move(file), this, mode);
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInFileSystemAccessorA());
R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailedInFileSystemAccessorA());
{
std::scoped_lock lk(m_open_list_lock);
@ -251,7 +251,7 @@ namespace ams::fs::impl {
R_TRY(m_impl->OpenDirectory(std::addressof(dir), normalized_path, mode));
auto accessor = new DirectoryAccessor(std::move(dir), *this);
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInFileSystemAccessorB());
R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailedInFileSystemAccessorB());
{
std::scoped_lock lk(m_open_list_lock);

View file

@ -21,21 +21,21 @@ namespace ams::fs::fsa {
Result Register(const char *name, std::unique_ptr<IFileSystem> &&fs) {
auto accessor = std::make_unique<impl::FileSystemAccessor>(name, std::move(fs));
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInRegisterA());
R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailedInRegisterA());
return impl::Register(std::move(accessor));
}
Result Register(const char *name, std::unique_ptr<IFileSystem> &&fs, std::unique_ptr<ICommonMountNameGenerator> &&generator) {
auto accessor = std::make_unique<impl::FileSystemAccessor>(name, std::move(fs), std::move(generator));
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInRegisterB());
R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailedInRegisterB());
return impl::Register(std::move(accessor));
}
Result Register(const char *name, std::unique_ptr<IFileSystem> &&fs, std::unique_ptr<ICommonMountNameGenerator> &&generator, bool use_data_cache, bool use_path_cache, bool support_multi_commit) {
auto accessor = std::make_unique<impl::FileSystemAccessor>(name, std::move(fs), std::move(generator));
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInRegisterB());
R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailedInRegisterB());
accessor->SetFileDataCacheAttachable(use_data_cache);
accessor->SetPathBasedFileDataCacheAttachable(use_path_cache);

View file

@ -201,7 +201,7 @@ namespace ams::fs {
AMS_FS_R_UNLESS(out != nullptr, fs::ResultNullptrArgument());
auto file_accessor = std::make_unique<impl::FileAccessor>(std::move(file), nullptr, static_cast<OpenMode>(mode));
AMS_FS_R_UNLESS(file_accessor != nullptr, fs::ResultAllocationFailureInNew());
AMS_FS_R_UNLESS(file_accessor != nullptr, fs::ResultAllocationMemoryFailedNew());
out->handle = file_accessor.release();
R_SUCCEED();

View file

@ -127,7 +127,7 @@ namespace ams::fs::impl {
/* Create the output fsa file. */
out_file->reset(new FileServiceObjectAdapter(std::move(file)));
R_UNLESS(out_file != nullptr, fs::ResultAllocationFailureInNew());
R_UNLESS(out_file != nullptr, fs::ResultAllocationMemoryFailedNew());
R_SUCCEED();
}
@ -143,7 +143,7 @@ namespace ams::fs::impl {
/* Create the output fsa directory. */
out_dir->reset(new DirectoryServiceObjectAdapter(std::move(dir)));
R_UNLESS(out_dir != nullptr, fs::ResultAllocationFailureInNew());
R_UNLESS(out_dir != nullptr, fs::ResultAllocationMemoryFailedNew());
R_SUCCEED();
}