2014-03-28 20:06:15 +01:00
# include "stdafx.h"
2014-06-17 17:44:03 +02:00
# include "Utilities/Log.h"
2014-06-02 19:27:24 +02:00
# include "Emu/Memory/Memory.h"
# include "Emu/System.h"
# include "Emu/SysCalls/Modules.h"
# include "Emu/FS/vfsFile.h"
# include "Emu/FS/vfsDir.h"
2014-03-28 20:06:15 +01:00
# include <algorithm>
# include "cellSysutil_SaveData.h"
# include "Loader/PSF.h"
2014-05-02 08:30:32 +02:00
extern Module * cellSysutil ;
2014-03-28 20:06:15 +01:00
// Auxiliary Classes
class sortSaveDataEntry
{
u32 sortType ;
u32 sortOrder ;
public :
sortSaveDataEntry ( u32 type , u32 order ) : sortType ( type ) , sortOrder ( order ) { }
2014-04-09 18:23:14 +02:00
bool operator ( ) ( const SaveDataEntry & entry1 , const SaveDataEntry & entry2 ) const
2014-03-28 20:06:15 +01:00
{
if ( sortOrder = = CELL_SAVEDATA_SORTORDER_DESCENT )
{
if ( sortType = = CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME )
2014-03-31 12:04:34 +02:00
return entry1 . st_mtime_ > = entry2 . st_mtime_ ;
if ( sortType = = CELL_SAVEDATA_SORTTYPE_SUBTITLE )
2014-03-28 20:06:15 +01:00
return entry1 . subtitle > = entry2 . subtitle ;
}
2014-03-31 12:04:34 +02:00
if ( sortOrder = = CELL_SAVEDATA_SORTORDER_ASCENT )
2014-03-28 20:06:15 +01:00
{
if ( sortType = = CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME )
2014-03-31 12:04:34 +02:00
return entry1 . st_mtime_ < entry2 . st_mtime_ ;
if ( sortType = = CELL_SAVEDATA_SORTTYPE_SUBTITLE )
2014-03-28 20:06:15 +01:00
return entry1 . subtitle < entry2 . subtitle ;
}
2014-03-31 12:04:34 +02:00
return true ;
2014-03-28 20:06:15 +01:00
}
} ;
// Auxiliary Functions
u64 getSaveDataSize ( const std : : string & dirName )
{
vfsDir dir ( dirName ) ;
if ( ! dir . IsOpened ( ) )
return 0 ;
u64 totalSize = 0 ;
for ( const DirEntryInfo * entry = dir . Read ( ) ; entry ; entry = dir . Read ( ) ) {
if ( entry - > flags & DirEntry_TypeFile ) {
vfsFile file ( dirName + " / " + entry - > name ) ;
totalSize + = file . GetSize ( ) ;
}
}
return totalSize ;
}
2014-04-09 18:23:14 +02:00
void addSaveDataEntry ( std : : vector < SaveDataEntry > & saveEntries , const std : : string & saveDir )
2014-03-28 20:06:15 +01:00
{
// PSF parameters
vfsFile f ( saveDir + " /PARAM.SFO " ) ;
PSFLoader psf ( f ) ;
if ( ! psf . Load ( false ) )
return ;
// PNG icon
2014-04-01 02:33:55 +02:00
std : : string localPath ;
2014-03-28 20:06:15 +01:00
Emu . GetVFS ( ) . GetDevice ( saveDir + " /ICON0.PNG " , localPath ) ;
2014-04-09 18:23:14 +02:00
SaveDataEntry saveEntry ;
2014-03-28 20:06:15 +01:00
saveEntry . dirName = psf . GetString ( " SAVEDATA_DIRECTORY " ) ;
saveEntry . listParam = psf . GetString ( " SAVEDATA_LIST_PARAM " ) ;
saveEntry . title = psf . GetString ( " TITLE " ) ;
saveEntry . subtitle = psf . GetString ( " SUB_TITLE " ) ;
saveEntry . details = psf . GetString ( " DETAIL " ) ;
2014-03-31 20:30:07 +02:00
saveEntry . sizeKB = getSaveDataSize ( saveDir ) / 1024 ;
2014-03-31 12:04:34 +02:00
saveEntry . st_atime_ = 0 ; // TODO
saveEntry . st_mtime_ = 0 ; // TODO
saveEntry . st_ctime_ = 0 ; // TODO
2014-04-09 18:23:14 +02:00
saveEntry . iconBuf = NULL ; // TODO: Here should be the PNG buffer
saveEntry . iconBufSize = 0 ; // TODO: Size of the PNG file
2014-03-31 12:04:34 +02:00
saveEntry . isNew = false ;
2014-03-28 20:06:15 +01:00
saveEntries . push_back ( saveEntry ) ;
}
2014-04-09 18:23:14 +02:00
void addNewSaveDataEntry ( std : : vector < SaveDataEntry > & saveEntries , mem_ptr_t < CellSaveDataListNewData > newData )
2014-03-31 12:04:34 +02:00
{
2014-04-09 18:23:14 +02:00
SaveDataEntry saveEntry ;
2014-03-31 12:04:34 +02:00
saveEntry . dirName = ( char * ) Memory . VirtualToRealAddr ( newData - > dirName_addr ) ;
saveEntry . title = ( char * ) Memory . VirtualToRealAddr ( newData - > icon - > title_addr ) ;
saveEntry . subtitle = ( char * ) Memory . VirtualToRealAddr ( newData - > icon - > title_addr ) ;
saveEntry . iconBuf = Memory . VirtualToRealAddr ( newData - > icon - > iconBuf_addr ) ;
saveEntry . iconBufSize = newData - > icon - > iconBufSize ;
saveEntry . isNew = true ;
// TODO: Add information stored in newData->iconPosition. (It's not very relevant)
saveEntries . push_back ( saveEntry ) ;
}
2014-04-09 18:23:14 +02:00
u32 focusSaveDataEntry ( const std : : vector < SaveDataEntry > & saveEntries , u32 focusPosition )
2014-03-31 12:04:34 +02:00
{
2014-03-31 20:30:07 +02:00
// TODO: Get the correct index. Right now, this returns the first element of the list.
2014-03-31 12:04:34 +02:00
return 0 ;
}
2014-04-09 18:23:14 +02:00
void setSaveDataList ( std : : vector < SaveDataEntry > & saveEntries , mem_ptr_t < CellSaveDataDirList > fixedList , u32 fixedListNum )
2014-03-31 12:04:34 +02:00
{
2014-04-09 18:23:14 +02:00
std : : vector < SaveDataEntry > : : iterator entry = saveEntries . begin ( ) ;
2014-03-31 12:04:34 +02:00
while ( entry ! = saveEntries . end ( ) )
{
bool found = false ;
for ( u32 j = 0 ; j < fixedListNum ; j + + )
{
if ( entry - > dirName = = ( char * ) fixedList [ j ] . dirName )
{
found = true ;
break ;
}
}
if ( ! found )
entry = saveEntries . erase ( entry ) ;
else
entry + + ;
}
}
2014-04-09 18:23:14 +02:00
void setSaveDataFixed ( std : : vector < SaveDataEntry > & saveEntries , mem_ptr_t < CellSaveDataFixedSet > fixedSet )
{
std : : vector < SaveDataEntry > : : iterator entry = saveEntries . begin ( ) ;
while ( entry ! = saveEntries . end ( ) )
{
if ( entry - > dirName = = ( char * ) Memory . VirtualToRealAddr ( fixedSet - > dirName_addr ) )
entry = saveEntries . erase ( entry ) ;
else
entry + + ;
}
if ( saveEntries . size ( ) = = 0 )
{
SaveDataEntry entry ;
entry . dirName = ( char * ) Memory . VirtualToRealAddr ( fixedSet - > dirName_addr ) ;
entry . isNew = true ;
saveEntries . push_back ( entry ) ;
}
if ( fixedSet - > newIcon . IsGood ( ) )
{
saveEntries [ 0 ] . iconBuf = Memory . VirtualToRealAddr ( fixedSet - > newIcon - > iconBuf_addr ) ;
saveEntries [ 0 ] . iconBufSize = fixedSet - > newIcon - > iconBufSize ;
saveEntries [ 0 ] . title = ( char * ) Memory . VirtualToRealAddr ( fixedSet - > newIcon - > title_addr ) ;
saveEntries [ 0 ] . subtitle = ( char * ) Memory . VirtualToRealAddr ( fixedSet - > newIcon - > title_addr ) ;
}
}
void getSaveDataStat ( SaveDataEntry entry , mem_ptr_t < CellSaveDataStatGet > statGet )
2014-03-31 20:30:07 +02:00
{
if ( entry . isNew )
statGet - > isNewData = CELL_SAVEDATA_ISNEWDATA_YES ;
else
statGet - > isNewData = CELL_SAVEDATA_ISNEWDATA_NO ;
statGet - > bind = 0 ; // TODO ?
statGet - > sizeKB = entry . sizeKB ;
statGet - > hddFreeSizeKB = 40000000 ; // 40 GB. TODO ?
statGet - > sysSizeKB = 0 ; // TODO: This is the size of PARAM.SFO + PARAM.PDF
statGet - > dir . st_atime_ = 0 ; // TODO ?
statGet - > dir . st_mtime_ = 0 ; // TODO ?
statGet - > dir . st_ctime_ = 0 ; // TODO ?
memcpy ( statGet - > dir . dirName , entry . dirName . c_str ( ) , CELL_SAVEDATA_DIRNAME_SIZE ) ;
statGet - > getParam . attribute = 0 ; // TODO ?
memcpy ( statGet - > getParam . title , entry . title . c_str ( ) , CELL_SAVEDATA_SYSP_TITLE_SIZE ) ;
memcpy ( statGet - > getParam . subTitle , entry . subtitle . c_str ( ) , CELL_SAVEDATA_SYSP_SUBTITLE_SIZE ) ;
memcpy ( statGet - > getParam . detail , entry . details . c_str ( ) , CELL_SAVEDATA_SYSP_DETAIL_SIZE ) ;
memcpy ( statGet - > getParam . listParam , entry . listParam . c_str ( ) , CELL_SAVEDATA_SYSP_LPARAM_SIZE ) ;
statGet - > fileNum = 0 ;
statGet - > fileList . SetAddr ( 0 ) ;
statGet - > fileListNum = 0 ;
std : : string saveDir = " /dev_hdd0/home/00000001/savedata/ " + entry . dirName ; // TODO: Get the path of the current user
vfsDir dir ( saveDir ) ;
if ( ! dir . IsOpened ( ) )
return ;
std : : vector < CellSaveDataFileStat > fileEntries ;
for ( const DirEntryInfo * dirEntry = dir . Read ( ) ; dirEntry ; dirEntry = dir . Read ( ) ) {
if ( dirEntry - > flags & DirEntry_TypeFile ) {
if ( dirEntry - > name = = " PARAM.SFO " | | dirEntry - > name = = " PARAM.PFD " )
continue ;
statGet - > fileNum + + ;
statGet - > fileListNum + + ;
CellSaveDataFileStat fileEntry ;
vfsFile file ( saveDir + " / " + dirEntry - > name ) ;
if ( dirEntry - > name = = " ICON0.PNG " ) fileEntry . fileType = CELL_SAVEDATA_FILETYPE_CONTENT_ICON0 ;
if ( dirEntry - > name = = " ICON1.PAM " ) fileEntry . fileType = CELL_SAVEDATA_FILETYPE_CONTENT_ICON1 ;
if ( dirEntry - > name = = " PIC1.PNG " ) fileEntry . fileType = CELL_SAVEDATA_FILETYPE_CONTENT_PIC1 ;
if ( dirEntry - > name = = " SND0.AT3 " ) fileEntry . fileType = CELL_SAVEDATA_FILETYPE_CONTENT_SND0 ;
fileEntry . st_size = file . GetSize ( ) ;
fileEntry . st_atime_ = 0 ; // TODO ?
fileEntry . st_mtime_ = 0 ; // TODO ?
fileEntry . st_ctime_ = 0 ; // TODO ?
2014-04-01 19:19:51 +02:00
memcpy ( fileEntry . fileName , dirEntry - > name . c_str ( ) , CELL_SAVEDATA_FILENAME_SIZE ) ;
2014-03-31 20:30:07 +02:00
fileEntries . push_back ( fileEntry ) ;
}
}
statGet - > fileList . SetAddr ( Memory . Alloc ( sizeof ( CellSaveDataFileStat ) * fileEntries . size ( ) , sizeof ( CellSaveDataFileStat ) ) ) ;
for ( u32 i = 0 ; i < fileEntries . size ( ) ; i + + )
memcpy ( & statGet - > fileList [ i ] , & fileEntries [ i ] , sizeof ( CellSaveDataFileStat ) ) ;
}
2014-04-19 18:50:06 +02:00
s32 modifySaveDataFiles ( mem_func_ptr_t < CellSaveDataFileCallback > & funcFile , mem_ptr_t < CellSaveDataCBResult > result , const std : : string & saveDataDir )
2014-03-31 20:30:07 +02:00
{
2014-04-19 18:50:06 +02:00
MemoryAllocator < CellSaveDataFileGet > fileGet ;
MemoryAllocator < CellSaveDataFileSet > fileSet ;
2014-04-09 18:23:14 +02:00
2014-04-19 18:50:06 +02:00
if ( ! Emu . GetVFS ( ) . ExistsDir ( saveDataDir ) )
Emu . GetVFS ( ) . CreateDir ( saveDataDir ) ;
fileGet - > excSize = 0 ;
while ( true )
2014-04-09 18:23:14 +02:00
{
2014-04-19 18:50:06 +02:00
funcFile ( result . GetAddr ( ) , fileGet . GetAddr ( ) , fileSet . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " modifySaveDataFiles: CellSaveDataFileCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-04-19 18:50:06 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
if ( result - > result = = CELL_SAVEDATA_CBRESULT_OK_LAST ) {
break ;
}
std : : string filepath = saveDataDir + ' / ' ;
vfsStream * file = NULL ;
void * buf = Memory . VirtualToRealAddr ( fileSet - > fileBuf_addr ) ;
2014-04-25 18:57:00 +02:00
switch ( ( u32 ) fileSet - > fileType )
2014-04-19 18:50:06 +02:00
{
case CELL_SAVEDATA_FILETYPE_SECUREFILE : filepath + = ( char * ) Memory . VirtualToRealAddr ( fileSet - > fileName_addr ) ; break ;
case CELL_SAVEDATA_FILETYPE_NORMALFILE : filepath + = ( char * ) Memory . VirtualToRealAddr ( fileSet - > fileName_addr ) ; break ;
case CELL_SAVEDATA_FILETYPE_CONTENT_ICON0 : filepath + = " ICON0.PNG " ; break ;
case CELL_SAVEDATA_FILETYPE_CONTENT_ICON1 : filepath + = " ICON1.PAM " ; break ;
case CELL_SAVEDATA_FILETYPE_CONTENT_PIC1 : filepath + = " PIC1.PNG " ; break ;
case CELL_SAVEDATA_FILETYPE_CONTENT_SND0 : filepath + = " SND0.AT3 " ; break ;
default :
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " modifySaveDataFiles: Unknown fileType! Aborting... " ) ;
2014-04-19 18:50:06 +02:00
return CELL_SAVEDATA_ERROR_PARAM ;
}
2014-04-25 18:57:00 +02:00
switch ( ( u32 ) fileSet - > fileOperation )
2014-04-19 18:50:06 +02:00
{
case CELL_SAVEDATA_FILEOP_READ :
file = Emu . GetVFS ( ) . OpenFile ( filepath , vfsRead ) ;
2014-06-02 19:27:24 +02:00
fileGet - > excSize = file - > Read ( buf , std : : min ( fileSet - > fileSize , fileSet - > fileBufSize ) ) ; // TODO: This may fail for big files because of the dest pointer.
2014-04-19 18:50:06 +02:00
break ;
2014-04-09 18:23:14 +02:00
2014-04-19 18:50:06 +02:00
case CELL_SAVEDATA_FILEOP_WRITE :
Emu . GetVFS ( ) . CreateFile ( filepath ) ;
file = Emu . GetVFS ( ) . OpenFile ( filepath , vfsWrite ) ;
2014-06-02 19:27:24 +02:00
fileGet - > excSize = file - > Write ( buf , std : : min ( fileSet - > fileSize , fileSet - > fileBufSize ) ) ; // TODO: This may fail for big files because of the dest pointer.
2014-04-19 18:50:06 +02:00
break ;
2014-04-09 18:23:14 +02:00
2014-04-19 18:50:06 +02:00
case CELL_SAVEDATA_FILEOP_DELETE :
Emu . GetVFS ( ) . RemoveFile ( filepath ) ;
fileGet - > excSize = 0 ;
break ;
2014-04-09 18:23:14 +02:00
2014-04-19 18:50:06 +02:00
case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC :
2014-06-27 15:26:46 +02:00
LOG_WARNING ( HLE , " modifySaveDataFiles: File operation CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC not yet implemented " ) ;
2014-04-19 18:50:06 +02:00
break ;
2014-03-31 20:30:07 +02:00
2014-04-19 18:50:06 +02:00
default :
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " modifySaveDataFiles: Unknown fileOperation! Aborting... " ) ;
2014-04-19 18:50:06 +02:00
return CELL_SAVEDATA_ERROR_PARAM ;
}
2014-04-09 18:23:14 +02:00
2014-04-19 18:50:06 +02:00
if ( file & & file - > IsOpened ( ) )
file - > Close ( ) ;
}
return CELL_SAVEDATA_RET_OK ;
2014-03-31 20:30:07 +02:00
}
2014-03-28 20:06:15 +01:00
// Functions
int cellSaveDataListSave2 ( u32 version , mem_ptr_t < CellSaveDataSetList > setList , mem_ptr_t < CellSaveDataSetBuf > setBuf ,
mem_func_ptr_t < CellSaveDataListCallback > funcList , mem_func_ptr_t < CellSaveDataStatCallback > funcStat , mem_func_ptr_t < CellSaveDataFileCallback > funcFile ,
2014-03-31 20:30:07 +02:00
u32 container , u32 userdata_addr )
2014-03-28 20:06:15 +01:00
{
2014-05-02 08:30:32 +02:00
cellSysutil - > Warning ( " cellSaveDataListSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=%d, userdata_addr=0x%x) " ,
2014-03-31 20:30:07 +02:00
version , setList . GetAddr ( ) , setBuf . GetAddr ( ) , funcList . GetAddr ( ) , funcStat . GetAddr ( ) , funcFile . GetAddr ( ) , container , userdata_addr ) ;
2014-03-28 20:06:15 +01:00
if ( ! setList . IsGood ( ) | | ! setBuf . IsGood ( ) | | ! funcList . IsGood ( ) | | ! funcStat . IsGood ( ) | | ! funcFile . IsGood ( ) )
return CELL_SAVEDATA_ERROR_PARAM ;
MemoryAllocator < CellSaveDataCBResult > result ;
MemoryAllocator < CellSaveDataListGet > listGet ;
2014-03-31 12:04:34 +02:00
MemoryAllocator < CellSaveDataListSet > listSet ;
2014-04-09 18:23:14 +02:00
MemoryAllocator < CellSaveDataStatGet > statGet ;
MemoryAllocator < CellSaveDataStatSet > statSet ;
2014-03-28 20:06:15 +01:00
std : : string saveBaseDir = " /dev_hdd0/home/00000001/savedata/ " ; // TODO: Get the path of the current user
vfsDir dir ( saveBaseDir ) ;
if ( ! dir . IsOpened ( ) )
return CELL_SAVEDATA_ERROR_INTERNAL ;
2014-04-01 02:33:55 +02:00
std : : string dirNamePrefix = Memory . ReadString ( setList - > dirNamePrefix_addr ) ;
2014-04-09 18:23:14 +02:00
std : : vector < SaveDataEntry > saveEntries ;
2014-03-28 20:06:15 +01:00
for ( const DirEntryInfo * entry = dir . Read ( ) ; entry ; entry = dir . Read ( ) )
{
2014-04-09 18:23:14 +02:00
if ( entry - > flags & DirEntry_TypeDir & & entry - > name . substr ( 0 , dirNamePrefix . size ( ) ) = = dirNamePrefix )
2014-03-28 20:06:15 +01:00
{
// Count the amount of matches and the amount of listed directories
listGet - > dirListNum + + ;
if ( listGet - > dirListNum > setBuf - > dirListMax )
continue ;
listGet - > dirNum + + ;
2014-04-01 02:33:55 +02:00
std : : string saveDir = saveBaseDir + entry - > name ;
2014-03-31 12:04:34 +02:00
addSaveDataEntry ( saveEntries , saveDir ) ;
2014-03-28 20:06:15 +01:00
}
}
// Sort the entries and fill the listGet->dirList array
std : : sort ( saveEntries . begin ( ) , saveEntries . end ( ) , sortSaveDataEntry ( setList - > sortType , setList - > sortOrder ) ) ;
2014-03-31 12:04:34 +02:00
listGet - > dirList . SetAddr ( setBuf - > buf_addr ) ;
CellSaveDataDirList * dirList = ( CellSaveDataDirList * ) Memory . VirtualToRealAddr ( listGet - > dirList . GetAddr ( ) ) ;
2014-03-28 20:06:15 +01:00
for ( u32 i = 0 ; i < saveEntries . size ( ) ; i + + ) {
memcpy ( dirList [ i ] . dirName , saveEntries [ i ] . dirName . c_str ( ) , CELL_SAVEDATA_DIRNAME_SIZE ) ;
memcpy ( dirList [ i ] . listParam , saveEntries [ i ] . listParam . c_str ( ) , CELL_SAVEDATA_SYSP_LPARAM_SIZE ) ;
}
funcList ( result . GetAddr ( ) , listGet . GetAddr ( ) , listSet . GetAddr ( ) ) ;
2014-03-31 20:30:07 +02:00
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataListSave2: CellSaveDataListCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-03-31 20:30:07 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
if ( ! listSet - > fixedList . IsGood ( ) )
return CELL_SAVEDATA_ERROR_PARAM ;
2014-04-09 18:23:14 +02:00
setSaveDataList ( saveEntries , ( u32 ) listSet - > fixedList . GetAddr ( ) , listSet - > fixedListNum ) ;
2014-03-31 20:30:07 +02:00
if ( listSet - > newData . IsGood ( ) )
addNewSaveDataEntry ( saveEntries , ( u32 ) listSet - > newData . GetAddr ( ) ) ;
if ( saveEntries . size ( ) = = 0 ) {
2014-06-27 15:26:46 +02:00
LOG_WARNING ( HLE , " cellSaveDataListSave2: No save entries found! " ) ; // TODO: Find a better way to handle this error
2014-03-31 20:30:07 +02:00
return CELL_SAVEDATA_RET_OK ;
}
2014-03-28 20:06:15 +01:00
2014-03-31 20:30:07 +02:00
u32 focusIndex = focusSaveDataEntry ( saveEntries , listSet - > focusPosition ) ;
// TODO: Display the dialog here
u32 selectedIndex = focusIndex ; // TODO: Until the dialog is implemented, select always the focused entry
getSaveDataStat ( saveEntries [ selectedIndex ] , statGet . GetAddr ( ) ) ;
result - > userdata_addr = userdata_addr ;
2014-03-28 20:06:15 +01:00
funcStat ( result . GetAddr ( ) , statGet . GetAddr ( ) , statSet . GetAddr ( ) ) ;
2014-03-31 20:30:07 +02:00
Memory . Free ( statGet - > fileList . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataListLoad2: CellSaveDataStatCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-03-31 20:30:07 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
2014-04-09 18:23:14 +02:00
/*if (statSet->setParam.IsGood())
addNewSaveDataEntry ( saveEntries , ( u32 ) listSet - > newData . GetAddr ( ) ) ; // TODO: This *is* wrong
*/
2014-03-28 20:06:15 +01:00
2014-04-19 18:50:06 +02:00
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles ( funcFile , result . GetAddr ( ) , saveBaseDir + ( char * ) statGet - > dir . dirName ) ;
2014-03-28 20:06:15 +01:00
2014-04-19 18:50:06 +02:00
return ret ;
2014-03-28 20:06:15 +01:00
}
int cellSaveDataListLoad2 ( u32 version , mem_ptr_t < CellSaveDataSetList > setList , mem_ptr_t < CellSaveDataSetBuf > setBuf ,
mem_func_ptr_t < CellSaveDataListCallback > funcList , mem_func_ptr_t < CellSaveDataStatCallback > funcStat , mem_func_ptr_t < CellSaveDataFileCallback > funcFile ,
2014-03-31 20:30:07 +02:00
u32 container , u32 userdata_addr )
2014-03-28 20:06:15 +01:00
{
2014-05-02 08:30:32 +02:00
cellSysutil - > Warning ( " cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=%d, userdata_addr=0x%x) " ,
2014-03-31 20:30:07 +02:00
version , setList . GetAddr ( ) , setBuf . GetAddr ( ) , funcList . GetAddr ( ) , funcStat . GetAddr ( ) , funcFile . GetAddr ( ) , container , userdata_addr ) ;
2014-03-28 20:06:15 +01:00
if ( ! setList . IsGood ( ) | | ! setBuf . IsGood ( ) | | ! funcList . IsGood ( ) | | ! funcStat . IsGood ( ) | | ! funcFile . IsGood ( ) )
return CELL_SAVEDATA_ERROR_PARAM ;
MemoryAllocator < CellSaveDataCBResult > result ;
MemoryAllocator < CellSaveDataListGet > listGet ;
2014-03-31 12:04:34 +02:00
MemoryAllocator < CellSaveDataListSet > listSet ;
2014-03-31 20:30:07 +02:00
MemoryAllocator < CellSaveDataStatGet > statGet ;
MemoryAllocator < CellSaveDataStatSet > statSet ;
2014-03-28 20:06:15 +01:00
std : : string saveBaseDir = " /dev_hdd0/home/00000001/savedata/ " ; // TODO: Get the path of the current user
vfsDir dir ( saveBaseDir ) ;
if ( ! dir . IsOpened ( ) )
return CELL_SAVEDATA_ERROR_INTERNAL ;
2014-04-01 02:33:55 +02:00
std : : string dirNamePrefix = Memory . ReadString ( setList - > dirNamePrefix_addr ) ;
2014-04-09 18:23:14 +02:00
std : : vector < SaveDataEntry > saveEntries ;
2014-03-28 20:06:15 +01:00
for ( const DirEntryInfo * entry = dir . Read ( ) ; entry ; entry = dir . Read ( ) )
{
2014-04-09 18:23:14 +02:00
if ( entry - > flags & DirEntry_TypeDir & & entry - > name . substr ( 0 , dirNamePrefix . size ( ) ) = = dirNamePrefix )
2014-03-28 20:06:15 +01:00
{
// Count the amount of matches and the amount of listed directories
listGet - > dirListNum + + ;
if ( listGet - > dirListNum > setBuf - > dirListMax )
continue ;
listGet - > dirNum + + ;
2014-04-01 02:33:55 +02:00
std : : string saveDir = saveBaseDir + entry - > name ;
2014-03-31 12:04:34 +02:00
addSaveDataEntry ( saveEntries , saveDir ) ;
2014-03-28 20:06:15 +01:00
}
}
// Sort the entries and fill the listGet->dirList array
std : : sort ( saveEntries . begin ( ) , saveEntries . end ( ) , sortSaveDataEntry ( setList - > sortType , setList - > sortOrder ) ) ;
2014-03-31 12:04:34 +02:00
listGet - > dirList . SetAddr ( setBuf - > buf_addr ) ;
CellSaveDataDirList * dirList = ( CellSaveDataDirList * ) Memory . VirtualToRealAddr ( listGet - > dirList . GetAddr ( ) ) ;
2014-03-28 20:06:15 +01:00
for ( u32 i = 0 ; i < saveEntries . size ( ) ; i + + ) {
memcpy ( dirList [ i ] . dirName , saveEntries [ i ] . dirName . c_str ( ) , CELL_SAVEDATA_DIRNAME_SIZE ) ;
memcpy ( dirList [ i ] . listParam , saveEntries [ i ] . listParam . c_str ( ) , CELL_SAVEDATA_SYSP_LPARAM_SIZE ) ;
}
funcList ( result . GetAddr ( ) , listGet . GetAddr ( ) , listSet . GetAddr ( ) ) ;
2014-03-31 12:04:34 +02:00
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataListLoad2: CellSaveDataListCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-03-31 12:04:34 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
2014-03-31 20:30:07 +02:00
if ( ! listSet - > fixedList . IsGood ( ) )
2014-03-31 12:04:34 +02:00
return CELL_SAVEDATA_ERROR_PARAM ;
2014-03-28 20:06:15 +01:00
2014-04-09 18:23:14 +02:00
setSaveDataList ( saveEntries , ( u32 ) listSet - > fixedList . GetAddr ( ) , listSet - > fixedListNum ) ;
2014-03-31 20:30:07 +02:00
if ( listSet - > newData . IsGood ( ) )
addNewSaveDataEntry ( saveEntries , ( u32 ) listSet - > newData . GetAddr ( ) ) ;
if ( saveEntries . size ( ) = = 0 ) {
2014-06-27 15:26:46 +02:00
LOG_WARNING ( HLE , " cellSaveDataListLoad2: No save entries found! " ) ; // TODO: Find a better way to handle this error
2014-03-31 20:30:07 +02:00
return CELL_SAVEDATA_RET_OK ;
}
2014-03-31 12:04:34 +02:00
2014-03-31 20:30:07 +02:00
u32 focusIndex = focusSaveDataEntry ( saveEntries , listSet - > focusPosition ) ;
2014-03-31 12:04:34 +02:00
// TODO: Display the dialog here
2014-03-31 20:30:07 +02:00
u32 selectedIndex = focusIndex ; // TODO: Until the dialog is implemented, select always the focused entry
getSaveDataStat ( saveEntries [ selectedIndex ] , statGet . GetAddr ( ) ) ;
result - > userdata_addr = userdata_addr ;
2014-03-31 12:04:34 +02:00
2014-03-28 20:06:15 +01:00
funcStat ( result . GetAddr ( ) , statGet . GetAddr ( ) , statSet . GetAddr ( ) ) ;
2014-03-31 20:30:07 +02:00
Memory . Free ( statGet - > fileList . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataListLoad2: CellSaveDataStatCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-03-31 20:30:07 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
2014-04-09 18:23:14 +02:00
/*if (statSet->setParam.IsGood())
// TODO: Write PARAM.SFO file
*/
2014-03-28 20:06:15 +01:00
2014-04-19 18:50:06 +02:00
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles ( funcFile , result . GetAddr ( ) , saveBaseDir + ( char * ) statGet - > dir . dirName ) ;
2014-03-28 20:06:15 +01:00
2014-04-19 18:50:06 +02:00
return ret ;
2014-03-28 20:06:15 +01:00
}
int cellSaveDataFixedSave2 ( u32 version , mem_ptr_t < CellSaveDataSetList > setList , mem_ptr_t < CellSaveDataSetBuf > setBuf ,
mem_func_ptr_t < CellSaveDataFixedCallback > funcFixed , mem_func_ptr_t < CellSaveDataStatCallback > funcStat , mem_func_ptr_t < CellSaveDataFileCallback > funcFile ,
u32 container , u32 userdata_addr )
{
2014-05-02 08:30:32 +02:00
cellSysutil - > Warning ( " cellSaveDataFixedSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcFixed_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=%d, userdata_addr=0x%x) " ,
2014-04-09 18:23:14 +02:00
version , setList . GetAddr ( ) , setBuf . GetAddr ( ) , funcFixed . GetAddr ( ) , funcStat . GetAddr ( ) , funcFile . GetAddr ( ) , container , userdata_addr ) ;
if ( ! setList . IsGood ( ) | | ! setBuf . IsGood ( ) | | ! funcFixed . IsGood ( ) | | ! funcStat . IsGood ( ) | | ! funcFile . IsGood ( ) )
return CELL_SAVEDATA_ERROR_PARAM ;
MemoryAllocator < CellSaveDataCBResult > result ;
MemoryAllocator < CellSaveDataListGet > listGet ;
MemoryAllocator < CellSaveDataFixedSet > fixedSet ;
MemoryAllocator < CellSaveDataStatGet > statGet ;
MemoryAllocator < CellSaveDataStatSet > statSet ;
std : : string saveBaseDir = " /dev_hdd0/home/00000001/savedata/ " ; // TODO: Get the path of the current user
vfsDir dir ( saveBaseDir ) ;
if ( ! dir . IsOpened ( ) )
return CELL_SAVEDATA_ERROR_INTERNAL ;
std : : string dirNamePrefix = Memory . ReadString ( setList - > dirNamePrefix_addr ) ;
std : : vector < SaveDataEntry > saveEntries ;
for ( const DirEntryInfo * entry = dir . Read ( ) ; entry ; entry = dir . Read ( ) )
{
if ( entry - > flags & DirEntry_TypeDir & & entry - > name . substr ( 0 , dirNamePrefix . size ( ) ) = = dirNamePrefix )
{
// Count the amount of matches and the amount of listed directories
listGet - > dirListNum + + ;
if ( listGet - > dirListNum > setBuf - > dirListMax )
continue ;
listGet - > dirNum + + ;
std : : string saveDir = saveBaseDir + entry - > name ;
addSaveDataEntry ( saveEntries , saveDir ) ;
}
}
// Sort the entries and fill the listGet->dirList array
std : : sort ( saveEntries . begin ( ) , saveEntries . end ( ) , sortSaveDataEntry ( setList - > sortType , setList - > sortOrder ) ) ;
listGet - > dirList . SetAddr ( setBuf - > buf_addr ) ;
CellSaveDataDirList * dirList = ( CellSaveDataDirList * ) Memory . VirtualToRealAddr ( listGet - > dirList . GetAddr ( ) ) ;
for ( u32 i = 0 ; i < saveEntries . size ( ) ; i + + ) {
memcpy ( dirList [ i ] . dirName , saveEntries [ i ] . dirName . c_str ( ) , CELL_SAVEDATA_DIRNAME_SIZE ) ;
memcpy ( dirList [ i ] . listParam , saveEntries [ i ] . listParam . c_str ( ) , CELL_SAVEDATA_SYSP_LPARAM_SIZE ) ;
}
funcFixed ( result . GetAddr ( ) , listGet . GetAddr ( ) , fixedSet . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataFixedSave2: CellSaveDataFixedCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-04-09 18:23:14 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
setSaveDataFixed ( saveEntries , fixedSet . GetAddr ( ) ) ;
getSaveDataStat ( saveEntries [ 0 ] , statGet . GetAddr ( ) ) ; // There should be only one element in this list
// TODO: Display the Yes|No dialog here
result - > userdata_addr = userdata_addr ;
funcStat ( result . GetAddr ( ) , statGet . GetAddr ( ) , statSet . GetAddr ( ) ) ;
Memory . Free ( statGet - > fileList . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataFixedSave2: CellSaveDataStatCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-04-09 18:23:14 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
/*if (statSet->setParam.IsGood())
// TODO: Write PARAM.SFO file
*/
2014-04-19 18:50:06 +02:00
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles ( funcFile , result . GetAddr ( ) , saveBaseDir + ( char * ) statGet - > dir . dirName ) ;
2014-04-09 18:23:14 +02:00
2014-04-19 18:50:06 +02:00
return ret ;
2014-03-28 20:06:15 +01:00
}
int cellSaveDataFixedLoad2 ( u32 version , mem_ptr_t < CellSaveDataSetList > setList , mem_ptr_t < CellSaveDataSetBuf > setBuf ,
mem_func_ptr_t < CellSaveDataFixedCallback > funcFixed , mem_func_ptr_t < CellSaveDataStatCallback > funcStat , mem_func_ptr_t < CellSaveDataFileCallback > funcFile ,
u32 container , u32 userdata_addr )
{
2014-05-02 08:30:32 +02:00
cellSysutil - > Warning ( " cellSaveDataFixedLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x) " ,
2014-04-09 18:23:14 +02:00
version , setList . GetAddr ( ) , setBuf . GetAddr ( ) , funcFixed . GetAddr ( ) , funcStat . GetAddr ( ) , funcFile . GetAddr ( ) , container , userdata_addr ) ;
if ( ! setList . IsGood ( ) | | ! setBuf . IsGood ( ) | | ! funcFixed . IsGood ( ) | | ! funcStat . IsGood ( ) | | ! funcFile . IsGood ( ) )
return CELL_SAVEDATA_ERROR_PARAM ;
MemoryAllocator < CellSaveDataCBResult > result ;
MemoryAllocator < CellSaveDataListGet > listGet ;
MemoryAllocator < CellSaveDataFixedSet > fixedSet ;
MemoryAllocator < CellSaveDataStatGet > statGet ;
MemoryAllocator < CellSaveDataStatSet > statSet ;
std : : string saveBaseDir = " /dev_hdd0/home/00000001/savedata/ " ; // TODO: Get the path of the current user
vfsDir dir ( saveBaseDir ) ;
if ( ! dir . IsOpened ( ) )
return CELL_SAVEDATA_ERROR_INTERNAL ;
std : : string dirNamePrefix = Memory . ReadString ( setList - > dirNamePrefix_addr ) ;
std : : vector < SaveDataEntry > saveEntries ;
for ( const DirEntryInfo * entry = dir . Read ( ) ; entry ; entry = dir . Read ( ) )
{
if ( entry - > flags & DirEntry_TypeDir & & entry - > name . substr ( 0 , dirNamePrefix . size ( ) ) = = dirNamePrefix )
{
// Count the amount of matches and the amount of listed directories
listGet - > dirListNum + + ;
if ( listGet - > dirListNum > setBuf - > dirListMax )
continue ;
listGet - > dirNum + + ;
std : : string saveDir = saveBaseDir + entry - > name ;
addSaveDataEntry ( saveEntries , saveDir ) ;
}
}
// Sort the entries and fill the listGet->dirList array
std : : sort ( saveEntries . begin ( ) , saveEntries . end ( ) , sortSaveDataEntry ( setList - > sortType , setList - > sortOrder ) ) ;
listGet - > dirList . SetAddr ( setBuf - > buf_addr ) ;
CellSaveDataDirList * dirList = ( CellSaveDataDirList * ) Memory . VirtualToRealAddr ( listGet - > dirList . GetAddr ( ) ) ;
for ( u32 i = 0 ; i < saveEntries . size ( ) ; i + + ) {
memcpy ( dirList [ i ] . dirName , saveEntries [ i ] . dirName . c_str ( ) , CELL_SAVEDATA_DIRNAME_SIZE ) ;
memcpy ( dirList [ i ] . listParam , saveEntries [ i ] . listParam . c_str ( ) , CELL_SAVEDATA_SYSP_LPARAM_SIZE ) ;
}
funcFixed ( result . GetAddr ( ) , listGet . GetAddr ( ) , fixedSet . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataFixedLoad2: CellSaveDataFixedCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-04-09 18:23:14 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
setSaveDataFixed ( saveEntries , fixedSet . GetAddr ( ) ) ;
getSaveDataStat ( saveEntries [ 0 ] , statGet . GetAddr ( ) ) ; // There should be only one element in this list
// TODO: Display the Yes|No dialog here
result - > userdata_addr = userdata_addr ;
funcStat ( result . GetAddr ( ) , statGet . GetAddr ( ) , statSet . GetAddr ( ) ) ;
Memory . Free ( statGet - > fileList . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataFixedLoad2: CellSaveDataStatCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-04-09 18:23:14 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
/*if (statSet->setParam.IsGood())
// TODO: Write PARAM.SFO file
*/
2014-04-19 18:50:06 +02:00
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles ( funcFile , result . GetAddr ( ) , saveBaseDir + ( char * ) statGet - > dir . dirName ) ;
2014-04-09 18:23:14 +02:00
2014-04-19 18:50:06 +02:00
return ret ;
2014-03-28 20:06:15 +01:00
}
int cellSaveDataAutoSave2 ( u32 version , u32 dirName_addr , u32 errDialog , mem_ptr_t < CellSaveDataSetBuf > setBuf ,
mem_func_ptr_t < CellSaveDataStatCallback > funcStat , mem_func_ptr_t < CellSaveDataFileCallback > funcFile ,
u32 container , u32 userdata_addr )
{
2014-05-02 08:30:32 +02:00
cellSysutil - > Warning ( " cellSaveDataAutoSave2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x) " ,
2014-05-31 23:37:48 +02:00
version , dirName_addr , errDialog , setBuf . GetAddr ( ) , funcStat . GetAddr ( ) , funcFile . GetAddr ( ) , container , userdata_addr ) ;
if ( ! setBuf . IsGood ( ) | | ! funcStat . IsGood ( ) | | ! funcFile . IsGood ( ) )
return CELL_SAVEDATA_ERROR_PARAM ;
MemoryAllocator < CellSaveDataCBResult > result ;
MemoryAllocator < CellSaveDataStatGet > statGet ;
MemoryAllocator < CellSaveDataStatSet > statSet ;
std : : string saveBaseDir = " /dev_hdd0/home/00000001/savedata/ " ; // TODO: Get the path of the current user
vfsDir dir ( saveBaseDir ) ;
if ( ! dir . IsOpened ( ) )
return CELL_SAVEDATA_ERROR_INTERNAL ;
std : : string dirName = Memory . ReadString ( dirName_addr ) ;
std : : vector < SaveDataEntry > saveEntries ;
for ( const DirEntryInfo * entry = dir . Read ( ) ; entry ; entry = dir . Read ( ) )
{
if ( entry - > flags & DirEntry_TypeDir & & entry - > name = = dirName ) {
addSaveDataEntry ( saveEntries , saveBaseDir + dirName ) ;
}
}
// The target entry does not exist
if ( saveEntries . size ( ) = = 0 ) {
SaveDataEntry entry ;
entry . dirName = dirName ;
entry . sizeKB = 0 ;
entry . isNew = true ;
saveEntries . push_back ( entry ) ;
}
getSaveDataStat ( saveEntries [ 0 ] , statGet . GetAddr ( ) ) ; // There should be only one element in this list
result - > userdata_addr = userdata_addr ;
funcStat ( result . GetAddr ( ) , statGet . GetAddr ( ) , statSet . GetAddr ( ) ) ;
Memory . Free ( statGet - > fileList . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataAutoSave2: CellSaveDataStatCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-05-31 23:37:48 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
/*if (statSet->setParam.IsGood())
// TODO: Write PARAM.SFO file
*/
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles ( funcFile , result . GetAddr ( ) , saveBaseDir + ( char * ) statGet - > dir . dirName ) ;
2014-03-28 20:06:15 +01:00
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataAutoLoad2 ( u32 version , u32 dirName_addr , u32 errDialog , mem_ptr_t < CellSaveDataSetBuf > setBuf ,
mem_func_ptr_t < CellSaveDataStatCallback > funcStat , mem_func_ptr_t < CellSaveDataFileCallback > funcFile ,
u32 container , u32 userdata_addr )
{
2014-05-02 08:30:32 +02:00
cellSysutil - > Warning ( " cellSaveDataAutoLoad2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x) " ,
2014-05-31 23:37:48 +02:00
version , dirName_addr , errDialog , setBuf . GetAddr ( ) , funcStat . GetAddr ( ) , funcFile . GetAddr ( ) , container , userdata_addr ) ;
if ( ! setBuf . IsGood ( ) | | ! funcStat . IsGood ( ) | | ! funcFile . IsGood ( ) )
return CELL_SAVEDATA_ERROR_PARAM ;
MemoryAllocator < CellSaveDataCBResult > result ;
MemoryAllocator < CellSaveDataStatGet > statGet ;
MemoryAllocator < CellSaveDataStatSet > statSet ;
std : : string saveBaseDir = " /dev_hdd0/home/00000001/savedata/ " ; // TODO: Get the path of the current user
vfsDir dir ( saveBaseDir ) ;
if ( ! dir . IsOpened ( ) )
return CELL_SAVEDATA_ERROR_INTERNAL ;
std : : string dirName = Memory . ReadString ( dirName_addr ) ;
std : : vector < SaveDataEntry > saveEntries ;
for ( const DirEntryInfo * entry = dir . Read ( ) ; entry ; entry = dir . Read ( ) )
{
if ( entry - > flags & DirEntry_TypeDir & & entry - > name = = dirName ) {
addSaveDataEntry ( saveEntries , saveBaseDir + dirName ) ;
}
}
// The target entry does not exist
if ( saveEntries . size ( ) = = 0 ) {
2014-06-27 15:26:46 +02:00
LOG_WARNING ( HLE , " cellSaveDataAutoLoad2: Couldn't find save entry (%s) " , dirName . c_str ( ) ) ;
2014-06-03 22:42:15 +02:00
return CELL_OK ; // TODO: Can anyone check the actual behaviour of a PS3 when saves are not found?
2014-05-31 23:37:48 +02:00
}
getSaveDataStat ( saveEntries [ 0 ] , statGet . GetAddr ( ) ) ; // There should be only one element in this list
result - > userdata_addr = userdata_addr ;
funcStat ( result . GetAddr ( ) , statGet . GetAddr ( ) , statSet . GetAddr ( ) ) ;
Memory . Free ( statGet - > fileList . GetAddr ( ) ) ;
if ( result - > result < 0 ) {
2014-06-27 15:26:46 +02:00
LOG_ERROR ( HLE , " cellSaveDataAutoLoad2: CellSaveDataStatCallback failed. " ) ; // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
2014-05-31 23:37:48 +02:00
return CELL_SAVEDATA_ERROR_CBRESULT ;
}
/*if (statSet->setParam.IsGood())
// TODO: Write PARAM.SFO file
*/
// Enter the loop where the save files are read/created/deleted.
s32 ret = modifySaveDataFiles ( funcFile , result . GetAddr ( ) , saveBaseDir + ( char * ) statGet - > dir . dirName ) ;
2014-03-28 20:06:15 +01:00
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataListAutoSave ( ) //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile,sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataListAutoLoad ( ) //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataDelete2 ( ) //sys_memory_container_t container
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_CANCEL ;
}
int cellSaveDataFixedDelete ( ) //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserListSave ( ) //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserListLoad ( ) //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserFixedSave ( ) //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserFixedLoad ( ) //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserAutoSave ( ) //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserAutoLoad ( ) //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserListAutoSave ( ) //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserListAutoLoad ( ) //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserFixedDelete ( ) //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
//void cellSaveDataEnableOverlay(); //int enable
// Functions (Extensions)
int cellSaveDataListDelete ( ) //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataListImport ( ) //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataListExport ( ) //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataFixedImport ( ) //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataFixedExport ( ) //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataGetListItem ( ) //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserListDelete ( ) //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone,sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserListImport ( ) //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserListExport ( ) //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserFixedImport ( ) //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserFixedExport ( ) //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}
int cellSaveDataUserGetListItem ( ) //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
{
UNIMPLEMENTED_FUNC ( cellSysutil ) ;
return CELL_SAVEDATA_RET_OK ;
}