Browse Source

* Patch from Bart B to implement TPath.DesktopPath and TPath.AppPath

Michaël Van Canneyt 1 year ago
parent
commit
92e86cb11d
1 changed files with 21 additions and 0 deletions
  1. 21 0
      packages/vcl-compat/src/system.ioutils.pp

+ 21 - 0
packages/vcl-compat/src/system.ioutils.pp

@@ -199,8 +199,10 @@ type
     class function GetTempPath: string;
     class function GetTempPath: string;
     class function GetHomePath: string;
     class function GetHomePath: string;
     class function GetDocumentsPath: string;
     class function GetDocumentsPath: string;
+    class function GetDesktopPath: string;
     class function GetSharedDocumentsPath: string;
     class function GetSharedDocumentsPath: string;
     class function GetLibraryPath: string;
     class function GetLibraryPath: string;
+    class function GetAppPath: string;
     class function GetCachePath: string;
     class function GetCachePath: string;
     class function GetPublicPath: string;
     class function GetPublicPath: string;
     class function GetPicturesPath: string;
     class function GetPicturesPath: string;
@@ -1139,6 +1141,20 @@ begin
   {$ENDIF}
   {$ENDIF}
 end;
 end;
 
 
+class function TPath.GetDesktopPath: string;
+begin
+  Result:='';
+  {$IfDef MSWINDOWS}
+    Result:=GetWindowsSpecialDir(CSIDL_DESKTOPDIRECTORY, False);
+  {$ELSE}
+    {$IFDEF UNIX}
+      Result:=GetSpecialDir(sdDesktop);
+    {$ELSE}
+      Result:=GetUserDir;
+    {$ENDIF}
+  {$EndIf}
+end;
+
 class function TPath.GetSharedDocumentsPath: string;
 class function TPath.GetSharedDocumentsPath: string;
 begin
 begin
   Result:='';
   Result:='';
@@ -1162,6 +1178,11 @@ begin
 {$ENDIF}
 {$ENDIF}
 end;
 end;
 
 
+class function TPath.GetAppPath: string;
+begin
+  Result:=ExtractFilePath(ParamStr(0));
+end;
+
 class function TPath.GetCachePath: string;
 class function TPath.GetCachePath: string;
 begin
 begin
   {$IfDef MSWINDOWS}
   {$IfDef MSWINDOWS}