sceAppContentDownloadDataGetAvailableSpaceKb

This commit is contained in:
red-prig 2022-12-11 17:25:44 +03:00
parent ae103ec9aa
commit ab085657cb
2 changed files with 46 additions and 4 deletions

View File

@ -139,6 +139,13 @@ begin
_sig_unlock;
end;
function ps4_sceAppContentDownloadDataGetAvailableSpaceKb(mountPoint:pSceAppContentMountPoint;availableSpaceKb:PQWORD):Integer; SysV_ABI_CDecl;
begin
_sig_lock;
Result:=GetDownloadAvailableSpaceKb(PChar(mountPoint),availableSpaceKb);
_sig_unlock;
end;
function Load_libSceAppContent(Const name:RawByteString):TElf_node;
var
lib:PLIBRARY;
@ -155,6 +162,7 @@ begin
lib^.set_proc($EDB38B5FAE88CFF5,@ps4_sceAppContentTemporaryDataMount);
lib^.set_proc($6EE61B78B3865A60,@ps4_sceAppContentTemporaryDataMount2);
lib^.set_proc($49A2A26F6520D322,@ps4_sceAppContentTemporaryDataGetAvailableSpaceKb);
lib^.set_proc($1A5EB0E62D09A246,@ps4_sceAppContentDownloadDataGetAvailableSpaceKb);
end;

View File

@ -26,7 +26,10 @@ Function UnMountSavePath(path:PChar):Integer;
Function FetchTmpMount(point:PChar;mode:Integer):Integer;
Function UnMountTmpPath(point:PChar):Integer;
Function FormatTmpPath(point:PChar):Integer;
Function GetTmpPathAvailableSpaceKb(point:PChar;size:PQWORD):Integer;
Function GetDownloadAvailableSpaceKb(point:PChar;size:PQWORD):Integer;
function parse_filename(filename:PChar;var r:RawByteString):Integer;
@ -297,11 +300,14 @@ const
SCE_APP_CONTENT_ERROR_NOT_MOUNTED=-2133262332; //0x80D90004
SCE_APP_CONTENT_ERROR_INTERNAL =-2133262326; //0x80D9000A
M_TMP_VALUE:PChar='tmp';
function temp_path:RawByteString;
begin
Result:=IncludeTrailingPathDelimiter(GetCurrentDir)+M_TMP_VALUE;
Result:=IncludeTrailingPathDelimiter(GetCurrentDir)+'tmp';
end;
function download_path(id:Byte):RawByteString;
begin
Result:=IncludeTrailingPathDelimiter(GetCurrentDir)+'download'+IntToStr(id);
end;
Function FetchTmpMount(point:PChar;mode:Integer):Integer;
@ -406,6 +412,34 @@ begin
end;
end;
Function GetDownloadAvailableSpaceKb(point:PChar;size:PQWORD):Integer;
var
S:RawByteString;
W:WideString;
bytes:Int64;
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:=download_path(0);
W:=UTF8Decode(S);
if GetDiskFreeSpaceExW(PWideChar(W),@bytes,nil,nil) then
begin
size^:=bytes div 1024;
Result:=0;
end else
begin
Result:=SCE_APP_CONTENT_ERROR_INTERNAL;
end;
end;
//
function MountDownloadConcat(id:Byte;const filename:RawByteString;var r:RawByteString):Integer;
@ -419,7 +453,7 @@ begin
end;
//param.sfo download size TODO
S:=IncludeTrailingPathDelimiter(GetCurrentDir)+'download'+IntToStr(id);
S:=download_path(id);
if not ForceDirectories(S) then Exit(PT_ERR);
Result:=PathConcat(S,filename,r);