Kill FileLoader::Reopen()...

Was a bad idea.
This commit is contained in:
Unknown W. Brackets 2014-11-23 14:08:14 -08:00
parent fd2d7406d1
commit b620070fa6
3 changed files with 9 additions and 22 deletions

View File

@ -36,8 +36,6 @@ public:
LocalFileLoader(const std::string &filename);
virtual ~LocalFileLoader();
virtual bool Reopen(const std::string &filename);
virtual bool Exists() override;
virtual bool IsDirectory() override;
virtual s64 FileSize() override;
@ -59,19 +57,11 @@ FileLoader *ConstructFileLoader(const std::string &filename) {
return new LocalFileLoader(filename);
}
LocalFileLoader::LocalFileLoader(const std::string &filename) {
Reopen(filename);
}
bool LocalFileLoader::Reopen(const std::string &filename) {
fd_ = 0;
f_ = nullptr;
filesize_ = 0;
filename_ = filename;
LocalFileLoader::LocalFileLoader(const std::string &filename)
: fd_(0), f_(nullptr), filesize_(0), filename_(filename) {
f_ = File::OpenCFile(filename, "rb");
if (!f_) {
return false;
return;
}
#ifdef ANDROID
@ -87,8 +77,6 @@ bool LocalFileLoader::Reopen(const std::string &filename) {
filesize_ = ftello(f_);
fseek(f_, 0, SEEK_SET);
#endif
return true;
}
LocalFileLoader::~LocalFileLoader() {
@ -295,7 +283,8 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader)
return FILETYPE_UNKNOWN;
}
bool LoadFile(FileLoader *fileLoader, std::string *error_string) {
bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string) {
FileLoader *&fileLoader = *fileLoaderPtr;
// Note that this can modify filename!
switch (Identify_File(fileLoader)) {
case FILETYPE_PSP_PBP_DIRECTORY:
@ -304,7 +293,8 @@ bool LoadFile(FileLoader *fileLoader, std::string *error_string) {
std::string ebootFilename = filename + "/EBOOT.PBP";
// Switch fileLoader to the EBOOT.
fileLoader->Reopen(ebootFilename);
delete fileLoader;
fileLoader = ConstructFileLoader(ebootFilename);
if (fileLoader->Exists()) {
INFO_LOG(LOADER, "File is a PBP in a directory!");

View File

@ -50,9 +50,6 @@ class FileLoader {
public:
virtual ~FileLoader() {}
// Needed when we switch from a directory to a PBP, etc.
virtual bool Reopen(const std::string &filename) = 0;
virtual bool Exists() = 0;
virtual bool IsDirectory() = 0;
virtual s64 FileSize() = 0;
@ -85,4 +82,4 @@ FileLoader *ConstructFileLoader(const std::string &filename);
IdentifiedFileType Identify_File(FileLoader *fileLoader);
// Can modify the string filename, as it calls IdentifyFile above.
bool LoadFile(FileLoader *fileLoader, std::string *error_string);
bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string);

View File

@ -220,7 +220,7 @@ void CPU_Init() {
// TODO: Check Game INI here for settings, patches and cheats, and modify coreParameter accordingly
// Why did we check for CORE_POWERDOWN here?
if (!LoadFile(loadedFile, &coreParameter.errorString)) {
if (!LoadFile(&loadedFile, &coreParameter.errorString)) {
CPU_Shutdown();
coreParameter.fileToStart = "";
CPU_SetState(CPU_THREAD_NOT_RUNNING);