mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-04-22 12:34:47 +00:00
fs: prefer make_unique to operator new
This commit is contained in:
parent
c4f93dbed2
commit
861279d398
12 changed files with 21 additions and 21 deletions
|
@ -170,7 +170,7 @@ namespace ams::fs {
|
|||
FsFile f;
|
||||
R_TRY(fsFsOpenFile(std::addressof(this->base_fs), sf_path.str, mode, &f));
|
||||
|
||||
std::unique_ptr<RemoteFile> file(new RemoteFile(f));
|
||||
auto file = std::make_unique<RemoteFile>(f);
|
||||
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInNew());
|
||||
|
||||
*out_file = std::move(file);
|
||||
|
@ -184,7 +184,7 @@ namespace ams::fs {
|
|||
FsDir d;
|
||||
R_TRY(fsFsOpenDirectory(std::addressof(this->base_fs), sf_path.str, mode, &d));
|
||||
|
||||
std::unique_ptr<RemoteDirectory> dir(new RemoteDirectory(d));
|
||||
auto dir = std::make_unique<RemoteDirectory>(d);
|
||||
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInNew());
|
||||
|
||||
*out_dir = std::move(dir);
|
||||
|
|
|
@ -54,11 +54,11 @@ namespace ams::fs {
|
|||
R_TRY(fsOpenBisFileSystem(std::addressof(fs), static_cast<::FsBisPartitionId>(id), ""));
|
||||
|
||||
/* Allocate a new mountname generator. */
|
||||
std::unique_ptr<BisCommonMountNameGenerator> generator(new BisCommonMountNameGenerator(id));
|
||||
auto generator = std::make_unique<BisCommonMountNameGenerator>(id);
|
||||
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInBisA());
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
std::unique_ptr<fsa::IFileSystem> fsa(new RemoteFileSystem(fs));
|
||||
auto fsa = std::make_unique<RemoteFileSystem>(fs);
|
||||
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInBisB());
|
||||
|
||||
/* Register. */
|
||||
|
@ -112,7 +112,7 @@ namespace ams::fs {
|
|||
R_TRY(fsOpenBisStorage(std::addressof(s), static_cast<::FsBisPartitionId>(id)));
|
||||
|
||||
/* Allocate a new storage wrapper. */
|
||||
std::unique_ptr<fs::IStorage> storage(new RemoteStorage(s));
|
||||
auto storage = std::make_unique<RemoteStorage>(s);
|
||||
R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInBisC());
|
||||
|
||||
*out = std::move(storage);
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace ams::fs {
|
|||
R_TRY(fsldrOpenCodeFileSystem(program_id.value, sf_path.str, std::addressof(fs)));
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
std::unique_ptr<fsa::IFileSystem> fsa(new RemoteFileSystem(fs));
|
||||
auto fsa = std::make_unique<RemoteFileSystem>(fs);
|
||||
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInCodeA());
|
||||
|
||||
/* Register. */
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace ams::fs {
|
|||
R_TRY(fsOpenFileSystemWithId(std::addressof(fs), id, static_cast<::FsFileSystemType>(type), path));
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
std::unique_ptr<fsa::IFileSystem> fsa(new RemoteFileSystem(fs));
|
||||
auto fsa = std::make_unique<RemoteFileSystem>(fs);
|
||||
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInContentA());
|
||||
|
||||
/* Register. */
|
||||
|
|
|
@ -79,11 +79,11 @@ namespace ams::fs {
|
|||
}
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
std::unique_ptr<fsa::IFileSystem> fsa(new RemoteFileSystem(fs));
|
||||
auto fsa = std::make_unique<RemoteFileSystem>(fs);
|
||||
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInContentStorageA());
|
||||
|
||||
/* Allocate a new mountname generator. */
|
||||
std::unique_ptr<ContentStorageCommonMountNameGenerator> generator(new ContentStorageCommonMountNameGenerator(id));
|
||||
auto generator = std::make_unique<ContentStorageCommonMountNameGenerator>(id);
|
||||
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInContentStorageB());
|
||||
|
||||
/* Register. */
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ams::fs::impl {
|
|||
R_CONVERT(ncm::ResultContentMetaNotFound, fs::ResultTargetNotFound());
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
std::unique_ptr<fs::IStorage> storage(new RemoteStorage(s));
|
||||
auto storage = std::make_unique<RemoteStorage>(s);
|
||||
R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInDataA());
|
||||
|
||||
*out = std::move(storage);
|
||||
|
@ -38,7 +38,7 @@ namespace ams::fs::impl {
|
|||
std::unique_ptr<fs::IStorage> storage;
|
||||
R_TRY(OpenDataStorageByDataId(std::addressof(storage), data_id, storage_id));
|
||||
|
||||
std::unique_ptr<RomFsFileSystem> fs(new RomFsFileSystem());
|
||||
auto fs = std::make_unique<RomFsFileSystem>();
|
||||
R_UNLESS(fs != nullptr, fs::ResultAllocationFailureInDataB());
|
||||
R_TRY(fs->Initialize(std::move(storage), cache_buffer, cache_size, use_cache));
|
||||
|
||||
|
|
|
@ -73,11 +73,11 @@ namespace ams::fs {
|
|||
R_TRY(fsOpenGameCardFileSystem(std::addressof(fs), std::addressof(_hnd), static_cast<::FsGameCardPartition>(partition)));
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
std::unique_ptr<fsa::IFileSystem> fsa(new RemoteFileSystem(fs));
|
||||
auto fsa = std::make_unique<RemoteFileSystem>(fs);
|
||||
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInGameCardC());
|
||||
|
||||
/* Allocate a new mountname generator. */
|
||||
std::unique_ptr<GameCardCommonMountNameGenerator> generator(new GameCardCommonMountNameGenerator(handle, partition));
|
||||
auto generator = std::make_unique<GameCardCommonMountNameGenerator>(handle, partition);
|
||||
R_UNLESS(generator != nullptr, fs::ResultAllocationFailureInGameCardD());
|
||||
|
||||
/* Register. */
|
||||
|
|
|
@ -486,7 +486,7 @@ namespace ams::fs {
|
|||
RomFileTable::FileInfo file_info;
|
||||
R_TRY(this->GetFileInfo(std::addressof(file_info), path));
|
||||
|
||||
std::unique_ptr<RomFsFile> file(new RomFsFile(this, this->entry_size + file_info.offset.Get(), this->entry_size + file_info.offset.Get() + file_info.size.Get()));
|
||||
auto file = std::make_unique<RomFsFile>(this, this->entry_size + file_info.offset.Get(), this->entry_size + file_info.offset.Get() + file_info.size.Get());
|
||||
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB());
|
||||
|
||||
*out_file = std::move(file);
|
||||
|
@ -503,7 +503,7 @@ namespace ams::fs {
|
|||
R_CONVERT(fs::ResultDbmInvalidOperation, fs::ResultPathNotFound())
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
std::unique_ptr<RomFsDirectory> dir(new RomFsDirectory(this, find, mode));
|
||||
auto dir = std::make_unique<RomFsDirectory>(this, find, mode);
|
||||
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInRomFsFileSystemC());
|
||||
|
||||
*out_dir = std::move(dir);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ams::fs {
|
|||
R_TRY(fsOpenSdCardFileSystem(std::addressof(fs)));
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
std::unique_ptr<fsa::IFileSystem> fsa(new RemoteFileSystem(fs));
|
||||
auto fsa = std::make_unique<RemoteFileSystem>(fs);
|
||||
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInSdCardA());
|
||||
|
||||
/* Register. */
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace ams::fs {
|
|||
R_TRY(fsOpenSaveDataFileSystemBySystemSaveDataId(std::addressof(fs), static_cast<::FsSaveDataSpaceId>(space_id), reinterpret_cast<const ::FsSaveDataAttribute *>(std::addressof(attribute))));
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
std::unique_ptr<fsa::IFileSystem> fsa(new RemoteFileSystem(fs));
|
||||
auto fsa = std::make_unique<RemoteFileSystem>(fs);
|
||||
R_UNLESS(fsa != nullptr, fs::ResultAllocationFailureInSystemSaveDataA());
|
||||
|
||||
/* Register. */
|
||||
|
|
|
@ -20,21 +20,21 @@
|
|||
namespace ams::fs::fsa {
|
||||
|
||||
Result Register(const char *name, std::unique_ptr<IFileSystem> &&fs) {
|
||||
std::unique_ptr<impl::FileSystemAccessor> accessor(new impl::FileSystemAccessor(name, std::move(fs)));
|
||||
auto accessor = std::make_unique<impl::FileSystemAccessor>(name, std::move(fs));
|
||||
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInRegisterA());
|
||||
|
||||
return impl::Register(std::move(accessor));
|
||||
}
|
||||
|
||||
Result Register(const char *name, std::unique_ptr<IFileSystem> &&fs, std::unique_ptr<ICommonMountNameGenerator> &&generator) {
|
||||
std::unique_ptr<impl::FileSystemAccessor> accessor(new impl::FileSystemAccessor(name, std::move(fs), std::move(generator)));
|
||||
auto accessor = std::make_unique<impl::FileSystemAccessor>(name, std::move(fs), std::move(generator));
|
||||
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInRegisterB());
|
||||
|
||||
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) {
|
||||
std::unique_ptr<impl::FileSystemAccessor> accessor(new impl::FileSystemAccessor(name, std::move(fs), std::move(generator)));
|
||||
auto accessor = std::make_unique<impl::FileSystemAccessor>(name, std::move(fs), std::move(generator));
|
||||
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInRegisterB());
|
||||
|
||||
accessor->SetFileDataCacheAttachable(use_data_cache);
|
||||
|
|
|
@ -169,7 +169,7 @@ namespace ams::fs {
|
|||
Result OpenFile(FileHandle *out, std::unique_ptr<fsa::IFile> &&file, int mode) {
|
||||
R_UNLESS(out != nullptr, fs::ResultNullptrArgument());
|
||||
|
||||
std::unique_ptr<impl::FileAccessor> file_accessor(new impl::FileAccessor(std::move(file), nullptr, static_cast<OpenMode>(mode)));
|
||||
auto file_accessor = std::make_unique<impl::FileAccessor>(std::move(file), nullptr, static_cast<OpenMode>(mode));
|
||||
R_UNLESS(file_accessor != nullptr, fs::ResultAllocationFailureInNew());
|
||||
out->handle = file_accessor.release();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue