This commit is contained in:
red-prig 2022-11-30 19:19:06 +03:00
parent 800db7aa37
commit 540c9351a2
2 changed files with 108 additions and 2 deletions

View File

@ -58,6 +58,9 @@ function ps4_sceKernelMkdir(path:PChar;mode:Integer):Integer; SysV_ABI_CDecl;
function ps4_unlink(path:PChar):Integer; SysV_ABI_CDecl;
function ps4_sceKernelUnlink(path:PChar):Integer; SysV_ABI_CDecl;
function ps4_rmdir(path:PChar):Integer; SysV_ABI_CDecl;
function ps4_sceKernelRmdir(path:PChar):Integer; SysV_ABI_CDecl;
function ps4_sceKernelCheckReachability(path:PChar):Integer; SysV_ABI_CDecl;
implementation
@ -747,7 +750,7 @@ begin
Result:=px2sce(Result);
end;
Function SwDelete(Const path:RawByteString):DWORD;
Function SwDeleteFile(Const path:RawByteString):DWORD;
var
W:WideString;
begin
@ -788,7 +791,7 @@ begin
Exit(EACCES);
end;
err:=SwDelete(fn);
err:=SwDeleteFile(fn);
if (err<>0) then
begin
@ -842,6 +845,106 @@ begin
Result:=px2sce(Result);
end;
Function SwRemoveDirectory(Const path:RawByteString):DWORD;
var
W:WideString;
begin
Result:=0;
_sig_lock;
W:=UTF8Decode(path);
if not RemoveDirectoryW(PWideChar(W)) then
begin
Result:=GetLastError;
end;
_sig_unlock;
end;
function _sys_rmdir(path:PChar):Integer;
var
fn:RawByteString;
err:DWORD;
begin
Result:=0;
if (path=nil) then Exit(EINVAL);
if (path[0]=#0) then
begin
Exit(ENOENT);
end;
Writeln('rmdir:',path);
fn:='';
Result:=parse_filename(path,fn);
Case Result of
PT_ROOT:Exit(EEXIST); //TODO
PT_FILE:;
PT_DEV :Exit(EACCES);
else
Exit(EACCES);
end;
err:=SwRemoveDirectory(fn);
if (err<>0) then
begin
Case err of
ERROR_DIRECTORY,
ERROR_INVALID_DRIVE,
ERROR_PATH_NOT_FOUND,
ERROR_FILE_NOT_FOUND:
Exit(ENOENT);
ERROR_CURRENT_DIRECTORY,
ERROR_ACCESS_DENIED,
ERROR_SHARING_VIOLATION,
ERROR_LOCK_VIOLATION,
ERROR_SHARING_BUFFER_EXCEEDED:
Exit(EACCES);
ERROR_BUFFER_OVERFLOW:
Exit(ENAMETOOLONG);
ERROR_NOT_ENOUGH_MEMORY:
Exit(ENOMEM);
ERROR_ALREADY_EXISTS,
ERROR_FILE_EXISTS:
Exit(EEXIST);
ERROR_DISK_FULL:
Exit(ENOSPC);
ERROR_DIR_NOT_EMPTY:
Exit(ENOTEMPTY);
else
Exit(EIO);
end;
end;
Result:=0;
end;
function ps4_rmdir(path:PChar):Integer; SysV_ABI_CDecl;
begin
_sig_lock;
Result:=_set_errno(_sys_rmdir(path));
_sig_unlock;
end;
function ps4_sceKernelRmdir(path:PChar):Integer; SysV_ABI_CDecl;
begin
_sig_lock;
Result:=_sys_rmdir(path);
_sig_unlock;
_set_errno(Result);
Result:=px2sce(Result);
end;
function ps4_sceKernelCheckReachability(path:PChar):Integer; SysV_ABI_CDecl;
var
fn:RawByteString;

View File

@ -1082,6 +1082,9 @@ begin
lib^.set_proc($540CECC2F4CE0B32,@ps4_unlink);
lib^.set_proc($0145D5C5678953F0,@ps4_sceKernelUnlink);
lib^.set_proc($73B6674FB57507DF,@ps4_rmdir);
lib^.set_proc($9DA22752362DDECA,@ps4_sceKernelRmdir);
lib^.set_proc($B96C96DEFF7CB14E,@ps4_sceKernelCheckReachability);
//file