Make a distinction between savedata and installdata.

This commit is contained in:
shenweip 2013-10-03 20:44:16 +08:00
parent 0e7871f30c
commit a304e9b420
4 changed files with 42 additions and 2 deletions

View File

@ -91,6 +91,7 @@ u64 GameInfo::GetSaveDataSizeInBytes() {
std::vector<std::string> saveDataDir = GetSaveDataDirectories();
u64 totalSize = 0;
u64 filesSizeInDir = 0;
for (size_t j = 0; j < saveDataDir.size(); j++) {
std::vector<FileInfo> fileInfo;
getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
@ -99,8 +100,38 @@ u64 GameInfo::GetSaveDataSizeInBytes() {
FileInfo finfo;
getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
if (!finfo.isDirectory)
totalSize += finfo.size;
filesSizeInDir += finfo.size;
}
if (filesSizeInDir < 0xA00000) {
//Generally the savedata size in a dir shouldn't be more than 10MB.
totalSize += filesSizeInDir;
}
filesSizeInDir = 0;
}
return totalSize;
}
u64 GameInfo::GetInstallDataSizeInBytes() {
std::vector<std::string> saveDataDir = GetSaveDataDirectories();
u64 totalSize = 0;
u64 filesSizeInDir = 0;
for (size_t j = 0; j < saveDataDir.size(); j++) {
std::vector<FileInfo> fileInfo;
getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
// Note: getFileInDir does not fill in fileSize properly.
for (size_t i = 0; i < fileInfo.size(); i++) {
FileInfo finfo;
getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
if (!finfo.isDirectory)
filesSizeInDir += finfo.size;
}
if (filesSizeInDir >= 0xA00000) {
// Generally the savedata size in a dir shouldn't be more than 10MB.
// This is probably GameInstall data.
totalSize += filesSizeInDir;
}
filesSizeInDir = 0;
}
return totalSize;
}
@ -311,6 +342,7 @@ public:
if (info_->wantBG) {
info_->gameSize = info_->GetGameSizeInBytes();
info_->saveDataSize = info_->GetSaveDataSizeInBytes();
info_->installDataSize = info_->GetInstallDataSizeInBytes();
}
}

View File

@ -35,13 +35,14 @@ class GameInfo {
public:
GameInfo()
: fileType(FILETYPE_UNKNOWN), paramSFOLoaded(false), iconTexture(NULL), pic0Texture(NULL), pic1Texture(NULL),
wantBG(false), gameSize(0), saveDataSize(0) {}
wantBG(false), gameSize(0), saveDataSize(0), installDataSize(0) {}
bool DeleteGame(); // Better be sure what you're doing when calling this.
bool DeleteAllSaveData();
u64 GetGameSizeInBytes();
u64 GetSaveDataSizeInBytes();
u64 GetInstallDataSizeInBytes();
void LoadParamSFO();
@ -82,6 +83,7 @@ public:
u64 gameSize;
u64 saveDataSize;
u64 installDataSize;
};
class GameInfoCache {

View File

@ -56,6 +56,7 @@ void GameScreen::CreateViews() {
tvTitle_ = leftColumn->Add(new TextView(info->title, ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 200, NONE, NONE)));
tvGameSize_ = leftColumn->Add(new TextView("...", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 250, NONE, NONE)));
tvSaveDataSize_ = leftColumn->Add(new TextView("...", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 290, NONE, NONE)));
tvInstallDataSize_ = leftColumn->Add(new TextView("", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 330, NONE, NONE)));
}
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
@ -128,6 +129,10 @@ void GameScreen::update(InputState &input) {
tvGameSize_->SetText(temp);
sprintf(temp, "%s: %1.2f %s", ga->T("SaveData"), (float) (info->saveDataSize) / 1024.f / 1024.f, ga->T("MB"));
tvSaveDataSize_->SetText(temp);
if (info->installDataSize > 0) {
sprintf(temp, "%s: %1.2f %s", ga->T("InstallData"), (float) (info->installDataSize) / 1024.f / 1024.f, ga->T("MB"));
tvInstallDataSize_->SetText(temp);
}
}
}

View File

@ -56,4 +56,5 @@ private:
UI::TextView *tvTitle_;
UI::TextView *tvGameSize_;
UI::TextView *tvSaveDataSize_;
UI::TextView *tvInstallDataSize_;
};