@ -13,6 +13,8 @@
namespace FileSys {
constexpr const char * SAVE_DATA_SIZE_FILENAME = " .yuzu_save_size " ;
std : : string SaveDataDescriptor : : DebugInfo ( ) const {
return fmt : : format ( " [type={:02X}, title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}] " ,
static_cast < u8 > ( type ) , title_id , user_id [ 1 ] , user_id [ 0 ] , save_id ) ;
@ -132,4 +134,32 @@ std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType typ
}
}
SaveDataSize SaveDataFactory : : ReadSaveDataSize ( SaveDataType type , u64 title_id ,
u128 user_id ) const {
const auto path = GetFullPath ( SaveDataSpaceId : : NandUser , type , title_id , user_id , 0 ) ;
const auto dir = GetOrCreateDirectoryRelative ( this - > dir , path ) ;
const auto size_file = dir - > GetFile ( SAVE_DATA_SIZE_FILENAME ) ;
if ( size_file = = nullptr | | size_file - > GetSize ( ) < sizeof ( SaveDataSize ) )
return { 0 , 0 } ;
SaveDataSize out ;
if ( size_file - > ReadObject ( & out ) ! = sizeof ( SaveDataSize ) )
return { 0 , 0 } ;
return out ;
}
void SaveDataFactory : : WriteSaveDataSize ( SaveDataType type , u64 title_id , u128 user_id ,
SaveDataSize new_value ) {
const auto path = GetFullPath ( SaveDataSpaceId : : NandUser , type , title_id , user_id , 0 ) ;
const auto dir = GetOrCreateDirectoryRelative ( this - > dir , path ) ;
const auto size_file = dir - > CreateFile ( SAVE_DATA_SIZE_FILENAME ) ;
if ( size_file = = nullptr )
return ;
size_file - > Resize ( sizeof ( SaveDataSize ) ) ;
size_file - > WriteObject ( new_value ) ;
}
} // namespace FileSys