|
@@ -7,7 +7,7 @@
|
|
Author : Kike Pérez
|
|
Author : Kike Pérez
|
|
Version : 1.9
|
|
Version : 1.9
|
|
Created : 14/07/2017
|
|
Created : 14/07/2017
|
|
- Modified : 16/01/2020
|
|
|
|
|
|
+ Modified : 12/02/2020
|
|
|
|
|
|
This file is part of QuickLib: https://github.com/exilon/QuickLib
|
|
This file is part of QuickLib: https://github.com/exilon/QuickLib
|
|
|
|
|
|
@@ -93,9 +93,9 @@ const
|
|
type
|
|
type
|
|
TPasswordComplexity = set of (pfIncludeNumbers,pfIncludeSigns);
|
|
TPasswordComplexity = set of (pfIncludeNumbers,pfIncludeSigns);
|
|
|
|
|
|
- {$IFDEF MSWINDOWS}
|
|
|
|
TEnvironmentPath = record
|
|
TEnvironmentPath = record
|
|
EXEPATH : string;
|
|
EXEPATH : string;
|
|
|
|
+ {$IFDEF MSWINDOWS}
|
|
WINDOWS : string;
|
|
WINDOWS : string;
|
|
SYSTEM : string;
|
|
SYSTEM : string;
|
|
PROGRAMFILES : string;
|
|
PROGRAMFILES : string;
|
|
@@ -112,8 +112,8 @@ type
|
|
APPDATA : String;
|
|
APPDATA : String;
|
|
PROGRAMDATA : string;
|
|
PROGRAMDATA : string;
|
|
ALLUSERSPROFILE : string;
|
|
ALLUSERSPROFILE : string;
|
|
|
|
+ {$ENDIF MSWINDOWS}
|
|
end;
|
|
end;
|
|
- {$ENDIF MSWINDOWS}
|
|
|
|
|
|
|
|
{$IFNDEF FPC}
|
|
{$IFNDEF FPC}
|
|
TFileHelper = record helper for TFile
|
|
TFileHelper = record helper for TFile
|
|
@@ -230,9 +230,9 @@ type
|
|
function WindowsToUnixPath(const WindowsPath: string): string;
|
|
function WindowsToUnixPath(const WindowsPath: string): string;
|
|
//corrects malformed urls
|
|
//corrects malformed urls
|
|
function CorrectURLPath(cUrl : string) : string;
|
|
function CorrectURLPath(cUrl : string) : string;
|
|
- {$IFDEF MSWINDOWS}
|
|
|
|
//get typical environment paths as temp, desktop, etc
|
|
//get typical environment paths as temp, desktop, etc
|
|
procedure GetEnvironmentPaths;
|
|
procedure GetEnvironmentPaths;
|
|
|
|
+ {$IFDEF MSWINDOWS}
|
|
function GetSpecialFolderPath(folderID : Integer) : string;
|
|
function GetSpecialFolderPath(folderID : Integer) : string;
|
|
//checks if running on a 64bit OS
|
|
//checks if running on a 64bit OS
|
|
function Is64bitOS : Boolean;
|
|
function Is64bitOS : Boolean;
|
|
@@ -339,6 +339,8 @@ type
|
|
function CommaText(aList : TStringList) : string; overload;
|
|
function CommaText(aList : TStringList) : string; overload;
|
|
//returns a real comma separated text from array of string
|
|
//returns a real comma separated text from array of string
|
|
function CommaText(aArray : TArray<string>) : string; overload;
|
|
function CommaText(aArray : TArray<string>) : string; overload;
|
|
|
|
+ //returns a string CRLF from array of string
|
|
|
|
+ function ArrayToString(aArray : TArray<string>) : string;
|
|
//converts TStrings to array
|
|
//converts TStrings to array
|
|
function StringsToArray(aStrings : TStrings) : TArray<string>;
|
|
function StringsToArray(aStrings : TStrings) : TArray<string>;
|
|
{$IFDEF MSWINDOWS}
|
|
{$IFDEF MSWINDOWS}
|
|
@@ -360,11 +362,17 @@ type
|
|
//get double quoted or dequoted string
|
|
//get double quoted or dequoted string
|
|
function DbQuotedStr(const str : string): string;
|
|
function DbQuotedStr(const str : string): string;
|
|
function UnDbQuotedStr(const str: string) : string;
|
|
function UnDbQuotedStr(const str: string) : string;
|
|
|
|
+ //get simple quoted or dequoted string
|
|
|
|
+ function SpQuotedStr(const str : string): string;
|
|
|
|
+ function UnSpQuotedStr(const str : string): string;
|
|
|
|
+ //ternary operator
|
|
|
|
+ function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : string) : string; overload;
|
|
|
|
+ function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : Integer) : Integer; overload;
|
|
|
|
+ function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : Extended) : Extended; overload;
|
|
|
|
+ function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : TObject) : TObject; overload;
|
|
|
|
|
|
-{$IFDEF MSWINDOWS}
|
|
|
|
var
|
|
var
|
|
path : TEnvironmentPath;
|
|
path : TEnvironmentPath;
|
|
-{$ENDIF}
|
|
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
@@ -529,11 +537,11 @@ begin
|
|
//TNetEncoding.Url.Encode()
|
|
//TNetEncoding.Url.Encode()
|
|
end;
|
|
end;
|
|
|
|
|
|
-{$IFDEF MSWINDOWS}
|
|
|
|
procedure GetEnvironmentPaths;
|
|
procedure GetEnvironmentPaths;
|
|
begin
|
|
begin
|
|
//gets path
|
|
//gets path
|
|
path.EXEPATH := TPath.GetDirectoryName(ParamStr(0));
|
|
path.EXEPATH := TPath.GetDirectoryName(ParamStr(0));
|
|
|
|
+ {$IFDEF MSWINDOWS}
|
|
path.WINDOWS := SysUtils.GetEnvironmentVariable('windir');
|
|
path.WINDOWS := SysUtils.GetEnvironmentVariable('windir');
|
|
path.PROGRAMFILES := SysUtils.GetEnvironmentVariable('ProgramFiles');
|
|
path.PROGRAMFILES := SysUtils.GetEnvironmentVariable('ProgramFiles');
|
|
path.COMMONFILES := SysUtils.GetEnvironmentVariable('CommonProgramFiles(x86)');
|
|
path.COMMONFILES := SysUtils.GetEnvironmentVariable('CommonProgramFiles(x86)');
|
|
@@ -556,8 +564,10 @@ begin
|
|
except
|
|
except
|
|
//
|
|
//
|
|
end;
|
|
end;
|
|
|
|
+ {$ENDIF}
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{$IFDEF MSWINDOWS}
|
|
function GetSpecialFolderPath(folderID : Integer) : string;
|
|
function GetSpecialFolderPath(folderID : Integer) : string;
|
|
var
|
|
var
|
|
ppidl: PItemIdList;
|
|
ppidl: PItemIdList;
|
|
@@ -1461,6 +1471,24 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function ArrayToString(aArray : TArray<string>) : string;
|
|
|
|
+var
|
|
|
|
+ value : string;
|
|
|
|
+ sb : TStringBuilder;
|
|
|
|
+begin
|
|
|
|
+ if High(aArray) < 0 then Exit;
|
|
|
|
+ sb := TStringBuilder.Create;
|
|
|
|
+ try
|
|
|
|
+ for value in aArray do
|
|
|
|
+ begin
|
|
|
|
+ sb.Append(value);
|
|
|
|
+ sb.Append(#10#13);
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ sb.Free;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
function StringsToArray(aStrings : TStrings) : TArray<string>;
|
|
function StringsToArray(aStrings : TStrings) : TArray<string>;
|
|
var
|
|
var
|
|
i : Integer;
|
|
i : Integer;
|
|
@@ -1798,7 +1826,41 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-{$IFDEF MSWINDOWS}
|
|
|
|
|
|
+function SpQuotedStr(const str : string): string;
|
|
|
|
+begin
|
|
|
|
+ Result := '''' + str + '''';
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function UnSpQuotedStr(const str: string) : string;
|
|
|
|
+begin
|
|
|
|
+ Result := Trim(str);
|
|
|
|
+ if not Result.IsEmpty then
|
|
|
|
+ begin
|
|
|
|
+ if Result.StartsWith('''') then Result := Copy(Result, 2, Result.Length - 2);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : string) : string;
|
|
|
|
+begin
|
|
|
|
+ if aCondition then Result := aIfIsTrue else Result := aIfIsFalse;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : Integer) : Integer;
|
|
|
|
+begin
|
|
|
|
+ if aCondition then Result := aIfIsTrue else Result := aIfIsFalse;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : Extended) : Extended;
|
|
|
|
+begin
|
|
|
|
+ if aCondition then Result := aIfIsTrue else Result := aIfIsFalse;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : TObject) : TObject;
|
|
|
|
+begin
|
|
|
|
+ if aCondition then Result := aIfIsTrue else Result := aIfIsFalse;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{$IFNDEF NEXTGEN}
|
|
initialization
|
|
initialization
|
|
try
|
|
try
|
|
GetEnvironmentPaths;
|
|
GetEnvironmentPaths;
|