mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 13:18:50 +00:00
DiscIO: Make factory methods return unique_ptrs
Rather than rely on the developer to do the right thing, just make the default behavior safely deallocate resources. If shared semantics are ever needed in the future, the constructor that takes a unique_ptr for shared_ptr can be used.
This commit is contained in:
parent
a0ac2b8673
commit
edbbf493f8
22 changed files with 204 additions and 231 deletions
|
@ -2,6 +2,7 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "DiscIO/FileBlob.h"
|
||||
|
||||
|
@ -14,13 +15,13 @@ PlainFileReader::PlainFileReader(std::FILE* file)
|
|||
m_size = m_file.GetSize();
|
||||
}
|
||||
|
||||
PlainFileReader* PlainFileReader::Create(const std::string& filename)
|
||||
std::unique_ptr<PlainFileReader> PlainFileReader::Create(const std::string& filename)
|
||||
{
|
||||
File::IOFile f(filename, "rb");
|
||||
if (f)
|
||||
return new PlainFileReader(f.ReleaseHandle());
|
||||
else
|
||||
return nullptr;
|
||||
return std::unique_ptr<PlainFileReader>(new PlainFileReader(f.ReleaseHandle()));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue