Skip to content

Commit

Permalink
Io: Account for free space on the host device.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Oct 19, 2020
1 parent b56dbd8 commit e3a201f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Core/HW/MemoryStick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#include <algorithm>
#include "Common/Serialize/Serializer.h"
#include "Common/Serialize/SerializeFuncs.h"
#include "Core/CoreTiming.h"
Expand Down Expand Up @@ -71,18 +72,20 @@ u64 MemoryStick_SectorSize() {
}

u64 MemoryStick_FreeSpace() {
u64 realFreeSpace = pspFileSystem.FreeSpace("ms0:/");

// Cap the memory stick size to avoid math errors when old games get sizes that were
// hard to imagine back then.
// not planned for back then (even though 2GB cards were available.)
// We have a compat setting to make it even smaller for Harry Potter : Goblet of Fire, see #13266.
const u64 memStickSize = PSP_CoreParameter().compat.flags().ReportSmallMemstick ? smallMemstickSize : (u64)g_Config.iMemStickSizeGB * 1024 * 1024 * 1024;
u64 usedSpace = pspFileSystem.getDirSize("ms0:/PSP/SAVEDATA/");// Assume the memory stick is only used to store savedata.
u64 freeSpace;
if (usedSpace >= memStickSize)
freeSpace = 0;
else
freeSpace = memStickSize - usedSpace;

return freeSpace;
// Assume the memory stick is only used to store savedata.
u64 usedSpace = pspFileSystem.getDirSize("ms0:/PSP/SAVEDATA/");
u64 simulatedFreeSpace = 0;
if (usedSpace < memStickSize) {
simulatedFreeSpace = memStickSize - usedSpace;
}

return std::min(simulatedFreeSpace, realFreeSpace);
}

void MemoryStick_SetFatState(MemStickFatState state) {
Expand Down

0 comments on commit e3a201f

Please sign in to comment.