Replace raw pointer in BsaArchive with unique_ptr

pull/541/head
Azdul 6 years ago
parent e502819246
commit caa0487c6a

@ -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…
Cancel
Save