mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Replace raw pointer in BsaArchive with unique_ptr
This commit is contained in:
parent
e502819246
commit
caa0487c6a
2 changed files with 4 additions and 7 deletions
|
@ -7,15 +7,13 @@ namespace VFS
|
|||
|
||||
BsaArchive::BsaArchive(const std::string &filename)
|
||||
{
|
||||
mFile = nullptr;
|
||||
|
||||
Bsa::BsaVersion bsaVersion = Bsa::TES4BSAFile::detectVersion(filename);
|
||||
|
||||
if (bsaVersion == Bsa::BSAVER_TES4PLUS) {
|
||||
mFile = new Bsa::TES4BSAFile();
|
||||
mFile = std::make_unique<Bsa::TES4BSAFile>();
|
||||
}
|
||||
else {
|
||||
mFile = new Bsa::BSAFile();
|
||||
mFile = std::make_unique<Bsa::BSAFile>();
|
||||
}
|
||||
|
||||
mFile->open(filename);
|
||||
|
@ -23,12 +21,11 @@ BsaArchive::BsaArchive(const std::string &filename)
|
|||
const Bsa::BSAFile::FileList &filelist = mFile->getList();
|
||||
for(Bsa::BSAFile::FileList::const_iterator it = filelist.begin();it != filelist.end();++it)
|
||||
{
|
||||
mResources.push_back(BsaArchiveFile(&*it, mFile));
|
||||
mResources.push_back(BsaArchiveFile(&*it, mFile.get()));
|
||||
}
|
||||
}
|
||||
|
||||
BsaArchive::~BsaArchive() {
|
||||
delete mFile;
|
||||
}
|
||||
|
||||
void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace VFS
|
|||
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
||||
|
||||
private:
|
||||
Bsa::BSAFile* mFile;
|
||||
std::unique_ptr<Bsa::BSAFile> mFile;
|
||||
std::vector<BsaArchiveFile> mResources;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue