---input--- // // Sourcecode from http://www.delphi-library.de/topic_47880.html // uses Windows, Messages; const FFM_INIT = WM_USER + 1976; FFM_ONFILEFOUND = WM_USER + 1974; // wParam: not used, lParam: Filename FFM_ONDIRFOUND = WM_USER + 1975; // wParam: NumFolder, lParam: Directory var CntFolders : Cardinal = 0; NumFolder : Cardinal = 0; //////////////////////////////////////////////////////////////////////////////// // // FindAllFilesInit // // procedure FindAllFilesInit; external; label foo; begin CntFolders := 0; NumFolder := 0; foo: Blub; goto foo; end; //////////////////////////////////////////////////////////////////////////////// // // CountFolders // // procedure CountFolders(Handle: THandle; RootFolder: string; Recurse: Boolean = True); var hFindFile : THandle; wfd : TWin32FindData; begin SendMessage(Handle, FFM_INIT, 0, 0); if RootFolder[length(RootFolder)] <> '\' then RootFolder := RootFolder + '\'; ZeroMemory(@wfd, sizeof(wfd)); wfd.dwFileAttributes := FILE_ATTRIBUTE_NORMAL; if Recurse then begin hFindFile := FindFirstFile(pointer(RootFolder + '*.*'), wfd); if hFindFile <> 0 then try repeat if wfd.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY = FILE_ATTRIBUTE_DIRECTORY then begin if (string(wfd.cFileName) <> '.') and (string(wfd.cFileName) <> '..') then begin CountFolders(Handle, RootFolder + wfd.cFileName, Recurse); end; end; until FindNextFile(hFindFile, wfd) = False; Inc(CntFolders); finally Windows.FindClose(hFindFile); end; end; end; //////////////////////////////////////////////////////////////////////////////// // // FindAllFiles // procedure FindAllFiles(Handle: THandle; RootFolder: string; Mask: string; Recurse: Boolean = True); var hFindFile : THandle; wfd : TWin32FindData; begin if RootFolder[length(RootFolder)] <> '\' then RootFolder := RootFolder + '\'; ZeroMemory(@wfd, sizeof(wfd)); wfd.dwFileAttributes := FILE_ATTRIBUTE_NORMAL; if Recurse then begin hFindFile := FindFirstFile(pointer(RootFolder + '*.*'), wfd); if hFindFile <> 0 then try repeat if wfd.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY = FILE_ATTRIBUTE_DIRECTORY then begin if (string(wfd.cFileName) <> '.') and (string(wfd.cFileName) <> '..') then begin FindAllFiles(Handle, RootFolder + wfd.cFileName, Mask, Recurse); end; end; until FindNextFile(hFindFile, wfd) = False; Inc(NumFolder); SendMessage(Handle, FFM_ONDIRFOUND, NumFolder, lParam(string(RootFolder))); finally Windows.FindClose(hFindFile); end; end; hFindFile := FindFirstFile(pointer(RootFolder + Mask), wfd); if hFindFile <> INVALID_HANDLE_VALUE then try repeat if (wfd.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <> FILE_ATTRIBUTE_DIRECTORY) then begin SendMessage(Handle, FFM_ONFILEFOUND, 0, lParam(string(RootFolder + wfd.cFileName))); end; until FindNextFile(hFindFile, wfd) = False; finally Windows.FindClose(hFindFile); end; end; property test: boolean read ftest write ftest; procedure test: boolean read ftest write ftest; // // This sourcecode is part of omorphia // Function IsValidHandle(Const Handle: THandle): Boolean; {$IFDEF OMORPHIA_FEATURES_USEASM} Assembler; Asm TEST EAX, EAX JZ @@Finish NOT EAX TEST EAX, EAX SETNZ AL {$IFDEF WINDOWS} JZ @@Finish //Save the handle against modifications or loss PUSH EAX //reserve some space for a later duplicate PUSH EAX //Check if we are working on NT-Platform CALL IsWindowsNTSystem TEST EAX, EAX JZ @@NoNTSystem PUSH DWORD PTR [ESP] LEA EAX, DWORD PTR [ESP+$04] PUSH EAX CALL GetHandleInformation TEST EAX, EAX JNZ @@Finish2 @@NoNTSystem: //Result := DuplicateHandle(GetCurrentProcess, Handle, GetCurrentProcess, // @Duplicate, 0, False, DUPLICATE_SAME_ACCESS); PUSH DUPLICATE_SAME_ACCESS PUSH $00000000 PUSH $00000000 LEA EAX, DWORD PTR [ESP+$0C] PUSH EAX CALL GetCurrentProcess PUSH EAX PUSH DWORD PTR [ESP+$18] PUSH EAX CALL DuplicateHandle TEST EAX, EAX JZ @@Finish2 // Result := CloseHandle(Duplicate); PUSH DWORD PTR [ESP] CALL CloseHandle @@Finish2: POP EDX POP EDX PUSH EAX PUSH $00000000 CALL SetLastError POP EAX {$ENDIF} @@Finish: End; {$ELSE} Var Duplicate: THandle; Flags: DWORD; Begin If IsWinNT Then Result := GetHandleInformation(Handle, Flags) Else Result := False; If Not Result Then Begin // DuplicateHandle is used as an additional check for those object types not // supported by GetHandleInformation (e.g. according to the documentation, // GetHandleInformation doesn't support window stations and desktop although // tests show that it does). GetHandleInformation is tried first because its // much faster. Additionally GetHandleInformation is only supported on NT... Result := DuplicateHandle(GetCurrentProcess, Handle, GetCurrentProcess, @Duplicate, 0, False, DUPLICATE_SAME_ACCESS); If Result Then Result := CloseHandle(Duplicate); End; End; {$ENDIF} {*******************************************************} { } { Delphi Supplemental Components } { ZLIB Data Compression Interface Unit } { } { Copyright (c) 1997 Borland International } { } {*******************************************************} { Modified for zlib 1.1.3 by Davide Moretti Z_STREAM_END do begin P := OutBuf; Inc(OutBytes, 256); ReallocMem(OutBuf, OutBytes); strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); strm.avail_out := 256; end; finally CCheck(deflateEnd(strm)); end; ReallocMem(OutBuf, strm.total_out); OutBytes := strm.total_out; except FreeMem(OutBuf); raise end; end; procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); var strm: TZStreamRec; P: Pointer; BufInc: Integer; begin FillChar(strm, sizeof(strm), 0); BufInc := (InBytes + 255) and not 255; if OutEstimate = 0 then OutBytes := BufInc else OutBytes := OutEstimate; GetMem(OutBuf, OutBytes); try strm.next_in := InBuf; strm.avail_in := InBytes; strm.next_out := OutBuf; strm.avail_out := OutBytes; DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); try while DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END do begin P := OutBuf; Inc(OutBytes, BufInc); ReallocMem(OutBuf, OutBytes); strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); strm.avail_out := BufInc; end; finally DCheck(inflateEnd(strm)); end; ReallocMem(OutBuf, strm.total_out); OutBytes := strm.total_out; except FreeMem(OutBuf); raise end; end; // TCustomZlibStream constructor TCustomZLibStream.Create(Strm: TStream); begin inherited Create; FStrm := Strm; FStrmPos := Strm.Position; end; procedure TCustomZLibStream.Progress(Sender: TObject); begin if Assigned(FOnProgress) then FOnProgress(Sender); end; // TCompressionStream constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel; Dest: TStream); const Levels: array [TCompressionLevel] of ShortInt = (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION); begin inherited Create(Dest); FZRec.next_out := FBuffer; FZRec.avail_out := sizeof(FBuffer); CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec))); end; destructor TCompressionStream.Destroy; begin FZRec.next_in := nil; FZRec.avail_in := 0; try if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END) and (FZRec.avail_out = 0) do begin FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); FZRec.next_out := FBuffer; FZRec.avail_out := sizeof(FBuffer); end; if FZRec.avail_out < sizeof(FBuffer) then FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out); finally deflateEnd(FZRec); end; inherited Destroy; end; function TCompressionStream.Read(var Buffer; Count: Longint): Longint; begin raise ECompressionError.Create('Invalid stream operation'); end; function TCompressionStream.Write(const Buffer; Count: Longint): Longint; begin FZRec.next_in := @Buffer; FZRec.avail_in := Count; if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; while (FZRec.avail_in > 0) do begin CCheck(deflate(FZRec, 0)); if FZRec.avail_out = 0 then begin FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); FZRec.next_out := FBuffer; FZRec.avail_out := sizeof(FBuffer); FStrmPos := FStrm.Position; Progress(Self); end; end; Result := Count; end; function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint; begin if (Offset = 0) and (Origin = soFromCurrent) then Result := FZRec.total_in else raise ECompressionError.Create('Invalid stream operation'); end; function TCompressionStream.GetCompressionRate: Single; begin if FZRec.total_in = 0 then Result := 0 else Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0; end; // TDecompressionStream constructor TDecompressionStream.Create(Source: TStream); begin inherited Create(Source); FZRec.next_in := FBuffer; FZRec.avail_in := 0; DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec))); end; destructor TDecompressionStream.Destroy; begin inflateEnd(FZRec); inherited Destroy; end; function TDecompressionStream.Read(var Buffer; Count: Longint): Longint; begin FZRec.next_out := @Buffer; FZRec.avail_out := Count; if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; while (FZRec.avail_out > 0) do begin if FZRec.avail_in = 0 then begin FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); if FZRec.avail_in = 0 then begin Result := Count - FZRec.avail_out; Exit; end; FZRec.next_in := FBuffer; FStrmPos := FStrm.Position; Progress(Self); end; DCheck(inflate(FZRec, 0)); end; Result := Count; end; function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; begin raise EDecompressionError.Create('Invalid stream operation'); end; function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; var I: Integer; Buf: array [0..4095] of Char; begin if (Offset = 0) and (Origin = soFromBeginning) then begin DCheck(inflateReset(FZRec)); FZRec.next_in := FBuffer; FZRec.avail_in := 0; FStrm.Position := 0; FStrmPos := 0; end else if ( (Offset >= 0) and (Origin = soFromCurrent)) or ( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then begin if Origin = soFromBeginning then Dec(Offset, FZRec.total_out); if Offset > 0 then begin for I := 1 to Offset div sizeof(Buf) do ReadBuffer(Buf, sizeof(Buf)); ReadBuffer(Buf, Offset mod sizeof(Buf)); end; end else raise EDecompressionError.Create('Invalid stream operation'); Result := FZRec.total_out; end; end. ---tokens--- '//' Comment.Single '\n' Text '// Sourcecode from http://www.delphi-library.de/topic_47880.html' Comment.Single '\n' Text '//' Comment.Single '\n' Text 'uses' Keyword ' ' Text 'Windows' Name ',' Operator ' ' Text 'Messages' Name ';' Operator '\n\n' Text 'const' Keyword '\n ' Text 'FFM_INIT' Name ' ' Text '=' Operator ' ' Text 'WM_USER' Name ' ' Text '+' Operator ' ' Text '1976' Literal.Number.Integer ';' Operator '\n ' Text 'FFM_ONFILEFOUND' Name ' ' Text '=' Operator ' ' Text 'WM_USER' Name ' ' Text '+' Operator ' ' Text '1974' Literal.Number.Integer ';' Operator ' ' Text '// wParam: not used, lParam: Filename' Comment.Single '\n ' Text 'FFM_ONDIRFOUND' Name ' ' Text '=' Operator ' ' Text 'WM_USER' Name ' ' Text '+' Operator ' ' Text '1975' Literal.Number.Integer ';' Operator ' ' Text '// wParam: NumFolder, lParam: Directory' Comment.Single '\n' Text 'var' Keyword '\n ' Text 'CntFolders' Name ' ' Text ':' Operator ' ' Text 'Cardinal' Keyword.Type ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n ' Text 'NumFolder' Name ' ' Text ':' Operator ' ' Text 'Cardinal' Keyword.Type ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n\n\n' Text '////////////////////////////////////////////////////////////////////////////////' Comment.Single '\n' Text '//' Comment.Single '\n' Text '// FindAllFilesInit' Comment.Single '\n' Text '//' Comment.Single '\n' Text '//' Comment.Single '\n' Text 'procedure' Keyword ' ' Text 'FindAllFilesInit' Name.Function ';' Operator ' ' Text 'external' Keyword.Pseudo ';' Operator '\n' Text 'label' Keyword ' ' Text 'foo' Name.Label ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'CntFolders' Name ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n ' Text 'NumFolder' Name ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n' Text 'foo' Name.Label ':' Operator '\n ' Text 'Blub' Name ';' Operator '\n ' Text 'goto' Keyword ' ' Text 'foo' Name.Label ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text '////////////////////////////////////////////////////////////////////////////////' Comment.Single '\n' Text '//' Comment.Single '\n' Text '// CountFolders' Comment.Single '\n' Text '//' Comment.Single '\n' Text '//' Comment.Single '\n' Text 'procedure' Keyword ' ' Text 'CountFolders' Name.Function '(' Punctuation 'Handle' Name ':' Operator ' ' Text 'THandle' Keyword.Type ';' Operator ' ' Text 'RootFolder' Name ':' Operator ' ' Text 'string' Keyword ';' Operator ' ' Text 'Recurse' Name ':' Operator ' ' Text 'Boolean' Keyword.Type ' ' Text '=' Operator ' ' Text 'True' Keyword ')' Punctuation ';' Operator '\n' Text 'var' Keyword '\n ' Text 'hFindFile' Name ' ' Text ':' Operator ' ' Text 'THandle' Keyword.Type ';' Operator '\n ' Text 'wfd' Name ' ' Text ':' Operator ' ' Text 'TWin32FindData' Name ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'SendMessage' Name '(' Punctuation 'Handle' Name ',' Operator ' ' Text 'FFM_INIT' Name ',' Operator ' ' Text '0' Literal.Number.Integer ',' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ';' Operator '\n ' Text 'if' Keyword ' ' Text 'RootFolder' Name '[' Punctuation 'length' Name.Builtin '(' Punctuation 'RootFolder' Name ')]' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text "'" Literal.String '\\' Literal.String "'" Literal.String ' ' Text 'then' Keyword '\n ' Text 'RootFolder' Name ' ' Text ':' Operator '=' Operator ' ' Text 'RootFolder' Name ' ' Text '+' Operator ' ' Text "'" Literal.String '\\' Literal.String "'" Literal.String ';' Operator '\n ' Text 'ZeroMemory' Name '(' Punctuation '@' Operator 'wfd' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'wfd' Name '))' Punctuation ';' Operator '\n ' Text 'wfd' Name '.' Operator 'dwFileAttributes' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FILE_ATTRIBUTE_NORMAL' Name ';' Operator '\n ' Text 'if' Keyword ' ' Text 'Recurse' Name ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'hFindFile' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FindFirstFile' Name '(' Punctuation 'pointer' Keyword.Type '(' Punctuation 'RootFolder' Name ' ' Text '+' Operator ' ' Text "'" Literal.String '*.*' Literal.String "'" Literal.String ')' Punctuation ',' Operator ' ' Text 'wfd' Name ')' Punctuation ';' Operator '\n ' Text 'if' Keyword ' ' Text 'hFindFile' Name ' ' Text '<' Operator '>' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'try' Keyword '\n ' Text 'repeat' Keyword '\n ' Text 'if' Keyword ' ' Text 'wfd' Name '.' Operator 'dwFileAttributes' Name ' ' Text 'and' Keyword ' ' Text 'FILE_ATTRIBUTE_DIRECTORY' Name ' ' Text '=' Operator ' ' Text 'FILE_ATTRIBUTE_DIRECTORY' Name ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text '(' Punctuation 'string' Keyword '(' Punctuation 'wfd' Name '.' Operator 'cFileName' Name ')' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text "'" Literal.String '.' Literal.String "'" Literal.String ')' Punctuation ' ' Text 'and' Keyword ' ' Text '(' Punctuation 'string' Keyword '(' Punctuation 'wfd' Name '.' Operator 'cFileName' Name ')' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text "'" Literal.String '..' Literal.String "'" Literal.String ')' Punctuation ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'CountFolders' Name '(' Punctuation 'Handle' Name ',' Operator ' ' Text 'RootFolder' Name ' ' Text '+' Operator ' ' Text 'wfd' Name '.' Operator 'cFileName' Name ',' Operator ' ' Text 'Recurse' Name ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'until' Keyword ' ' Text 'FindNextFile' Name '(' Punctuation 'hFindFile' Name ',' Operator ' ' Text 'wfd' Name ')' Punctuation ' ' Text '=' Operator ' ' Text 'False' Keyword ';' Operator '\n ' Text 'Inc' Name.Builtin '(' Punctuation 'CntFolders' Name ')' Punctuation ';' Operator '\n ' Text 'finally' Keyword '\n ' Text 'Windows' Name '.' Operator 'FindClose' Name '(' Punctuation 'hFindFile' Name ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text '////////////////////////////////////////////////////////////////////////////////' Comment.Single '\n' Text '//' Comment.Single '\n' Text '// FindAllFiles' Comment.Single '\n' Text '//' Comment.Single '\n' Text 'procedure' Keyword ' ' Text 'FindAllFiles' Name.Function '(' Punctuation 'Handle' Name ':' Operator ' ' Text 'THandle' Keyword.Type ';' Operator ' ' Text 'RootFolder' Name ':' Operator ' ' Text 'string' Keyword ';' Operator ' ' Text 'Mask' Name ':' Operator ' ' Text 'string' Keyword ';' Operator ' ' Text 'Recurse' Name ':' Operator ' ' Text 'Boolean' Keyword.Type ' ' Text '=' Operator ' ' Text 'True' Keyword ')' Punctuation ';' Operator '\n' Text 'var' Keyword '\n ' Text 'hFindFile' Name ' ' Text ':' Operator ' ' Text 'THandle' Keyword.Type ';' Operator '\n ' Text 'wfd' Name ' ' Text ':' Operator ' ' Text 'TWin32FindData' Name ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text 'RootFolder' Name '[' Punctuation 'length' Name.Builtin '(' Punctuation 'RootFolder' Name ')]' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text "'" Literal.String '\\' Literal.String "'" Literal.String ' ' Text 'then' Keyword '\n ' Text 'RootFolder' Name ' ' Text ':' Operator '=' Operator ' ' Text 'RootFolder' Name ' ' Text '+' Operator ' ' Text "'" Literal.String '\\' Literal.String "'" Literal.String ';' Operator '\n ' Text 'ZeroMemory' Name '(' Punctuation '@' Operator 'wfd' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'wfd' Name '))' Punctuation ';' Operator '\n ' Text 'wfd' Name '.' Operator 'dwFileAttributes' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FILE_ATTRIBUTE_NORMAL' Name ';' Operator '\n ' Text 'if' Keyword ' ' Text 'Recurse' Name ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'hFindFile' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FindFirstFile' Name '(' Punctuation 'pointer' Keyword.Type '(' Punctuation 'RootFolder' Name ' ' Text '+' Operator ' ' Text "'" Literal.String '*.*' Literal.String "'" Literal.String ')' Punctuation ',' Operator ' ' Text 'wfd' Name ')' Punctuation ';' Operator '\n ' Text 'if' Keyword ' ' Text 'hFindFile' Name ' ' Text '<' Operator '>' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'try' Keyword '\n ' Text 'repeat' Keyword '\n ' Text 'if' Keyword ' ' Text 'wfd' Name '.' Operator 'dwFileAttributes' Name ' ' Text 'and' Keyword ' ' Text 'FILE_ATTRIBUTE_DIRECTORY' Name ' ' Text '=' Operator ' ' Text 'FILE_ATTRIBUTE_DIRECTORY' Name ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text '(' Punctuation 'string' Keyword '(' Punctuation 'wfd' Name '.' Operator 'cFileName' Name ')' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text "'" Literal.String '.' Literal.String "'" Literal.String ')' Punctuation ' ' Text 'and' Keyword ' ' Text '(' Punctuation 'string' Keyword '(' Punctuation 'wfd' Name '.' Operator 'cFileName' Name ')' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text "'" Literal.String '..' Literal.String "'" Literal.String ')' Punctuation ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'FindAllFiles' Name '(' Punctuation 'Handle' Name ',' Operator ' ' Text 'RootFolder' Name ' ' Text '+' Operator ' ' Text 'wfd' Name '.' Operator 'cFileName' Name ',' Operator ' ' Text 'Mask' Name ',' Operator ' ' Text 'Recurse' Name ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'until' Keyword ' ' Text 'FindNextFile' Name '(' Punctuation 'hFindFile' Name ',' Operator ' ' Text 'wfd' Name ')' Punctuation ' ' Text '=' Operator ' ' Text 'False' Keyword ';' Operator '\n ' Text 'Inc' Name.Builtin '(' Punctuation 'NumFolder' Name ')' Punctuation ';' Operator '\n ' Text 'SendMessage' Name '(' Punctuation 'Handle' Name ',' Operator ' ' Text 'FFM_ONDIRFOUND' Name ',' Operator ' ' Text 'NumFolder' Name ',' Operator ' ' Text 'lParam' Name '(' Punctuation 'string' Keyword '(' Punctuation 'RootFolder' Name ')))' Punctuation ';' Operator '\n ' Text 'finally' Keyword '\n ' Text 'Windows' Name '.' Operator 'FindClose' Name '(' Punctuation 'hFindFile' Name ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'hFindFile' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FindFirstFile' Name '(' Punctuation 'pointer' Keyword.Type '(' Punctuation 'RootFolder' Name ' ' Text '+' Operator ' ' Text 'Mask' Name ')' Punctuation ',' Operator ' ' Text 'wfd' Name ')' Punctuation ';' Operator '\n ' Text 'if' Keyword ' ' Text 'hFindFile' Name ' ' Text '<' Operator '>' Operator ' ' Text 'INVALID_HANDLE_VALUE' Name ' ' Text 'then' Keyword '\n ' Text 'try' Keyword '\n ' Text 'repeat' Keyword '\n ' Text 'if' Keyword ' ' Text '(' Punctuation 'wfd' Name '.' Operator 'dwFileAttributes' Name ' ' Text 'and' Keyword ' ' Text 'FILE_ATTRIBUTE_DIRECTORY' Name ' ' Text '<' Operator '>' Operator ' ' Text 'FILE_ATTRIBUTE_DIRECTORY' Name ')' Punctuation ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'SendMessage' Name '(' Punctuation 'Handle' Name ',' Operator ' ' Text 'FFM_ONFILEFOUND' Name ',' Operator ' ' Text '0' Literal.Number.Integer ',' Operator ' ' Text 'lParam' Name '(' Punctuation 'string' Keyword '(' Punctuation 'RootFolder' Name ' ' Text '+' Operator ' ' Text 'wfd' Name '.' Operator 'cFileName' Name ')))' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'until' Keyword ' ' Text 'FindNextFile' Name '(' Punctuation 'hFindFile' Name ',' Operator ' ' Text 'wfd' Name ')' Punctuation ' ' Text '=' Operator ' ' Text 'False' Keyword ';' Operator '\n ' Text 'finally' Keyword '\n ' Text 'Windows' Name '.' Operator 'FindClose' Name '(' Punctuation 'hFindFile' Name ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n\n' Text 'property' Keyword ' ' Text 'test' Name.Property ':' Operator ' ' Text 'boolean' Keyword.Type ' ' Text 'read' Keyword.Pseudo ' ' Text 'ftest' Name.Function ' ' Text 'write' Keyword.Pseudo ' ' Text 'ftest' Name.Function ';' Operator '\n' Text 'procedure' Keyword ' ' Text 'test' Name.Function ':' Operator ' ' Text 'boolean' Keyword.Type ' ' Text 'read' Name.Builtin ' ' Text 'ftest' Name ' ' Text 'write' Name.Builtin ' ' Text 'ftest' Name ';' Operator '\n\n' Text '//' Comment.Single '\n' Text '// This sourcecode is part of omorphia' Comment.Single '\n' Text '//' Comment.Single '\n\n' Text 'Function' Keyword ' ' Text 'IsValidHandle' Name.Function '(' Punctuation 'Const' Keyword ' ' Text 'Handle' Name ':' Operator ' ' Text 'THandle' Keyword.Type ')' Punctuation ':' Operator ' ' Text 'Boolean' Keyword.Type ';' Operator ' ' Text '{$IFDEF OMORPHIA_FEATURES_USEASM}' Comment.Multiline ' ' Text 'Assembler' Keyword.Pseudo ';' Operator '\n' Text 'Asm' Keyword '\n ' Text 'TEST' Keyword ' ' Text 'EAX' Name.Builtin ',' Operator ' ' Text 'EAX' Name.Builtin '\n ' Text 'JZ' Keyword ' ' Text '@@Finish' Name.Label '\n ' Text 'NOT' Keyword ' ' Text 'EAX' Name.Builtin '\n ' Text 'TEST' Keyword ' ' Text 'EAX' Name.Builtin ',' Operator ' ' Text 'EAX' Name.Builtin '\n ' Text 'SETNZ' Keyword ' ' Text 'AL' Name.Builtin '\n\n ' Text '{$IFDEF WINDOWS}' Comment.Multiline '\n ' Text 'JZ' Keyword ' ' Text '@@Finish' Name.Label '\n\n ' Text '//Save the handle against modifications or loss' Comment.Single '\n ' Text 'PUSH' Keyword ' ' Text 'EAX' Name.Builtin '\n\n ' Text '//reserve some space for a later duplicate' Comment.Single '\n ' Text 'PUSH' Keyword ' ' Text 'EAX' Name.Builtin '\n\n ' Text '//Check if we are working on NT-Platform' Comment.Single '\n ' Text 'CALL' Keyword ' ' Text 'IsWindowsNTSystem' Name '\n ' Text 'TEST' Keyword ' ' Text 'EAX' Name.Builtin ',' Operator ' ' Text 'EAX' Name.Builtin '\n ' Text 'JZ' Keyword ' ' Text '@@NoNTSystem' Name.Label '\n\n ' Text 'PUSH' Keyword ' ' Text 'DWORD' Name ' ' Text 'PTR' Name ' ' Text '[' Punctuation 'ESP' Name.Builtin ']' Punctuation '\n ' Text 'LEA' Keyword ' ' Text 'EAX' Name.Builtin ',' Operator ' ' Text 'DWORD' Name ' ' Text 'PTR' Name ' ' Text '[' Punctuation 'ESP' Name.Builtin '+' Operator '$04' Literal.Number.Hex ']' Punctuation '\n ' Text 'PUSH' Keyword ' ' Text 'EAX' Name.Builtin '\n ' Text 'CALL' Keyword ' ' Text 'GetHandleInformation' Name '\n ' Text 'TEST' Keyword ' ' Text 'EAX' Name.Builtin ',' Operator ' ' Text 'EAX' Name.Builtin '\n ' Text 'JNZ' Keyword ' ' Text '@@Finish2' Name.Label '\n\n' Text '@@NoNTSystem' Name.Label ':' Operator '\n ' Text '//Result := DuplicateHandle(GetCurrentProcess, Handle, GetCurrentProcess,' Comment.Single '\n ' Text '// @Duplicate, 0, False, DUPLICATE_SAME_ACCESS);' Comment.Single '\n ' Text 'PUSH' Keyword ' ' Text 'DUPLICATE_SAME_ACCESS' Name '\n ' Text 'PUSH' Keyword ' ' Text '$00000000' Literal.Number.Hex '\n ' Text 'PUSH' Keyword ' ' Text '$00000000' Literal.Number.Hex '\n ' Text 'LEA' Keyword ' ' Text 'EAX' Name.Builtin ',' Operator ' ' Text 'DWORD' Name ' ' Text 'PTR' Name ' ' Text '[' Punctuation 'ESP' Name.Builtin '+' Operator '$0C' Literal.Number.Hex ']' Punctuation '\n ' Text 'PUSH' Keyword ' ' Text 'EAX' Name.Builtin '\n ' Text 'CALL' Keyword ' ' Text 'GetCurrentProcess' Name '\n ' Text 'PUSH' Keyword ' ' Text 'EAX' Name.Builtin '\n ' Text 'PUSH' Keyword ' ' Text 'DWORD' Name ' ' Text 'PTR' Name ' ' Text '[' Punctuation 'ESP' Name.Builtin '+' Operator '$18' Literal.Number.Hex ']' Punctuation '\n ' Text 'PUSH' Keyword ' ' Text 'EAX' Name.Builtin '\n ' Text 'CALL' Keyword ' ' Text 'DuplicateHandle' Name '\n\n ' Text 'TEST' Keyword ' ' Text 'EAX' Name.Builtin ',' Operator ' ' Text 'EAX' Name.Builtin '\n ' Text 'JZ' Keyword ' ' Text '@@Finish2' Name.Label '\n\n ' Text '// Result := CloseHandle(Duplicate);' Comment.Single '\n ' Text 'PUSH' Keyword ' ' Text 'DWORD' Name ' ' Text 'PTR' Name ' ' Text '[' Punctuation 'ESP' Name.Builtin ']' Punctuation '\n ' Text 'CALL' Keyword ' ' Text 'CloseHandle' Name '\n\n' Text '@@Finish2' Name.Label ':' Operator '\n ' Text 'POP' Keyword ' ' Text 'EDX' Name.Builtin '\n ' Text 'POP' Keyword ' ' Text 'EDX' Name.Builtin '\n\n ' Text 'PUSH' Keyword ' ' Text 'EAX' Name.Builtin '\n ' Text 'PUSH' Keyword ' ' Text '$00000000' Literal.Number.Hex '\n ' Text 'CALL' Keyword ' ' Text 'SetLastError' Name '\n ' Text 'POP' Keyword ' ' Text 'EAX' Name.Builtin '\n ' Text '{$ENDIF}' Comment.Multiline '\n\n' Text '@@Finish' Name.Label ':' Operator '\n' Text 'End' Keyword ';' Operator '\n' Text '{$ELSE}' Comment.Multiline '\n' Text 'Var' Keyword '\n ' Text 'Duplicate' Name ':' Operator ' ' Text 'THandle' Keyword.Type ';' Operator '\n ' Text 'Flags' Name ':' Operator ' ' Text 'DWORD' Keyword.Type ';' Operator '\n' Text 'Begin' Keyword '\n ' Text 'If' Keyword ' ' Text 'IsWinNT' Name ' ' Text 'Then' Keyword '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'GetHandleInformation' Name '(' Punctuation 'Handle' Name ',' Operator ' ' Text 'Flags' Name ')' Punctuation '\n ' Text 'Else' Keyword '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'False' Keyword ';' Operator '\n ' Text 'If' Keyword ' ' Text 'Not' Keyword ' ' Text 'Result' Name.Builtin.Pseudo ' ' Text 'Then' Keyword '\n ' Text 'Begin' Keyword '\n ' Text '// DuplicateHandle is used as an additional check for those object types not' Comment.Single '\n ' Text '// supported by GetHandleInformation (e.g. according to the documentation,' Comment.Single '\n ' Text "// GetHandleInformation doesn't support window stations and desktop although" Comment.Single '\n ' Text '// tests show that it does). GetHandleInformation is tried first because its' Comment.Single '\n ' Text '// much faster. Additionally GetHandleInformation is only supported on NT...' Comment.Single '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'DuplicateHandle' Name '(' Punctuation 'GetCurrentProcess' Name ',' Operator ' ' Text 'Handle' Name ',' Operator ' ' Text 'GetCurrentProcess' Name ',' Operator '\n ' Text '@' Operator 'Duplicate' Name ',' Operator ' ' Text '0' Literal.Number.Integer ',' Operator ' ' Text 'False' Keyword ',' Operator ' ' Text 'DUPLICATE_SAME_ACCESS' Name ')' Punctuation ';' Operator '\n ' Text 'If' Keyword ' ' Text 'Result' Name.Builtin.Pseudo ' ' Text 'Then' Keyword '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'CloseHandle' Name '(' Punctuation 'Duplicate' Name ')' Punctuation ';' Operator '\n ' Text 'End' Keyword ';' Operator '\n' Text 'End' Keyword ';' Operator '\n' Text '{$ENDIF}' Comment.Multiline '\n\n\n \t\n\n' Text '{*******************************************************}' Comment.Multiline '\n' Text '{ }' Comment.Multiline '\n' Text '{ Delphi Supplemental Components }' Comment.Multiline '\n' Text '{ ZLIB Data Compression Interface Unit }' Comment.Multiline '\n' Text '{ }' Comment.Multiline '\n' Text '{ Copyright (c) 1997 Borland International }' Comment.Multiline '\n' Text '{ }' Comment.Multiline '\n' Text '{*******************************************************}' Comment.Multiline '\n\n' Text '{ Modified for zlib 1.1.3 by Davide Moretti ' Operator ' ' Text 'Z_STREAM_END' Name ' ' Text 'do' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'P' Name ' ' Text ':' Operator '=' Operator ' ' Text 'OutBuf' Name ';' Operator '\n ' Text 'Inc' Name.Builtin '(' Punctuation 'OutBytes' Name ',' Operator ' ' Text '256' Literal.Number.Integer ')' Punctuation ';' Operator '\n ' Text 'ReallocMem' Name.Builtin '(' Punctuation 'OutBuf' Name ',' Operator ' ' Text 'OutBytes' Name ')' Punctuation ';' Operator '\n ' Text 'strm' Name '.' Operator 'next_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'PChar' Keyword.Type '(' Punctuation 'Integer' Keyword.Type '(' Punctuation 'OutBuf' Name ')' Punctuation ' ' Text '+' Operator ' ' Text '(' Punctuation 'Integer' Keyword.Type '(' Punctuation 'strm' Name '.' Operator 'next_out' Name ')' Punctuation ' ' Text '-' Operator ' ' Text 'Integer' Keyword.Type '(' Punctuation 'P' Name ')))' Punctuation ';' Operator '\n ' Text 'strm' Name '.' Operator 'avail_out' Name ' ' Text ':' Operator '=' Operator ' ' Text '256' Literal.Number.Integer ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'finally' Keyword '\n ' Text 'CCheck' Name '(' Punctuation 'deflateEnd' Name '(' Punctuation 'strm' Name '))' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'ReallocMem' Name.Builtin '(' Punctuation 'OutBuf' Name ',' Operator ' ' Text 'strm' Name '.' Operator 'total_out' Name ')' Punctuation ';' Operator '\n ' Text 'OutBytes' Name ' ' Text ':' Operator '=' Operator ' ' Text 'strm' Name '.' Operator 'total_out' Name ';' Operator '\n ' Text 'except' Keyword '\n ' Text 'FreeMem' Name.Builtin '(' Punctuation 'OutBuf' Name ')' Punctuation ';' Operator '\n ' Text 'raise' Keyword '\n ' Text 'end' Keyword ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n\n' Text 'procedure' Keyword ' ' Text 'DecompressBuf' Name.Function '(' Punctuation 'const' Keyword ' ' Text 'InBuf' Name ':' Operator ' ' Text 'Pointer' Keyword.Type ';' Operator ' ' Text 'InBytes' Name ':' Operator ' ' Text 'Integer' Keyword.Type ';' Operator '\n ' Text 'OutEstimate' Name ':' Operator ' ' Text 'Integer' Keyword.Type ';' Operator ' ' Text 'out' Name ' ' Text 'OutBuf' Name ':' Operator ' ' Text 'Pointer' Keyword.Type ';' Operator ' ' Text 'out' Name ' ' Text 'OutBytes' Name ':' Operator ' ' Text 'Integer' Keyword.Type ')' Punctuation ';' Operator '\n' Text 'var' Keyword '\n ' Text 'strm' Name ':' Operator ' ' Text 'TZStreamRec' Name ';' Operator '\n ' Text 'P' Name ':' Operator ' ' Text 'Pointer' Keyword.Type ';' Operator '\n ' Text 'BufInc' Name ':' Operator ' ' Text 'Integer' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'FillChar' Name.Builtin '(' Punctuation 'strm' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'strm' Name ')' Punctuation ',' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ';' Operator '\n ' Text 'BufInc' Name ' ' Text ':' Operator '=' Operator ' ' Text '(' Punctuation 'InBytes' Name ' ' Text '+' Operator ' ' Text '255' Literal.Number.Integer ')' Punctuation ' ' Text 'and' Keyword ' ' Text 'not' Keyword ' ' Text '255' Literal.Number.Integer ';' Operator '\n ' Text 'if' Keyword ' ' Text 'OutEstimate' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'OutBytes' Name ' ' Text ':' Operator '=' Operator ' ' Text 'BufInc' Name '\n ' Text 'else' Keyword '\n ' Text 'OutBytes' Name ' ' Text ':' Operator '=' Operator ' ' Text 'OutEstimate' Name ';' Operator '\n ' Text 'GetMem' Name.Builtin '(' Punctuation 'OutBuf' Name ',' Operator ' ' Text 'OutBytes' Name ')' Punctuation ';' Operator '\n ' Text 'try' Keyword '\n ' Text 'strm' Name '.' Operator 'next_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'InBuf' Name ';' Operator '\n ' Text 'strm' Name '.' Operator 'avail_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'InBytes' Name ';' Operator '\n ' Text 'strm' Name '.' Operator 'next_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'OutBuf' Name ';' Operator '\n ' Text 'strm' Name '.' Operator 'avail_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'OutBytes' Name ';' Operator '\n ' Text 'DCheck' Name '(' Punctuation 'inflateInit_' Name '(' Punctuation 'strm' Name ',' Operator ' ' Text 'zlib_version' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'strm' Name ')))' Punctuation ';' Operator '\n ' Text 'try' Keyword '\n ' Text 'while' Keyword ' ' Text 'DCheck' Name '(' Punctuation 'inflate' Name '(' Punctuation 'strm' Name ',' Operator ' ' Text 'Z_FINISH' Name '))' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text 'Z_STREAM_END' Name ' ' Text 'do' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'P' Name ' ' Text ':' Operator '=' Operator ' ' Text 'OutBuf' Name ';' Operator '\n ' Text 'Inc' Name.Builtin '(' Punctuation 'OutBytes' Name ',' Operator ' ' Text 'BufInc' Name ')' Punctuation ';' Operator '\n ' Text 'ReallocMem' Name.Builtin '(' Punctuation 'OutBuf' Name ',' Operator ' ' Text 'OutBytes' Name ')' Punctuation ';' Operator '\n ' Text 'strm' Name '.' Operator 'next_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'PChar' Keyword.Type '(' Punctuation 'Integer' Keyword.Type '(' Punctuation 'OutBuf' Name ')' Punctuation ' ' Text '+' Operator ' ' Text '(' Punctuation 'Integer' Keyword.Type '(' Punctuation 'strm' Name '.' Operator 'next_out' Name ')' Punctuation ' ' Text '-' Operator ' ' Text 'Integer' Keyword.Type '(' Punctuation 'P' Name ')))' Punctuation ';' Operator '\n ' Text 'strm' Name '.' Operator 'avail_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'BufInc' Name ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'finally' Keyword '\n ' Text 'DCheck' Name '(' Punctuation 'inflateEnd' Name '(' Punctuation 'strm' Name '))' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'ReallocMem' Name.Builtin '(' Punctuation 'OutBuf' Name ',' Operator ' ' Text 'strm' Name '.' Operator 'total_out' Name ')' Punctuation ';' Operator '\n ' Text 'OutBytes' Name ' ' Text ':' Operator '=' Operator ' ' Text 'strm' Name '.' Operator 'total_out' Name ';' Operator '\n ' Text 'except' Keyword '\n ' Text 'FreeMem' Name.Builtin '(' Punctuation 'OutBuf' Name ')' Punctuation ';' Operator '\n ' Text 'raise' Keyword '\n ' Text 'end' Keyword ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n\n' Text '// TCustomZlibStream' Comment.Single '\n\n' Text 'constructor' Keyword ' ' Text 'TCustomZLibStream' Name.Class '.' Operator 'Create' Name.Function '(' Punctuation 'Strm' Name ':' Operator ' ' Text 'TStream' Name ')' Punctuation ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'inherited' Keyword ' ' Text 'Create' Name ';' Operator '\n ' Text 'FStrm' Name ' ' Text ':' Operator '=' Operator ' ' Text 'Strm' Name ';' Operator '\n ' Text 'FStrmPos' Name ' ' Text ':' Operator '=' Operator ' ' Text 'Strm' Name '.' Operator 'Position' Name ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'procedure' Keyword ' ' Text 'TCustomZLibStream' Name.Class '.' Operator 'Progress' Name.Function '(' Punctuation 'Sender' Name ':' Operator ' ' Text 'TObject' Keyword.Type ')' Punctuation ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text 'Assigned' Name.Builtin '(' Punctuation 'FOnProgress' Name ')' Punctuation ' ' Text 'then' Keyword ' ' Text 'FOnProgress' Name '(' Punctuation 'Sender' Name ')' Punctuation ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n\n' Text '// TCompressionStream' Comment.Single '\n\n' Text 'constructor' Keyword ' ' Text 'TCompressionStream' Name.Class '.' Operator 'Create' Name.Function '(' Punctuation 'CompressionLevel' Name ':' Operator ' ' Text 'TCompressionLevel' Name ';' Operator '\n ' Text 'Dest' Name ':' Operator ' ' Text 'TStream' Name ')' Punctuation ';' Operator '\n' Text 'const' Keyword '\n ' Text 'Levels' Name ':' Operator ' ' Text 'array' Keyword ' ' Text '[' Punctuation 'TCompressionLevel' Name ']' Punctuation ' ' Text 'of' Keyword ' ' Text 'ShortInt' Keyword.Type ' ' Text '=' Operator '\n ' Text '(' Punctuation 'Z_NO_COMPRESSION' Name ',' Operator ' ' Text 'Z_BEST_SPEED' Name ',' Operator ' ' Text 'Z_DEFAULT_COMPRESSION' Name ',' Operator ' ' Text 'Z_BEST_COMPRESSION' Name ')' Punctuation ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'inherited' Keyword ' ' Text 'Create' Name '(' Punctuation 'Dest' Name ')' Punctuation ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'next_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FBuffer' Name ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name ')' Punctuation ';' Operator '\n ' Text 'CCheck' Name '(' Punctuation 'deflateInit_' Name '(' Punctuation 'FZRec' Name ',' Operator ' ' Text 'Levels' Name '[' Punctuation 'CompressionLevel' Name ']' Punctuation ',' Operator ' ' Text 'zlib_version' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FZRec' Name ')))' Punctuation ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'destructor' Keyword ' ' Text 'TCompressionStream' Name.Class '.' Operator 'Destroy' Name.Function ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'FZRec' Name '.' Operator 'next_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'nil' Keyword ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n ' Text 'try' Keyword '\n ' Text 'if' Keyword ' ' Text 'FStrm' Name '.' Operator 'Position' Name ' ' Text '<' Operator '>' Operator ' ' Text 'FStrmPos' Name ' ' Text 'then' Keyword ' ' Text 'FStrm' Name '.' Operator 'Position' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FStrmPos' Name ';' Operator '\n ' Text 'while' Keyword ' ' Text '(' Punctuation 'CCheck' Name '(' Punctuation 'deflate' Name '(' Punctuation 'FZRec' Name ',' Operator ' ' Text 'Z_FINISH' Name '))' Punctuation ' ' Text '<' Operator '>' Operator ' ' Text 'Z_STREAM_END' Name ')' Punctuation '\n ' Text 'and' Keyword ' ' Text '(' Punctuation 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ' ' Text 'do' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'FStrm' Name '.' Operator 'WriteBuffer' Name '(' Punctuation 'FBuffer' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name '))' Punctuation ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'next_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FBuffer' Name ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'if' Keyword ' ' Text 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text '<' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name ')' Punctuation ' ' Text 'then' Keyword '\n ' Text 'FStrm' Name '.' Operator 'WriteBuffer' Name '(' Punctuation 'FBuffer' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name ')' Punctuation ' ' Text '-' Operator ' ' Text 'FZRec' Name '.' Operator 'avail_out' Name ')' Punctuation ';' Operator '\n ' Text 'finally' Keyword '\n ' Text 'deflateEnd' Name '(' Punctuation 'FZRec' Name ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'inherited' Keyword ' ' Text 'Destroy' Name ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'function' Keyword ' ' Text 'TCompressionStream' Name.Class '.' Operator 'Read' Name.Function '(' Punctuation 'var' Keyword ' ' Text 'Buffer' Name ';' Operator ' ' Text 'Count' Name ':' Operator ' ' Text 'Longint' Keyword.Type ')' Punctuation ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'raise' Keyword ' ' Text 'ECompressionError' Name '.' Operator 'Create' Name '(' Punctuation "'" Literal.String 'Invalid stream operation' Literal.String "'" Literal.String ')' Punctuation ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'function' Keyword ' ' Text 'TCompressionStream' Name.Class '.' Operator 'Write' Name.Function '(' Punctuation 'const' Keyword ' ' Text 'Buffer' Name ';' Operator ' ' Text 'Count' Name ':' Operator ' ' Text 'Longint' Keyword.Type ')' Punctuation ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'FZRec' Name '.' Operator 'next_in' Name ' ' Text ':' Operator '=' Operator ' ' Text '@' Operator 'Buffer' Name ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'Count' Name ';' Operator '\n ' Text 'if' Keyword ' ' Text 'FStrm' Name '.' Operator 'Position' Name ' ' Text '<' Operator '>' Operator ' ' Text 'FStrmPos' Name ' ' Text 'then' Keyword ' ' Text 'FStrm' Name '.' Operator 'Position' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FStrmPos' Name ';' Operator '\n ' Text 'while' Keyword ' ' Text '(' Punctuation 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text '>' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ' ' Text 'do' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'CCheck' Name '(' Punctuation 'deflate' Name '(' Punctuation 'FZRec' Name ',' Operator ' ' Text '0' Literal.Number.Integer '))' Punctuation ';' Operator '\n ' Text 'if' Keyword ' ' Text 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'FStrm' Name '.' Operator 'WriteBuffer' Name '(' Punctuation 'FBuffer' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name '))' Punctuation ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'next_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FBuffer' Name ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name ')' Punctuation ';' Operator '\n ' Text 'FStrmPos' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FStrm' Name '.' Operator 'Position' Name ';' Operator '\n ' Text 'Progress' Name '(' Punctuation 'Self' Keyword ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'Count' Name ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'function' Keyword ' ' Text 'TCompressionStream' Name.Class '.' Operator 'Seek' Name.Function '(' Punctuation 'Offset' Name ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator ' ' Text 'Origin' Name ':' Operator ' ' Text 'Word' Keyword.Type ')' Punctuation ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text '(' Punctuation 'Offset' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ' ' Text 'and' Keyword ' ' Text '(' Punctuation 'Origin' Name ' ' Text '=' Operator ' ' Text 'soFromCurrent' Name ')' Punctuation ' ' Text 'then' Keyword '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'FZRec' Name '.' Operator 'total_in' Name '\n ' Text 'else' Keyword '\n ' Text 'raise' Keyword ' ' Text 'ECompressionError' Name '.' Operator 'Create' Name '(' Punctuation "'" Literal.String 'Invalid stream operation' Literal.String "'" Literal.String ')' Punctuation ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'function' Keyword ' ' Text 'TCompressionStream' Name.Class '.' Operator 'GetCompressionRate' Name.Function ':' Operator ' ' Text 'Single' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text 'FZRec' Name '.' Operator 'total_in' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer '\n ' Text 'else' Keyword '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text '(' Punctuation '1.0' Literal.Number.Float ' ' Text '-' Operator ' ' Text '(' Punctuation 'FZRec' Name '.' Operator 'total_out' Name ' ' Text '/' Operator ' ' Text 'FZRec' Name '.' Operator 'total_in' Name '))' Punctuation ' ' Text '*' Operator ' ' Text '10' Literal.Number.Integer '0.0' Literal.Number.Float ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n\n' Text '// TDecompressionStream' Comment.Single '\n\n' Text 'constructor' Keyword ' ' Text 'TDecompressionStream' Name.Class '.' Operator 'Create' Name.Function '(' Punctuation 'Source' Name ':' Operator ' ' Text 'TStream' Name ')' Punctuation ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'inherited' Keyword ' ' Text 'Create' Name '(' Punctuation 'Source' Name ')' Punctuation ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'next_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FBuffer' Name ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n ' Text 'DCheck' Name '(' Punctuation 'inflateInit_' Name '(' Punctuation 'FZRec' Name ',' Operator ' ' Text 'zlib_version' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FZRec' Name ')))' Punctuation ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'destructor' Keyword ' ' Text 'TDecompressionStream' Name.Class '.' Operator 'Destroy' Name.Function ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'inflateEnd' Name '(' Punctuation 'FZRec' Name ')' Punctuation ';' Operator '\n ' Text 'inherited' Keyword ' ' Text 'Destroy' Name ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'function' Keyword ' ' Text 'TDecompressionStream' Name.Class '.' Operator 'Read' Name.Function '(' Punctuation 'var' Keyword ' ' Text 'Buffer' Name ';' Operator ' ' Text 'Count' Name ':' Operator ' ' Text 'Longint' Keyword.Type ')' Punctuation ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'FZRec' Name '.' Operator 'next_out' Name ' ' Text ':' Operator '=' Operator ' ' Text '@' Operator 'Buffer' Name ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text ':' Operator '=' Operator ' ' Text 'Count' Name ';' Operator '\n ' Text 'if' Keyword ' ' Text 'FStrm' Name '.' Operator 'Position' Name ' ' Text '<' Operator '>' Operator ' ' Text 'FStrmPos' Name ' ' Text 'then' Keyword ' ' Text 'FStrm' Name '.' Operator 'Position' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FStrmPos' Name ';' Operator '\n ' Text 'while' Keyword ' ' Text '(' Punctuation 'FZRec' Name '.' Operator 'avail_out' Name ' ' Text '>' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ' ' Text 'do' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FStrm' Name '.' Operator 'Read' Name '(' Punctuation 'FBuffer' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'FBuffer' Name '))' Punctuation ';' Operator '\n ' Text 'if' Keyword ' ' Text 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'Count' Name ' ' Text '-' Operator ' ' Text 'FZRec' Name '.' Operator 'avail_out' Name ';' Operator '\n ' Text 'Exit' Keyword ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'next_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FBuffer' Name ';' Operator '\n ' Text 'FStrmPos' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FStrm' Name '.' Operator 'Position' Name ';' Operator '\n ' Text 'Progress' Name '(' Punctuation 'Self' Keyword ')' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'DCheck' Name '(' Punctuation 'inflate' Name '(' Punctuation 'FZRec' Name ',' Operator ' ' Text '0' Literal.Number.Integer '))' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'Count' Name ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'function' Keyword ' ' Text 'TDecompressionStream' Name.Class '.' Operator 'Write' Name.Function '(' Punctuation 'const' Keyword ' ' Text 'Buffer' Name ';' Operator ' ' Text 'Count' Name ':' Operator ' ' Text 'Longint' Keyword.Type ')' Punctuation ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'raise' Keyword ' ' Text 'EDecompressionError' Name '.' Operator 'Create' Name '(' Punctuation "'" Literal.String 'Invalid stream operation' Literal.String "'" Literal.String ')' Punctuation ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'function' Keyword ' ' Text 'TDecompressionStream' Name.Class '.' Operator 'Seek' Name.Function '(' Punctuation 'Offset' Name ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator ' ' Text 'Origin' Name ':' Operator ' ' Text 'Word' Keyword.Type ')' Punctuation ':' Operator ' ' Text 'Longint' Keyword.Type ';' Operator '\n' Text 'var' Keyword '\n ' Text 'I' Name ':' Operator ' ' Text 'Integer' Keyword.Type ';' Operator '\n ' Text 'Buf' Name ':' Operator ' ' Text 'array' Keyword ' ' Text '[' Punctuation '0' Literal.Number.Integer '.' Operator '.' Operator '4095' Literal.Number.Integer ']' Punctuation ' ' Text 'of' Keyword ' ' Text 'Char' Keyword.Type ';' Operator '\n' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text '(' Punctuation 'Offset' Name ' ' Text '=' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ' ' Text 'and' Keyword ' ' Text '(' Punctuation 'Origin' Name ' ' Text '=' Operator ' ' Text 'soFromBeginning' Name ')' Punctuation ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'DCheck' Name '(' Punctuation 'inflateReset' Name '(' Punctuation 'FZRec' Name '))' Punctuation ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'next_in' Name ' ' Text ':' Operator '=' Operator ' ' Text 'FBuffer' Name ';' Operator '\n ' Text 'FZRec' Name '.' Operator 'avail_in' Name ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n ' Text 'FStrm' Name '.' Operator 'Position' Name ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n ' Text 'FStrmPos' Name ' ' Text ':' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ';' Operator '\n ' Text 'end' Keyword '\n ' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text '(' Punctuation ' ' Text '(' Punctuation 'Offset' Name ' ' Text '>' Operator '=' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ' ' Text 'and' Keyword ' ' Text '(' Punctuation 'Origin' Name ' ' Text '=' Operator ' ' Text 'soFromCurrent' Name '))' Punctuation ' ' Text 'or' Keyword '\n ' Text '(' Punctuation ' ' Text '((' Punctuation 'Offset' Name ' ' Text '-' Operator ' ' Text 'FZRec' Name '.' Operator 'total_out' Name ')' Punctuation ' ' Text '>' Operator ' ' Text '0' Literal.Number.Integer ')' Punctuation ' ' Text 'and' Keyword ' ' Text '(' Punctuation 'Origin' Name ' ' Text '=' Operator ' ' Text 'soFromBeginning' Name '))' Punctuation ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'if' Keyword ' ' Text 'Origin' Name ' ' Text '=' Operator ' ' Text 'soFromBeginning' Name ' ' Text 'then' Keyword ' ' Text 'Dec' Name.Builtin '(' Punctuation 'Offset' Name ',' Operator ' ' Text 'FZRec' Name '.' Operator 'total_out' Name ')' Punctuation ';' Operator '\n ' Text 'if' Keyword ' ' Text 'Offset' Name ' ' Text '>' Operator ' ' Text '0' Literal.Number.Integer ' ' Text 'then' Keyword '\n ' Text 'begin' Keyword '\n ' Text 'for' Keyword ' ' Text 'I' Name ' ' Text ':' Operator '=' Operator ' ' Text '1' Literal.Number.Integer ' ' Text 'to' Keyword ' ' Text 'Offset' Name ' ' Text 'div' Keyword ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'Buf' Name ')' Punctuation ' ' Text 'do' Keyword '\n ' Text 'ReadBuffer' Name '(' Punctuation 'Buf' Name ',' Operator ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'Buf' Name '))' Punctuation ';' Operator '\n ' Text 'ReadBuffer' Name '(' Punctuation 'Buf' Name ',' Operator ' ' Text 'Offset' Name ' ' Text 'mod' Keyword ' ' Text 'sizeof' Name.Builtin '(' Punctuation 'Buf' Name '))' Punctuation ';' Operator '\n ' Text 'end' Keyword ';' Operator '\n ' Text 'end' Keyword '\n ' Text 'else' Keyword '\n ' Text 'raise' Keyword ' ' Text 'EDecompressionError' Name '.' Operator 'Create' Name '(' Punctuation "'" Literal.String 'Invalid stream operation' Literal.String "'" Literal.String ')' Punctuation ';' Operator '\n ' Text 'Result' Name.Builtin.Pseudo ' ' Text ':' Operator '=' Operator ' ' Text 'FZRec' Name '.' Operator 'total_out' Name ';' Operator '\n' Text 'end' Keyword ';' Operator '\n\n' Text 'end' Keyword '.' Operator '\n' Text