mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-02 13:19:34 +01:00
* moved SYSUTILS_HAS_ANSISTR/UNICODESTR_FILEUTIL_IMPL define to interface
so declarations can also depend on it and similar defines (not yet the
case)
+ added SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL/SYSUTILS_HAS_UNICODESTR_ENVVAR_IMPL
to indicate whether the platform-dependent part of the unit provides
an ansistring/unicodestring interface to get environment variables
+ Windows version of getenvironmentvariable(unicodestring)
+ generic ansistring/unicodestring versions of GetEnvironmentVariable()
in case the platform doesn't provide them
* result of GetEnvironmentString() is ansistring/unicodestring depending
on the state of the FPC_RTL_UNICODE define
git-svn-id: branches/cpstrrtl@25116 -
This commit is contained in:
parent
09014e8716
commit
155aafc255
@ -26,6 +26,12 @@ interface
|
||||
{$H+}
|
||||
|
||||
{$DEFINE HAS_SLEEP}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -42,9 +48,6 @@ uses dos,sysconst;
|
||||
{$DEFINE FPC_FEXPAND_DRIVESEP_IS_ROOT}
|
||||
{$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -562,7 +565,7 @@ begin
|
||||
Result:=Dos.envCount;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -20,6 +20,11 @@ unit sysutils;
|
||||
|
||||
interface
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -28,9 +33,6 @@ implementation
|
||||
uses
|
||||
sysconst,heapmgr;
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -228,7 +230,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
begin
|
||||
result := '';
|
||||
end;
|
||||
|
||||
@ -26,6 +26,12 @@ uses
|
||||
Dos;
|
||||
|
||||
{$DEFINE HAS_SLEEP}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -38,9 +44,6 @@ implementation
|
||||
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
||||
{$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -1208,7 +1211,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP (EnvP, Index);
|
||||
|
||||
@ -32,6 +32,11 @@ interface
|
||||
{$DEFINE HAS_SLEEP}
|
||||
{$DEFINE HAS_OSERROR}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -41,9 +46,6 @@ implementation
|
||||
uses
|
||||
dos, sysconst;
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -269,7 +271,7 @@ begin
|
||||
result := -1;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
begin
|
||||
result := '';
|
||||
end;
|
||||
|
||||
@ -28,6 +28,12 @@ uses
|
||||
go32,dos;
|
||||
|
||||
{$DEFINE HAS_SLEEP}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -40,9 +46,6 @@ implementation
|
||||
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
||||
{$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -781,7 +784,7 @@ begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -44,6 +44,11 @@ type
|
||||
exactMatch: Boolean;
|
||||
end;
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -58,9 +63,6 @@ uses
|
||||
{$DEFINE FPC_FEXPAND_NO_DOTS_UPDIR}
|
||||
{$DEFINE FPC_FEXPAND_NO_CURDIR}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -642,7 +644,7 @@ begin
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -28,6 +28,12 @@ interface
|
||||
{$DEFINE OS_FILESETDATEBYNAME}
|
||||
{$DEFINE HAS_SLEEP}
|
||||
{$DEFINE HAS_OSERROR}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -44,9 +50,6 @@ uses dos,sysconst;
|
||||
{$DEFINE FPC_FEXPAND_DRIVESEP_IS_ROOT}
|
||||
{$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -628,7 +631,7 @@ begin
|
||||
Result:=Dos.envCount;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -28,6 +28,12 @@ uses
|
||||
{go32,}dos;
|
||||
|
||||
{$DEFINE HAS_SLEEP}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -40,9 +46,6 @@ implementation
|
||||
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
||||
{$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -764,7 +767,7 @@ begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -39,6 +39,12 @@ type
|
||||
LastRes: NTSTATUS;
|
||||
end;
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_UNICODESTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API (actually it's
|
||||
unicodestring, but that's not yet implemented) }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -49,9 +55,6 @@ implementation
|
||||
|
||||
{$DEFINE FPC_NOGENERICANSIROUTINES}
|
||||
|
||||
{ used OS file system APIs use unicodestring }
|
||||
{$define SYSUTILS_HAS_UNICODESTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -1060,7 +1063,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetEnvironmentString(Index: Integer): String;
|
||||
function GetEnvironmentString(Index: Integer): {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
var
|
||||
hp : pwidechar;
|
||||
len: sizeint;
|
||||
@ -1071,15 +1074,19 @@ begin
|
||||
begin
|
||||
while (hp^<>#0) and (Index>1) do
|
||||
begin
|
||||
Dec(Index);
|
||||
hp:=hp+wstrlen(hp)+1;
|
||||
Dec(Index);
|
||||
hp:=hp+wstrlen(hp)+1;
|
||||
end;
|
||||
If (hp^<>#0) then
|
||||
begin
|
||||
{$ifdef FPC_RTL_UNICODE}
|
||||
Result:=hp;
|
||||
{$else}
|
||||
len:=UnicodeToUTF8(Nil, hp, 0);
|
||||
SetLength(Result, len);
|
||||
UnicodeToUTF8(PChar(Result), hp, len);
|
||||
SetCodePage(RawByteString(Result),CP_UTF8,false);
|
||||
{$endif}
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -29,6 +29,11 @@ interface
|
||||
{ force ansistrings }
|
||||
{$H+}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -37,9 +42,6 @@ implementation
|
||||
uses
|
||||
sysconst;
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -285,7 +287,7 @@ begin
|
||||
result := -1;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
begin
|
||||
result := '';
|
||||
end;
|
||||
|
||||
@ -29,6 +29,11 @@ uses DOS;
|
||||
{$DEFINE HAS_SLEEP}
|
||||
{$DEFINE HAS_OSERROR}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
TYPE
|
||||
TNetwareFindData =
|
||||
RECORD
|
||||
@ -77,9 +82,6 @@ implementation
|
||||
{$define FPC_FEXPAND_VOLUMES}
|
||||
{$define FPC_FEXPAND_NO_DEFAULT_PATHS}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -521,7 +523,7 @@ begin
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -79,6 +79,11 @@ implementation
|
||||
{$DEFINE FPC_FEXPAND_VOLUMES}
|
||||
{$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
@ -587,7 +592,7 @@ begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -73,6 +73,23 @@ begin
|
||||
Result:=EP^;
|
||||
end;
|
||||
|
||||
{ these are extremely inefficient, but not much we can do about it because
|
||||
changing their result type based on the supported OS-interfaces will change
|
||||
program behaviour if they are passed as a parameter to overloaded routines }
|
||||
{$ifndef SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
Function GetEnvironmentVariable(Const EnvVar : AnsiString) : AnsiString;
|
||||
begin
|
||||
result:=AnsiString(GetEnvironmentVariable(UnicodeString(EnvVar)));
|
||||
end;
|
||||
{$endif not SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{$ifndef SYSUTILS_HAS_UNICODESTR_ENVVAR_IMPL}
|
||||
Function GetEnvironmentVariable(Const EnvVar : UnicodeString) : UnicodeString;
|
||||
begin
|
||||
result:=UnicodeString(GetEnvironmentVariable(AnsiString(EnvVar)));
|
||||
end;
|
||||
{$endif not SYSUTILS_HAS_UNICODESTR_ENVVAR_IMPL}
|
||||
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Application name
|
||||
|
||||
@ -21,9 +21,11 @@ Function GetLastOSError : Integer;
|
||||
{$endif}
|
||||
Procedure RaiseLastOSError;overload;
|
||||
Procedure RaiseLastOSError(LastError: Integer);overload;
|
||||
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||
|
||||
Function GetEnvironmentVariable(Const EnvVar : AnsiString) : AnsiString;
|
||||
Function GetEnvironmentVariable(Const EnvVar : UnicodeString) : UnicodeString;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
{$IFDEF HAS_SLEEP}
|
||||
procedure Sleep(milliseconds: Cardinal);
|
||||
{$ENDIF}
|
||||
|
||||
@ -23,6 +23,12 @@ interface
|
||||
{$H+}
|
||||
|
||||
{$DEFINE HAS_SLEEP}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -43,9 +49,6 @@ type
|
||||
{$DEFINE HAS_GETTICKCOUNT}
|
||||
{$DEFINE HAS_GETTICKCOUNT64}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -608,7 +611,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP (EnvP, Index);
|
||||
|
||||
@ -35,6 +35,12 @@ interface
|
||||
{$DEFINE HAS_OSUSERDIR}
|
||||
{$DEFINE HAS_LOCALTIMEZONEOFFSET}
|
||||
{$DEFINE HAS_GETTICKCOUNT64}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
uses
|
||||
Unix,errors,sysconst,Unixtype;
|
||||
|
||||
@ -265,9 +271,6 @@ procedure UnhookSignal(RtlSigNum: Integer; OnlyIfHooked: Boolean = True);
|
||||
{$DEFINE FPC_FEXPAND_TILDE} { Tilde is expanded to home }
|
||||
{$DEFINE FPC_FEXPAND_GETENVPCHAR} { GetEnv result is a PChar }
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -1149,7 +1152,7 @@ begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -28,6 +28,12 @@ uses
|
||||
watcom,dos;
|
||||
|
||||
{$DEFINE HAS_SLEEP}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -40,9 +46,6 @@ implementation
|
||||
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
||||
{$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -764,7 +767,7 @@ begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
|
||||
@ -29,18 +29,19 @@ interface
|
||||
{ force ansistrings }
|
||||
{$H+}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
dos, sysconst;
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -241,7 +242,7 @@ begin
|
||||
result := -1;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
begin
|
||||
result := '';
|
||||
end;
|
||||
|
||||
@ -33,6 +33,14 @@ uses
|
||||
{$DEFINE HAS_LOCALTIMEZONEOFFSET}
|
||||
{$DEFINE HAS_GETTICKCOUNT}
|
||||
{$DEFINE HAS_GETTICKCOUNT64}
|
||||
|
||||
{ used OS file system APIs use unicodestring }
|
||||
{$define SYSUTILS_HAS_UNICODESTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
{ OS has a unicodestring/two byte environment variable API }
|
||||
{$define SYSUTILS_HAS_UNICODESTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -153,9 +161,6 @@ function GetFileVersion(const AFileName:string):Cardinal;
|
||||
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
||||
{$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_UNICODESTR_FILEUTIL_IMPL}
|
||||
|
||||
function ConvertEraYearString(Count ,Year,Month,Day : integer) : string; forward;
|
||||
function ConvertEraString(Count ,Year,Month,Day : integer) : string; forward;
|
||||
{ Include platform independent implementation part }
|
||||
@ -975,6 +980,32 @@ begin
|
||||
FreeEnvironmentStringsA(p);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariable(Const EnvVar : UnicodeString) : UnicodeString;
|
||||
|
||||
var
|
||||
s, upperenv : Unicodestring;
|
||||
i : longint;
|
||||
hp,p : pwidechar;
|
||||
begin
|
||||
Result:='';
|
||||
p:=GetEnvironmentStringsW;
|
||||
hp:=p;
|
||||
upperenv:=uppercase(envvar);
|
||||
while hp^<>#0 do
|
||||
begin
|
||||
s:=hp;
|
||||
i:=pos('=',s);
|
||||
if uppercase(copy(s,1,i-1))=upperenv then
|
||||
begin
|
||||
Result:=copy(s,i+1,length(s)-i);
|
||||
break;
|
||||
end;
|
||||
{ next string entry}
|
||||
hp:=hp+strlen(hp)+1;
|
||||
end;
|
||||
FreeEnvironmentStringsW(p);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
var
|
||||
@ -992,10 +1023,13 @@ begin
|
||||
FreeEnvironmentStringsA(p);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
|
||||
var
|
||||
hp,p : pchar;
|
||||
{$ifdef FPC_RTL_UNICODE}
|
||||
tmpstr : RawByteString;
|
||||
{$endif}
|
||||
begin
|
||||
Result:='';
|
||||
p:=GetEnvironmentStringsA;
|
||||
@ -1009,8 +1043,14 @@ begin
|
||||
end;
|
||||
If (hp^<>#0) then
|
||||
begin
|
||||
Result:=HP;
|
||||
{$ifdef FPC_RTL_UNICODE}
|
||||
tmpstr:=hp;
|
||||
SetCodePage(tmpstr,CP_OEMCP,false);
|
||||
Result:=tmpstr;
|
||||
{$else}
|
||||
Result:=hp;
|
||||
SetCodePage(RawByteString(Result),CP_OEMCP,false);
|
||||
{$endif}
|
||||
end;
|
||||
end;
|
||||
FreeEnvironmentStringsA(p);
|
||||
|
||||
@ -31,6 +31,13 @@ uses
|
||||
{$DEFINE HAS_OSCONFIG}
|
||||
{$DEFINE HAS_TEMPDIR}
|
||||
{$DEFINE HAS_LOCALTIMEZONEOFFSET}
|
||||
|
||||
{ used OS file system APIs use ansistring }
|
||||
{$define SYSUTILS_HAS_UNICODESTR_FILEUTIL_IMPL}
|
||||
{ OS has an ansistring/single byte environment variable API (it has a dummy
|
||||
one currently, but that one uses ansistring) }
|
||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||
|
||||
{ Include platform independent interface part }
|
||||
{$i sysutilh.inc}
|
||||
|
||||
@ -62,9 +69,6 @@ implementation
|
||||
{$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
|
||||
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
||||
|
||||
{ used OS file system APIs use unicodestring }
|
||||
{$DEFINE SYSUTILS_HAS_UNICODESTR_FILEUTIL_IMPL}
|
||||
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
@ -611,7 +615,7 @@ begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
|
||||
begin
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user