mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-01-06 11:30:44 +01:00
* Added GetUSerDir function (ID 11338)
git-svn-id: trunk@11074 -
This commit is contained in:
parent
b6c43bad7d
commit
26575472b6
@ -121,6 +121,12 @@ begin
|
||||
Result:=GetAppConfigFile(Global,False);
|
||||
end;
|
||||
|
||||
Function DGetUserDir : String;
|
||||
|
||||
begin
|
||||
Result:=ExtractFilePath(Paramstr(0));
|
||||
end;
|
||||
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Fallback implementations for AppConfigDir implementation.
|
||||
@ -146,6 +152,26 @@ begin
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Fallback implementations for GetUserDir implementation.
|
||||
---------------------------------------------------------------------}
|
||||
{
|
||||
If a particular OS does it different:
|
||||
- set the HAVE_OSUSERDIR define before including sysutils.inc.
|
||||
- implement the function.
|
||||
Default makes it the application directory. Rationale is that the result
|
||||
will be used for config files, and it should exist. The application directory
|
||||
has this for sure.
|
||||
}
|
||||
|
||||
{$ifndef HAS_OSUSERDIR}
|
||||
Function GetUserDir : String;
|
||||
|
||||
begin
|
||||
Result:=DGetUserDir;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Get temporary directory name
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
@ -37,6 +37,7 @@ function GetTempFileName(Dir,Prefix: PChar; uUnique: DWORD; TempFileName: PChar)
|
||||
Function GetAppConfigDir(Global : Boolean) : String;
|
||||
Function GetAppConfigFile(Global : Boolean) : String;
|
||||
Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
|
||||
Function GetUserDir : String;
|
||||
Function VendorName : String;
|
||||
Function ApplicationName : String;
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ interface
|
||||
{$DEFINE HAS_TEMPDIR}
|
||||
{$DEFINE HASUNIX}
|
||||
{$DEFINE HASCREATEGUID}
|
||||
{$DEFINE HAS_OSUSERDIR}
|
||||
|
||||
uses
|
||||
Unix,errors,sysconst,Unixtype;
|
||||
@ -1039,7 +1040,7 @@ end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
Initialization code
|
||||
GetTempDir
|
||||
****************************************************************************}
|
||||
|
||||
|
||||
@ -1060,6 +1061,27 @@ begin
|
||||
Result:=IncludeTrailingPathDelimiter(Result);
|
||||
end;
|
||||
|
||||
{****************************************************************************
|
||||
GetUserDir
|
||||
****************************************************************************}
|
||||
|
||||
Var
|
||||
TheUserDir : String;
|
||||
|
||||
Function GetUserDir : String;
|
||||
|
||||
begin
|
||||
If (TheUserDir='') then
|
||||
begin
|
||||
TheUserDir:=GetEnvironmentVariable('HOME');
|
||||
if (TheUserDir<>'') then
|
||||
TheUserDir:=IncludeTrailingPathDelimiter(TheUserDir)
|
||||
else
|
||||
TheUserDir:=GetTempDir(False);
|
||||
end;
|
||||
Result:=TheUserDir;
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
Initialization code
|
||||
|
||||
@ -27,6 +27,7 @@ uses
|
||||
{$DEFINE HAS_SLEEP}
|
||||
{$DEFINE HAS_OSERROR}
|
||||
{$DEFINE HAS_OSCONFIG}
|
||||
{$DEFINE HAS_OSUSERDIR}
|
||||
{$DEFINE HAS_CREATEGUID}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
@ -1061,6 +1062,12 @@ begin
|
||||
result:=DGetAppConfigFile(Global,SubDir);
|
||||
end;
|
||||
|
||||
Function GetUserDir : String;
|
||||
|
||||
begin
|
||||
Result:=GetSpecialDir(CSIDL_PROFILE);
|
||||
end;
|
||||
|
||||
Procedure InitSysConfigDir;
|
||||
|
||||
begin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user