Subversion Repositories fastphp

Rev

Rev 75 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 75 Rev 91
Line 7... Line 7...
7
  StdCtrls, SynEdit, ActiveX;
7
  StdCtrls, SynEdit, ActiveX;
8
 
8
 
9
type
9
type
10
  TContentCallBack = procedure(Content: string) of object;
10
  TContentCallBack = procedure(Content: string) of object;
11
 
11
 
12
function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): string;
12
function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): String;
13
function StrIPos(const SubStr, S: string): Integer;
13
function StrIPos(const SubStr, S: string): Integer;
14
function LoadFileToStr(const FileName: TFileName): AnsiString;
14
function LoadFileToStr(const FileName: TFileName): AnsiString;
15
function LastPos(const SubStr, S: string): integer;
15
function LastPos(const SubStr, S: string): integer;
16
function IsTextHTML(s: string): boolean;
16
function IsTextHTML(s: string): boolean;
17
function GetWordUnderPos(AMemo: TSynEdit; Line, Column: integer): string;
17
function GetWordUnderPos(AMemo: TSynEdit; Line, Column: integer): string;
Line 29... Line 29...
29
 
29
 
30
uses
30
uses
31
  ShlObj, // Needed for the CSIDL constants
31
  ShlObj, // Needed for the CSIDL constants
32
  IdGlobal, IdHash, IdHashMessageDigest; // used for MD5 calculation
32
  IdGlobal, IdHash, IdHashMessageDigest; // used for MD5 calculation
33
 
33
 
34
function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): string;
34
function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): String;
35
var
35
var
36
  SA: TSecurityAttributes;
36
  SA: TSecurityAttributes;
37
  SI: TStartupInfo;
37
  SI: TStartupInfo;
38
  PI: TProcessInformation;
38
  PI: TProcessInformation;
39
  StdOutPipeRead, StdOutPipeWrite: THandle;
39
  StdOutPipeRead, StdOutPipeWrite: THandle;
Line 73... Line 73...
73
        repeat
73
        repeat
74
          WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
74
          WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
75
          if BytesRead > 0 then
75
          if BytesRead > 0 then
76
          begin
76
          begin
77
            Buffer[BytesRead] := #0;
77
            Buffer[BytesRead] := #0;
78
            Result := Result + Buffer;
78
            Result := Result + string(Buffer);
79
            if Assigned(ContentCallBack) then ContentCallBack(Buffer);
79
            if Assigned(ContentCallBack) then ContentCallBack(string(Buffer));
80
          end;
80
          end;
81
        until not WasOK or (BytesRead = 0);
81
        until not WasOK or (BytesRead = 0);
82
        WaitForSingleObject(PI.hProcess, INFINITE);
82
        WaitForSingleObject(PI.hProcess, INFINITE);
83
      finally
83
      finally
84
        CloseHandle(PI.hThread);
84
        CloseHandle(PI.hThread);
Line 97... Line 97...
97
function LoadFileToStr(const FileName: TFileName): AnsiString;
97
function LoadFileToStr(const FileName: TFileName): AnsiString;
98
var
98
var
99
  FileStream : TFileStream;
99
  FileStream : TFileStream;
100
 
100
 
101
begin
101
begin
102
  Result:= '';
102
  Result := '';
103
  FileStream:= TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
103
  FileStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
104
  try
104
  try
105
    if FileStream.Size>0 then begin
105
    if FileStream.Size>0 then begin
106
      SetLength(Result, FileStream.Size);
106
      SetLength(Result, FileStream.Size);
107
      FileStream.Read(Result[1], FileStream.Size);
107
      FileStream.Read(Result[1], FileStream.Size);
108
    end;
108
    end;