mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 22:49:26 +02:00
LazUtils: Delete very old code for TProcessUTF8 that was needed for FPC 2.x.
git-svn-id: trunk@63563 -
This commit is contained in:
parent
6bab11b3bb
commit
f18d2348ff
@ -13,19 +13,10 @@ unit UTF8Process;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$IF FPC_FULLVERSION<20701}
|
||||
{$DEFINE UseOldTProcess}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF UseOldTProcess}
|
||||
{$IFDEF MSWINDOWS}
|
||||
{$IFDEF MSWINDOWS}
|
||||
{$DEFINE UseTProcessW}
|
||||
{$ELSE}
|
||||
{$DEFINE UseTProcessAlias}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
@ -35,54 +26,14 @@ uses
|
||||
{$ENDIF}
|
||||
FileUtil, LazFileUtils, LazUTF8, LazUtilsStrConsts;
|
||||
|
||||
{$IFDEF UseOldTProcess}
|
||||
type
|
||||
{ TProcessUTF8 }
|
||||
{ TProcessUTF8 }
|
||||
|
||||
TProcessUTF8 = class(TProcess)
|
||||
private
|
||||
FApplicationNameUTF8: string;
|
||||
FCommandLineUTF8: string;
|
||||
FConsoleTitleUTF8: string;
|
||||
FCurrentDirectoryUTF8: string;
|
||||
FDesktopUTF8: string;
|
||||
FEnvironmentUTF8: TStrings;
|
||||
FExecutableUTF8: string;
|
||||
FParametersUTF8: TStrings;
|
||||
procedure SetApplicationNameUTF8(const AValue: string);
|
||||
procedure SetCommandLineUTF8(const AValue: string);
|
||||
procedure SetConsoleTitleUTF8(const AValue: string);
|
||||
procedure SetCurrentDirectoryUTF8(const AValue: string);
|
||||
procedure SetDesktopUTF8(const AValue: string);
|
||||
procedure SetEnvironmentUTF8(const AValue: TStrings);
|
||||
procedure SetExecutableUTF8(AValue: string);
|
||||
procedure SetParametersUTF8(AValue: TStrings);
|
||||
procedure UpdateEnvironment;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure Execute; override;
|
||||
procedure ParseCmdLine(const CmdLine: string; ReadBackslash: boolean = false);
|
||||
published
|
||||
property ApplicationName: string read FApplicationNameUTF8 write SetApplicationNameUTF8;
|
||||
property CommandLine: string read FCommandLineUTF8 write SetCommandLineUTF8;
|
||||
property ConsoleTitle: string read FConsoleTitleUTF8 write SetConsoleTitleUTF8;
|
||||
property CurrentDirectory: string read FCurrentDirectoryUTF8 write SetCurrentDirectoryUTF8;
|
||||
property Desktop: string read FDesktopUTF8 write SetDesktopUTF8;
|
||||
property Environment: TStrings read FEnvironmentUTF8 write SetEnvironmentUTF8;
|
||||
property Executable: string read FExecutableUTF8 Write SetExecutableUTF8;
|
||||
property Parameters: TStrings read FParametersUTF8 write SetParametersUTF8;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF UseTProcessW}
|
||||
{$IFDEF UseTProcessW}
|
||||
{$Optimization -ORDERFIELDS }
|
||||
const
|
||||
SNoCommandLine = 'Cannot execute empty command-line';
|
||||
SErrCannotExecute = 'Failed to execute %s : %d';
|
||||
type
|
||||
{ TProcessUTF8 }
|
||||
|
||||
TProcessUTF8 = class(TProcess)
|
||||
protected
|
||||
procedure SetProcessHandle(aProcessHandle : THandle);
|
||||
@ -92,18 +43,15 @@ type
|
||||
procedure Execute; override;
|
||||
procedure ParseCmdLine(const CmdLine: string; ReadBackslash: boolean = false);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF UseTProcessAlias}
|
||||
{$ELSE}
|
||||
|
||||
type
|
||||
|
||||
{ TProcessUTF8 }
|
||||
|
||||
TProcessUTF8 = class(TProcess)
|
||||
public
|
||||
procedure ParseCmdLine(const CmdLine: string; ReadBackslash: boolean = false);
|
||||
end;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
procedure RunCmdFromPath(ProgramFilename, CmdLineParameters: string);
|
||||
function FindFilenameOfCmd(ProgramFilename: string): string;
|
||||
@ -246,116 +194,6 @@ begin
|
||||
RegisterComponents('System',[TProcessUTF8]);
|
||||
end;
|
||||
|
||||
{$IFDEF UseOldTProcess}
|
||||
{$WARN SYMBOL_DEPRECATED OFF}
|
||||
{ TProcessUTF8 }
|
||||
|
||||
procedure TProcessUTF8.SetApplicationNameUTF8(const AValue: string);
|
||||
begin
|
||||
if FApplicationNameUTF8=AValue then exit;
|
||||
FApplicationNameUTF8:=AValue;
|
||||
inherited ApplicationName:=UTF8ToSys(FApplicationNameUTF8);
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.SetCommandLineUTF8(const AValue: string);
|
||||
var
|
||||
Src: TStrings;
|
||||
i: Integer;
|
||||
begin
|
||||
if FCommandLineUTF8=AValue then exit;
|
||||
FCommandLineUTF8:=AValue;
|
||||
inherited CommandLine:=UTF8ToSys(FCommandLineUTF8);
|
||||
FExecutableUTF8:=SysToUTF8(inherited Executable);
|
||||
FParametersUTF8.Clear;
|
||||
Src:=inherited Parameters;
|
||||
if Src<>nil then
|
||||
for i:=0 to Src.Count-1 do
|
||||
FParametersUTF8.Add(SysToUTF8(Src[i]));
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.SetConsoleTitleUTF8(const AValue: string);
|
||||
begin
|
||||
if FConsoleTitleUTF8=AValue then exit;
|
||||
FConsoleTitleUTF8:=AValue;
|
||||
inherited ConsoleTitle:=UTF8ToSys(FConsoleTitleUTF8);
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.SetCurrentDirectoryUTF8(const AValue: string);
|
||||
begin
|
||||
if FCurrentDirectoryUTF8=AValue then exit;
|
||||
FCurrentDirectoryUTF8:=AValue;
|
||||
inherited CurrentDirectory:=UTF8ToSys(FCurrentDirectoryUTF8);
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.SetDesktopUTF8(const AValue: string);
|
||||
begin
|
||||
if FDesktopUTF8=AValue then exit;
|
||||
FDesktopUTF8:=AValue;
|
||||
inherited Desktop:=UTF8ToSys(FDesktopUTF8);
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.SetEnvironmentUTF8(const AValue: TStrings);
|
||||
begin
|
||||
if (FEnvironmentUTF8=AValue)
|
||||
or ((AValue<>nil) and FEnvironmentUTF8.Equals(AValue)) then exit;
|
||||
FEnvironmentUTF8.Assign(AValue);
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.SetExecutableUTF8(AValue: string);
|
||||
begin
|
||||
if FExecutableUTF8=AValue then Exit;
|
||||
FExecutableUTF8:=AValue;
|
||||
inherited Executable:=UTF8ToSys(FExecutableUTF8);
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.SetParametersUTF8(AValue: TStrings);
|
||||
begin
|
||||
if (FParametersUTF8=AValue)
|
||||
or ((AValue<>nil) and FParametersUTF8.Equals(AValue)) then exit;
|
||||
FParametersUTF8.Assign(AValue);
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.UpdateEnvironment;
|
||||
var
|
||||
sl: TStringList;
|
||||
i: Integer;
|
||||
begin
|
||||
sl:=TStringList.Create;
|
||||
try
|
||||
for i:=0 to FEnvironmentUTF8.Count-1 do
|
||||
sl.Add(UTF8ToSys(FEnvironmentUTF8[i]));
|
||||
inherited Environment:=sl;
|
||||
sl.Clear;
|
||||
for i:=0 to FParametersUTF8.Count-1 do
|
||||
sl.Add(UTF8ToSys(FParametersUTF8[i]));
|
||||
inherited Parameters:=sl;
|
||||
finally
|
||||
sl.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TProcessUTF8.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FEnvironmentUTF8:=TStringList.Create;
|
||||
FParametersUTF8:=TStringList.Create;
|
||||
end;
|
||||
|
||||
destructor TProcessUTF8.Destroy;
|
||||
begin
|
||||
FreeAndNil(FEnvironmentUTF8);
|
||||
FreeAndNil(FParametersUTF8);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TProcessUTF8.Execute;
|
||||
begin
|
||||
UpdateEnvironment;
|
||||
inherited Execute;
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF UseTProcessW}
|
||||
Const
|
||||
PriorityConstants : Array [TProcessPriority] of Cardinal =
|
||||
@ -687,20 +525,13 @@ begin
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TProcessUTF8.ParseCmdLine(const CmdLine: string;
|
||||
ReadBackslash: boolean);
|
||||
procedure TProcessUTF8.ParseCmdLine(const CmdLine: string; ReadBackslash: boolean);
|
||||
var
|
||||
List: TStringList;
|
||||
begin
|
||||
List:=TStringList.Create;
|
||||
try
|
||||
SplitCmdLineParams(
|
||||
{$IFDEF UseOldTProcess}
|
||||
SysToUTF8(CmdLine),
|
||||
{$ELSE}
|
||||
CmdLine,
|
||||
{$ENDIF}
|
||||
List,ReadBackslash);
|
||||
SplitCmdLineParams(CmdLine, List, ReadBackslash);
|
||||
if List.Count>0 then begin
|
||||
Executable:=List[0];
|
||||
List.Delete(0);
|
||||
|
Loading…
Reference in New Issue
Block a user