diff --git a/src/ps4_libsceappcontent.pas b/src/ps4_libsceappcontent.pas index c3985a06..31b06f7f 100644 --- a/src/ps4_libsceappcontent.pas +++ b/src/ps4_libsceappcontent.pas @@ -11,6 +11,9 @@ uses implementation +uses + sys_path; + type PSceAppContentInitParam=^SceAppContentInitParam; SceAppContentInitParam=packed record @@ -107,10 +110,19 @@ type pSceAppContentMountPoint=^SceAppContentMountPoint; SceAppContentMountPoint=array[0..SCE_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE-1] of AnsiChar; +function ps4_sceAppContentTemporaryDataFormat(mountPoint:pSceAppContentMountPoint):Integer; SysV_ABI_CDecl; +begin + Result:=FormatTmpPath(PChar(mountPoint)); +end; + +function ps4_sceAppContentTemporaryDataMount(mountPoint:pSceAppContentMountPoint):Integer; SysV_ABI_CDecl; +begin + Result:=FetchTmpMount(PChar(mountPoint),SCE_APP_CONTENT_TEMPORARY_DATA_OPTION_FORMAT); +end; + function ps4_sceAppContentTemporaryDataMount2(option:DWORD;mountPoint:pSceAppContentMountPoint):Integer; SysV_ABI_CDecl; begin - Result:=0; - Assert(false,'TODO'); + Result:=FetchTmpMount(PChar(mountPoint),option); end; function Load_libSceAppContent(Const name:RawByteString):TElf_node; @@ -125,6 +137,8 @@ begin lib^.set_proc($47D940F363AB68DB,@ps4_sceAppContentInitialize); lib^.set_proc($F7D6FCD88297A47E,@ps4_sceAppContentAppParamGetInt); lib^.set_proc($C6777C049CC0C669,@ps4_sceAppContentGetAddcontInfoList); + lib^.set_proc($6B937B9401B4CB64,@ps4_sceAppContentTemporaryDataFormat); + lib^.set_proc($EDB38B5FAE88CFF5,@ps4_sceAppContentTemporaryDataMount); lib^.set_proc($6EE61B78B3865A60,@ps4_sceAppContentTemporaryDataMount2); end; diff --git a/sys/sys_path.pas b/sys/sys_path.pas index 09f7cbab..b026c45a 100644 --- a/sys/sys_path.pas +++ b/sys/sys_path.pas @@ -23,6 +23,8 @@ Function FetchSaveMount(path,point:PChar;mode:Integer):Integer; Function UnMountSavePath(path:PChar):Integer; Function FetchTmpMount(point:PChar;mode:Integer):Integer; +Function UnMountTmpPath(point:PChar):Integer; +Function FormatTmpPath(point:PChar):Integer; function parse_filename(filename:PChar;var r:RawByteString):Integer; @@ -288,9 +290,10 @@ end; // const - SCE_APP_CONTENT_ERROR_PARAMETER=-2133262334; //0x80D90002; - SCE_APP_CONTENT_ERROR_BUSY =-2133262333; //0x80D90003; - SCE_APP_CONTENT_ERROR_INTERNAL =-2133262326; //0x80D9000A; + SCE_APP_CONTENT_ERROR_PARAMETER =-2133262334; //0x80D90002 + SCE_APP_CONTENT_ERROR_BUSY =-2133262333; //0x80D90003 + SCE_APP_CONTENT_ERROR_NOT_MOUNTED=-2133262332; //0x80D90004 + SCE_APP_CONTENT_ERROR_INTERNAL =-2133262326; //0x80D9000A M_TMP_VALUE:PChar='tmp'; @@ -300,22 +303,60 @@ var begin if (point=nil) then Exit(SCE_APP_CONTENT_ERROR_PARAMETER); - if XCHG(FTmpMount,1)<>0 then Exit(SCE_APP_CONTENT_ERROR_BUSY); - - Move(M_TMP_VALUE,point^,Length(M_TMP_VALUE)+1); - Case mode of 0:; - 1:begin //format - S:=IncludeTrailingPathDelimiter(GetCurrentDir)+M_TMP_VALUE; - DeleteDirectory(S,False); - end; + 1:; else Exit(SCE_APP_CONTENT_ERROR_PARAMETER); end; + if not CAS(FTmpMount,0,1) then Exit(SCE_APP_CONTENT_ERROR_BUSY); + + PDWORD(point)^:=$00706D74; //tmp + + S:=IncludeTrailingPathDelimiter(GetCurrentDir)+M_TMP_VALUE; + + if (mode=1) then //format + begin + DeleteDirectory(S,False); + end; + CreateDir(S); + XCHG(FTmpMount,2); + Result:=0; +end; + +Function UnMountTmpPath(point:PChar):Integer; +begin + if (point=nil) then Exit(SCE_APP_CONTENT_ERROR_PARAMETER); + + if (PDWORD(point)^<>$00706D74) then //tmp + begin + Exit(SCE_APP_CONTENT_ERROR_NOT_MOUNTED); + end; + + if not CAS(FTmpMount,2,0) then Exit(SCE_APP_CONTENT_ERROR_NOT_MOUNTED); + + Result:=0; +end; + +Function FormatTmpPath(point:PChar):Integer; +var + S:RawByteString; +begin + if (point=nil) then Exit(SCE_APP_CONTENT_ERROR_PARAMETER); + + if (PDWORD(point)^<>$00706D74) then //tmp + begin + Exit(SCE_APP_CONTENT_ERROR_NOT_MOUNTED); + end; + + if (FTmpMount<>2) then Exit(SCE_APP_CONTENT_ERROR_NOT_MOUNTED); + + S:=IncludeTrailingPathDelimiter(GetCurrentDir)+M_TMP_VALUE; + DeleteDirectory(S,False); + Result:=0; end; @@ -323,7 +364,7 @@ function MountTmpConcat(const filename:RawByteString;var r:RawByteString):Intege var S:RawByteString; begin - if (FTmpMount=0) then Exit(PT_ERR); + if (FTmpMount<>2) then Exit(PT_ERR); S:=IncludeTrailingPathDelimiter(GetCurrentDir)+M_TMP_VALUE;