mirror of https://github.com/red-prig/fpPS4.git
ForEachRootDir
This commit is contained in:
parent
38a18ed2c0
commit
85e8e21a5c
|
@ -11,7 +11,8 @@ uses
|
|||
RWLock,
|
||||
sys_kernel,
|
||||
sys_time,
|
||||
sys_fd;
|
||||
sys_fd,
|
||||
sys_path;
|
||||
|
||||
const
|
||||
// File types
|
||||
|
@ -68,6 +69,7 @@ type
|
|||
function fstat (stat:PSceKernelStat):Integer; override;
|
||||
function lseek (offset:Int64;whence:Integer):Int64; override;
|
||||
function getdirentries(buf:Pointer;nbytes:Int64;basep:PInt64):Int64; override;
|
||||
procedure add_dir(const name:RawByteString);
|
||||
end;
|
||||
|
||||
function get_d_type(dwFileAttributes:DWORD):BYTE;
|
||||
|
@ -256,21 +258,6 @@ function _sys_root_open(const path:RawByteString;flags,mode:Integer):Integer;
|
|||
var
|
||||
f:TDirFile;
|
||||
|
||||
procedure add_dir(name:RawByteString);
|
||||
var
|
||||
tmp:dirent;
|
||||
i:Integer;
|
||||
begin
|
||||
tmp:=Default(dirent);
|
||||
|
||||
i:=Length(f.dirs);
|
||||
move_name(i,DT_DIR,name,@tmp);
|
||||
|
||||
i:=Length(f.dirs);
|
||||
SetLength(f.dirs,i+1);
|
||||
f.dirs[i]:=tmp;
|
||||
end;
|
||||
|
||||
begin
|
||||
Result:=0;
|
||||
|
||||
|
@ -279,11 +266,7 @@ begin
|
|||
|
||||
SetLength(f.dirs,0);
|
||||
|
||||
add_dir('.');
|
||||
add_dir('..');
|
||||
add_dir('app0');
|
||||
add_dir('dev');
|
||||
add_dir('sys');
|
||||
ForEachRootDir(@f.add_dir);
|
||||
|
||||
Result:=_sys_open_fd(f,flags);
|
||||
|
||||
|
@ -465,6 +448,21 @@ begin
|
|||
Result:=count*SizeOf(dirent);
|
||||
end;
|
||||
|
||||
procedure TDirFile.add_dir(const name:RawByteString);
|
||||
var
|
||||
tmp:dirent;
|
||||
i:Integer;
|
||||
begin
|
||||
tmp:=Default(dirent);
|
||||
|
||||
i:=Length(dirs);
|
||||
move_name(i,DT_DIR,name,@tmp);
|
||||
|
||||
i:=Length(dirs);
|
||||
SetLength(dirs,i+1);
|
||||
dirs[i]:=tmp;
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
end.
|
||||
|
|
|
@ -32,6 +32,11 @@ Function GetDownloadAvailableSpaceKb(point:PChar;size:PQWORD):Integer;
|
|||
|
||||
function parse_filename(filename:PChar;var r:RawByteString):Integer;
|
||||
|
||||
type
|
||||
TFeDirCb=procedure(const S:RawByteString) of object;
|
||||
|
||||
Procedure ForEachRootDir(add_dir:TFeDirCb);
|
||||
|
||||
implementation
|
||||
|
||||
const
|
||||
|
@ -463,7 +468,7 @@ end;
|
|||
|
||||
//
|
||||
|
||||
function MountDownloadConcat(id:Byte;const filename:RawByteString;var r:RawByteString):Integer;
|
||||
function MountDownloadConcat(id:Byte;force:Boolean;const filename:RawByteString;var r:RawByteString):Integer;
|
||||
var
|
||||
S:RawByteString;
|
||||
begin
|
||||
|
@ -475,7 +480,11 @@ begin
|
|||
|
||||
//param.sfo download size TODO
|
||||
S:=download_path(id);
|
||||
if not ForceDirectories(S) then Exit(PT_ERR);
|
||||
|
||||
if force then
|
||||
begin
|
||||
if not ForceDirectories(S) then Exit(PT_ERR);
|
||||
end;
|
||||
|
||||
Result:=PathConcat(S,filename,r);
|
||||
end;
|
||||
|
@ -489,6 +498,69 @@ begin
|
|||
Result:=PathConcat(s,filename,r);
|
||||
end;
|
||||
|
||||
Procedure ForEachRootDir(add_dir:TFeDirCb);
|
||||
var
|
||||
i:Integer;
|
||||
r:RawByteString;
|
||||
begin
|
||||
if (add_dir=nil) then Exit;
|
||||
|
||||
add_dir('.');
|
||||
add_dir('..');
|
||||
add_dir('app0');
|
||||
|
||||
if (ps4_app.app1_path<>'') then
|
||||
begin
|
||||
add_dir('app1');
|
||||
end;
|
||||
|
||||
r:='';
|
||||
if (MountMiscConcat('data','',r)=PT_FILE) then
|
||||
if DirectoryExists(r) then
|
||||
begin
|
||||
add_dir('data');
|
||||
end;
|
||||
|
||||
add_dir('dev');
|
||||
|
||||
For i:=0 to 15 do
|
||||
begin
|
||||
r:='';
|
||||
if (MountDownloadConcat(i,False,'',r)=PT_FILE) then
|
||||
if DirectoryExists(r) then
|
||||
begin
|
||||
add_dir('download'+IntToStr(i));
|
||||
end;
|
||||
end;
|
||||
|
||||
For i:=0 to 1 do
|
||||
begin
|
||||
r:='';
|
||||
if (MountSaveConcat(i,'',r)=PT_FILE) then
|
||||
if DirectoryExists(r) then
|
||||
begin
|
||||
add_dir('savedata'+IntToStr(i));
|
||||
end;
|
||||
end;
|
||||
|
||||
add_dir('sys'); //aka sceKernelGetFsSandboxRandomWord
|
||||
|
||||
r:='';
|
||||
if (MountTmpConcat('',r)=PT_FILE) then
|
||||
if DirectoryExists(r) then
|
||||
begin
|
||||
add_dir('temp0');
|
||||
end;
|
||||
|
||||
r:='';
|
||||
if (MountMiscConcat('usr','',r)=PT_FILE) then
|
||||
if DirectoryExists(r) then
|
||||
begin
|
||||
add_dir('usr');
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
const
|
||||
|
@ -565,7 +637,7 @@ begin
|
|||
'0'..'1':
|
||||
begin
|
||||
if (fp^<>#0) then Inc(fp);
|
||||
Result:=MountDownloadConcat(ord((pp+8)^)-ord('0'),fp,r);
|
||||
Result:=MountDownloadConcat(ord((pp+8)^)-ord('0'),True,fp,r);
|
||||
end;
|
||||
else
|
||||
Result:=PT_ERR;
|
||||
|
|
Loading…
Reference in New Issue