groffstudio

Diff
Login

Diff

Differences From Artifact [244f78b094]:

To Artifact [b2dc02ad8c]:


16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30







-
+







}

{$mode ObjFPC}{$H+}

interface

uses
  Classes, SysUtils, Forms, StdCtrls, Process;
  Classes, SysUtils, Forms, StdCtrls, Process, Dialogs;

type

  { TBuildStatusWindow }

  TBuildStatusWindow = class(TForm)
    Label1: TLabel;
40
41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56

57
58

59
60

61
62
63

64

65
66
67
68

69

70
71
72
73
74
75
76

77
78
79
80

81
82
83
84
85
86
87
88
89
90
91
92



93
94
95
96
97


98
99
100
101
40
41
42
43
44
45
46


47
48
49
50



51

52


53


54

55

56

57
58
59
60
61
62

63







64




65












66
67
68


69
70
71
72
73
74
75
76
77







-
-


+

-
-
-

-
+
-
-
+
-
-
+
-

-
+
-
+




+
-
+
-
-
-
-
-
-
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-



+
+





implementation

{$R *.lfm}

function TBuildStatusWindow.BuildDocument(CommandLine: String; LogFile: String): Boolean;
var
  p: TProcess;
  n: LongInt;
  str: String;
  lh: TextFile;
  ret: Boolean;
begin
  p := TProcess.Create(nil);
  p.Options := p.Options + [poUsePipes, poStderrToOutPut];

{$IFDEF WINDOWS}
  p.Executable := 'cmd';
  ret := RunCommand('cmd', ['/c', CommandLine], str, [], swoHIDE);
  p.Parameters.Add('/c');
{$ENDIF}
{$ELSE}
{$IFDEF UNIX}
  p.Executable := 'sh';
  ret := RunCommand('sh', ['-c', CommandLine], str, [], swoHIDE);
  p.Parameters.Add('-c');
{$ENDIF}
  p.Parameters.Add(CommandLine);

  p.Execute;
  if Length(str) = 0 then str := 'No problems have occurred. :-)';

  if LogFile <> '' then
  begin
    AssignFile(lh, LogFile);
    try
    Rewrite(lh);
      ReWrite(lh);

    while p.Running do
    begin
      n := p.Output.Read(str, 2048);
      if n > 0 then
      begin
        writeln(lh, str);
      Write(lh, str);
      end
      else Sleep(100);
    end;

    finally
    { We might have some buffer contents left. }
    repeat
      n := p.Output.Read(str, 2048);
      if n > 0 then
      begin
        writeln(lh, str);
      end;
    until n <= 0;

    CloseFile(lh);
  end;

      CloseFile(lh);
    end;
  end;
  result := p.ExitStatus > 0;
  p.Free;

  { Close the status window: }
  Close;

  Result := ret;
end;

end.