Changeset 9 for trunk/USubversion.pas
- Timestamp:
- Aug 21, 2022, 7:07:10 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/USubversion.pas
r5 r9 4 4 5 5 uses 6 Classes, SysUtils, Process, FileUtil 6 Classes, SysUtils, Process, FileUtil, UExecute 7 7 {$IFDEF UNIX}, baseunix{$ENDIF}; 8 8 … … 15 15 end; 16 16 17 { TExecute }18 19 TExecute = class20 protected21 function GetExecutable: string; virtual;22 public23 StandardOutput: string;24 ErrorOutput: string;25 procedure Execute(Parameters: array of string); virtual;26 procedure ExecuteOutput(Parameters: array of string);27 function GetInfo(Text: string): TSubversionInfo;28 end;29 30 17 { TSubversion } 31 18 … … 35 22 function GetExecutable: string; override; 36 23 public 24 function GetInfo(Text: string): TSubversionInfo; 37 25 end; 38 26 … … 50 38 implementation 51 39 52 { TExecute } 53 54 function TExecute.GetExecutable: string; 55 begin 56 Result := ''; 57 end; 58 59 procedure TExecute.Execute(Parameters: array of string); 60 var 61 Process: TProcess; 62 I: Integer; 63 Buffer: string; 64 Count: Integer; 65 begin 66 StandardOutput := ''; 67 ErrorOutput := ''; 68 Buffer := ''; 69 try 70 Process := TProcess.Create(nil); 71 Process.Executable := GetExecutable; 72 for I := 0 to Length(Parameters) - 1 do 73 Process.Parameters.Add(Parameters[I]); 74 Process.Options := [poUsePipes, poNoConsole]; 75 Process.Execute; 76 while Process.Running or (Process.Output.NumBytesAvailable > 0) or 77 (Process.Stderr.NumBytesAvailable > 0) do 78 begin 79 if Process.Output.NumBytesAvailable > 0 then begin 80 SetLength(Buffer, 1000); 81 Count := Process.Output.Read(Buffer[1], Length(Buffer)); 82 SetLength(Buffer, Count); 83 StandardOutput := StandardOutput + Buffer; 84 end; 85 if Process.Stderr.NumBytesAvailable > 0 then begin 86 SetLength(Buffer, 1000); 87 Count := Process.Stderr.Read(Buffer[1], Length(Buffer)); 88 SetLength(Buffer, Count); 89 ErrorOutput := ErrorOutput + Buffer; 90 end; 91 Sleep(1); 92 end; 93 finally 94 Process.Free; 95 end; 96 end; 97 98 procedure TExecute.ExecuteOutput(Parameters: array of string); 99 begin 100 Execute(Parameters); 101 if StandardOutput <> '' then Write(StandardOutput); 102 if ErrorOutput <> '' then Write(ErrorOutput); 103 end; 104 105 function TExecute.GetInfo(Text: string): TSubversionInfo; 40 function TSubversion.GetInfo(Text: string): TSubversionInfo; 106 41 var 107 42 Index: Integer;
Note:
See TracChangeset
for help on using the changeset viewer.