コード例 #1
0
ファイル: SavedataParam.cpp プロジェクト: aki21/ppsspp
bool SavedataParam::GetSize(SceUtilitySavedataParam *param)
{
	if (!param)
	{
		return false;
	}

	std::string saveDir = savePath + GetGameName(param) + GetSaveName(param);
	PSPFileInfo info = pspFileSystem.GetFileInfo(saveDir);
	bool exists = info.exists;

	if (Memory::IsValidAddress(param->sizeAddr))
	{
		PspUtilitySavedataSizeInfo sizeInfo;
		Memory::ReadStruct(param->sizeAddr, &sizeInfo);

		// TODO: Read the entries and count up the size vs. existing size?

		sizeInfo.sectorSize = (int)MemoryStick_SectorSize();
		sizeInfo.freeSectors = (int)(MemoryStick_FreeSpace() / MemoryStick_SectorSize());

		// TODO: Is this after the specified files?  Before?
		sizeInfo.freeKB = (int)(MemoryStick_FreeSpace() / 1024);
		std::string spaceTxt = SavedataParam::GetSpaceText((int)MemoryStick_FreeSpace());
		strncpy(sizeInfo.freeString, spaceTxt.c_str(), 8);
		sizeInfo.freeString[7] = '\0';

		// TODO.
		sizeInfo.neededKB = 0;
		strcpy(sizeInfo.neededString, "0 KB");
		sizeInfo.overwriteKB = 0;
		strcpy(sizeInfo.overwriteString, "0 KB");

		Memory::WriteStruct(param->sizeAddr, &sizeInfo);
	}

	return exists;
}
コード例 #2
0
ファイル: SavedataParam.cpp プロジェクト: Summeli/ppsspp
bool SavedataParam::GetSizes(SceUtilitySavedataParam *param)
{
	if (!param) {
		return false;
	}

	bool ret = true;

	if (Memory::IsValidAddress(param->msFree))
	{
		Memory::Write_U32((u32)MemoryStick_SectorSize(),param->msFree); // cluster Size
		Memory::Write_U32((u32)(MemoryStick_FreeSpace() / MemoryStick_SectorSize()),param->msFree+4);	// Free cluster
		Memory::Write_U32((u32)(MemoryStick_FreeSpace() / 0x400),param->msFree+8); // Free space (in KB)
		std::string spaceTxt = SavedataParam::GetSpaceText((int)MemoryStick_FreeSpace());
		Memory::Memset(param->msFree+12,0,(u32)spaceTxt.size()+1);
		Memory::Memcpy(param->msFree+12,spaceTxt.c_str(),(u32)spaceTxt.size()); // Text representing free space
	}
	if (Memory::IsValidAddress(param->msData))
	{
		std::string path = GetSaveFilePath(param,0);
		PSPFileInfo finfo = pspFileSystem.GetFileInfo(path);
		if(finfo.exists)
		{
			// TODO : fill correctly with the total save size
			Memory::Write_U32(1,param->msData+36);	//1
			Memory::Write_U32(0x20,param->msData+40);	// 0x20
			Memory::Write_U8(0,param->msData+44);	// "32 KB" // 8 u8
			Memory::Write_U32(0x20,param->msData+52);	//  0x20
			Memory::Write_U8(0,param->msData+56);	// "32 KB" // 8 u8
		}
		else
		{
			Memory::Write_U32(0,param->msData+36);
			Memory::Write_U32(0,param->msData+40);
			Memory::Write_U8(0,param->msData+44);
			Memory::Write_U32(0,param->msData+52);
			Memory::Write_U8(0,param->msData+56);
			ret = false;
			// this should return SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA
		}
	}
	if (Memory::IsValidAddress(param->utilityData))
	{
		int total_size = 0;
		total_size += getSizeNormalized(1); // SFO;
		total_size += getSizeNormalized(param->dataSize); // Save Data
		total_size += getSizeNormalized(param->icon0FileData.size);
		total_size += getSizeNormalized(param->icon1FileData.size);
		total_size += getSizeNormalized(param->pic1FileData.size);
		total_size += getSizeNormalized(param->snd0FileData.size);

		Memory::Write_U32(total_size / (u32)MemoryStick_SectorSize(),param->utilityData);	// num cluster
		Memory::Write_U32(total_size / 0x400,param->utilityData+4);	// save size in KB
		std::string spaceTxt = SavedataParam::GetSpaceText(total_size);
		Memory::Memset(param->utilityData+8,0,(u32)spaceTxt.size()+1);
		Memory::Memcpy(param->utilityData+8,spaceTxt.c_str(),(u32)spaceTxt.size()); // save size in text
		Memory::Write_U32(total_size / 0x400,param->utilityData+16);	// save size in KB
		spaceTxt = SavedataParam::GetSpaceText(total_size);
		Memory::Memset(param->utilityData+20,0,(u32)spaceTxt.size()+1);
		Memory::Memcpy(param->utilityData+20,spaceTxt.c_str(),(u32)spaceTxt.size()); // save size in text
	}
	return ret;

}