Limit time GameInfo file loaders are kept open.
This commit is contained in:
parent
90093faffc
commit
2d0bc5eeee
2 changed files with 34 additions and 9 deletions
|
@ -54,7 +54,7 @@ bool GameInfo::DeleteGame() {
|
||||||
case FILETYPE_PSP_ISO_NP:
|
case FILETYPE_PSP_ISO_NP:
|
||||||
{
|
{
|
||||||
// Just delete the one file (TODO: handle two-disk games as well somehow).
|
// Just delete the one file (TODO: handle two-disk games as well somehow).
|
||||||
const char *fileToRemove = fileLoader->Path().c_str();
|
const char *fileToRemove = filePath_.c_str();
|
||||||
deleteFile(fileToRemove);
|
deleteFile(fileToRemove);
|
||||||
auto i = std::find(g_Config.recentIsos.begin(), g_Config.recentIsos.end(), fileToRemove);
|
auto i = std::find(g_Config.recentIsos.begin(), g_Config.recentIsos.end(), fileToRemove);
|
||||||
if (i != g_Config.recentIsos.end()) {
|
if (i != g_Config.recentIsos.end()) {
|
||||||
|
@ -66,7 +66,7 @@ bool GameInfo::DeleteGame() {
|
||||||
{
|
{
|
||||||
// TODO: This could be handled by Core/Util/GameManager too somehow.
|
// TODO: This could be handled by Core/Util/GameManager too somehow.
|
||||||
|
|
||||||
const char *directoryToRemove = fileLoader->Path().c_str();
|
const char *directoryToRemove = filePath_.c_str();
|
||||||
INFO_LOG(HLE, "Deleting %s", directoryToRemove);
|
INFO_LOG(HLE, "Deleting %s", directoryToRemove);
|
||||||
if (!File::DeleteDirRecursively(directoryToRemove)) {
|
if (!File::DeleteDirRecursively(directoryToRemove)) {
|
||||||
ERROR_LOG(HLE, "Failed to delete file");
|
ERROR_LOG(HLE, "Failed to delete file");
|
||||||
|
@ -77,7 +77,7 @@ bool GameInfo::DeleteGame() {
|
||||||
}
|
}
|
||||||
case FILETYPE_PSP_ELF:
|
case FILETYPE_PSP_ELF:
|
||||||
{
|
{
|
||||||
const char *fileToRemove = fileLoader->Path().c_str();
|
const char *fileToRemove = filePath_.c_str();
|
||||||
deleteFile(fileToRemove);
|
deleteFile(fileToRemove);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ u64 GameInfo::GetGameSizeInBytes() {
|
||||||
// TODO: Need to recurse here.
|
// TODO: Need to recurse here.
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return fileLoader->FileSize();
|
return GetFileLoader()->FileSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +165,26 @@ u64 GameInfo::GetInstallDataSizeInBytes() {
|
||||||
return totalSize;
|
return totalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameInfo::LoadFromPath(const std::string &gamePath) {
|
||||||
|
delete fileLoader;
|
||||||
|
fileLoader = ConstructFileLoader(gamePath);
|
||||||
|
filePath_ = gamePath;
|
||||||
|
|
||||||
|
return fileLoader->Exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileLoader *GameInfo::GetFileLoader() {
|
||||||
|
if (!fileLoader) {
|
||||||
|
fileLoader = ConstructFileLoader(filePath_);
|
||||||
|
}
|
||||||
|
return fileLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameInfo::DisposeFileLoader() {
|
||||||
|
delete fileLoader;
|
||||||
|
fileLoader = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool GameInfo::DeleteAllSaveData() {
|
bool GameInfo::DeleteAllSaveData() {
|
||||||
std::vector<std::string> saveDataDir = GetSaveDataDirectories();
|
std::vector<std::string> saveDataDir = GetSaveDataDirectories();
|
||||||
for (size_t j = 0; j < saveDataDir.size(); j++) {
|
for (size_t j = 0; j < saveDataDir.size(); j++) {
|
||||||
|
@ -250,14 +270,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void run() {
|
virtual void run() {
|
||||||
delete info_->fileLoader;
|
if (!info_->LoadFromPath(gamePath_))
|
||||||
info_->fileLoader = ConstructFileLoader(gamePath_);
|
|
||||||
if (!info_->fileLoader->Exists())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string filename = gamePath_;
|
std::string filename = gamePath_;
|
||||||
info_->path = gamePath_;
|
info_->path = gamePath_;
|
||||||
info_->fileType = Identify_File(info_->fileLoader);
|
info_->fileType = Identify_File(info_->GetFileLoader());
|
||||||
// Fallback title
|
// Fallback title
|
||||||
info_->title = getFilename(info_->path);
|
info_->title = getFilename(info_->path);
|
||||||
|
|
||||||
|
@ -386,7 +404,7 @@ handleELF:
|
||||||
// Let's assume it's an ISO.
|
// Let's assume it's an ISO.
|
||||||
// TODO: This will currently read in the whole directory tree. Not really necessary for just a
|
// TODO: This will currently read in the whole directory tree. Not really necessary for just a
|
||||||
// few files.
|
// few files.
|
||||||
BlockDevice *bd = constructBlockDevice(info_->fileLoader);
|
BlockDevice *bd = constructBlockDevice(info_->GetFileLoader());
|
||||||
if (!bd)
|
if (!bd)
|
||||||
return; // nothing to do here..
|
return; // nothing to do here..
|
||||||
ISOFileSystem umd(&handles, bd, "/PSP_GAME");
|
ISOFileSystem umd(&handles, bd, "/PSP_GAME");
|
||||||
|
@ -481,6 +499,8 @@ handleELF:
|
||||||
info_->saveDataSize = info_->GetSaveDataSizeInBytes();
|
info_->saveDataSize = info_->GetSaveDataSizeInBytes();
|
||||||
info_->installDataSize = info_->GetInstallDataSizeInBytes();
|
info_->installDataSize = info_->GetInstallDataSizeInBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info_->DisposeFileLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float priority() {
|
virtual float priority() {
|
||||||
|
|
|
@ -101,6 +101,9 @@ public:
|
||||||
|
|
||||||
bool DeleteGame(); // Better be sure what you're doing when calling this.
|
bool DeleteGame(); // Better be sure what you're doing when calling this.
|
||||||
bool DeleteAllSaveData();
|
bool DeleteAllSaveData();
|
||||||
|
bool LoadFromPath(const std::string &gamePath);
|
||||||
|
FileLoader *GetFileLoader();
|
||||||
|
void DisposeFileLoader();
|
||||||
|
|
||||||
u64 GetGameSizeInBytes();
|
u64 GetGameSizeInBytes();
|
||||||
u64 GetSaveDataSizeInBytes();
|
u64 GetSaveDataSizeInBytes();
|
||||||
|
@ -157,7 +160,9 @@ public:
|
||||||
u64 saveDataSize;
|
u64 saveDataSize;
|
||||||
u64 installDataSize;
|
u64 installDataSize;
|
||||||
|
|
||||||
|
protected:
|
||||||
FileLoader *fileLoader;
|
FileLoader *fileLoader;
|
||||||
|
std::string filePath_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameInfoCache {
|
class GameInfoCache {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue