mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: GetAppDataDir function
This commit is contained in:
parent
c3a941c369
commit
be5735f1dd
2 changed files with 39 additions and 4 deletions
|
|
@ -22,7 +22,11 @@
|
|||
|
||||
unit uOSUtils;
|
||||
|
||||
{$mode delphi}{$H+}
|
||||
{$mode delphi}
|
||||
|
||||
{$IFDEF DARWIN}
|
||||
{$modeswitch objectivec1}
|
||||
{$ENDIF}
|
||||
|
||||
interface
|
||||
|
||||
|
|
@ -176,6 +180,7 @@ function GetAppConfigDir: String;
|
|||
@returns(The directory for the application's cache files)
|
||||
}
|
||||
function GetAppCacheDir: String;
|
||||
function GetAppDataDir: String;
|
||||
function GetTempFolder: String;
|
||||
|
||||
{ Similar to "GetTempFolder" but that we can unilaterally delete at the end when closin application}
|
||||
|
|
@ -250,8 +255,10 @@ uses
|
|||
{$ENDIF}
|
||||
{$IF DEFINED(UNIX)}
|
||||
, BaseUnix, Unix, uMyUnix, dl
|
||||
{$IF NOT DEFINED(DARWIN)}
|
||||
, uGio, uClipboard, uKde
|
||||
{$IF DEFINED(DARWIN)}
|
||||
, CocoaAll, uMyDarwin
|
||||
{$ELSE}
|
||||
, uGio, uClipboard, uXdg, uKde
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
;
|
||||
|
|
@ -871,7 +878,7 @@ begin
|
|||
end;
|
||||
{$ELSEIF DEFINED(DARWIN)}
|
||||
begin
|
||||
Result:= GetHomeDir + '/Library/Caches/' + ApplicationName;
|
||||
Result:= NSGetFolderPath(NSCachesDirectory);
|
||||
end;
|
||||
{$ELSE}
|
||||
var
|
||||
|
|
@ -885,6 +892,21 @@ begin
|
|||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function GetAppDataDir: String;
|
||||
{$IF DEFINED(MSWINDOWS)}
|
||||
begin
|
||||
Result:= GetAppCacheDir;
|
||||
end;
|
||||
{$ELSEIF DEFINED(DARWIN)}
|
||||
begin
|
||||
Result:= NSGetFolderPath(NSApplicationSupportDirectory);
|
||||
end;
|
||||
{$ELSE}
|
||||
begin
|
||||
Result:= IncludeTrailingPathDelimiter(GetUserDataDir) + ApplicationName;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function GetTempFolder: String;
|
||||
begin
|
||||
Result:= GetTempDir + '_dc';
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ uses
|
|||
function StringToNSString(const S: String): NSString;
|
||||
function StringToCFStringRef(const S: String): CFStringRef;
|
||||
|
||||
function NSGetFolderPath(Folder: NSSearchPathDirectory): String;
|
||||
|
||||
function GetFileDescription(const FileName: String): String;
|
||||
function MountNetworkDrive(const serverAddress: String): Boolean;
|
||||
|
||||
|
|
@ -54,6 +56,17 @@ begin
|
|||
Result:= CFStringCreateWithCString(nil, PAnsiChar(S), kCFStringEncodingUTF8);
|
||||
end;
|
||||
|
||||
function NSGetFolderPath(Folder: NSSearchPathDirectory): String;
|
||||
var
|
||||
Path: NSArray;
|
||||
begin
|
||||
Path:= NSFileManager.defaultManager.URLsForDirectory_inDomains(Folder, NSUserDomainMask);
|
||||
if Path.count > 0 then
|
||||
begin
|
||||
Result:= IncludeTrailingBackslash(NSURL(Path.objectAtIndex(0)).path) + ApplicationName;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetFileDescription(const FileName: String): String;
|
||||
var
|
||||
Error: NSError;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue