Быстрая обработка файла
type
TByteSet = set of byte ;
procedure ProcessFile( const InFileName,OutFileName: string; Valid: TByteSet ) ;
var
InFile, OutFile : file ;
InBuf, OutBuf : PByteArray ;
InPos, OutPos : word ;
BytesRead : word ;
begin
OutBuf := NIL ;
New( InBuf ) ;
try
New( OutBuf ) ;
AssignFile( InFile, InFileName ) ;
AssignFile( OutFile, OutFileName ) ;
Reset( InFile, 1 ) ;
Rewrite( OutFile, 1 ) ;
repeat
Blockread( InFile, InBuf^, SizeOf( InBuf^ ), BytesRead ) ;
OutPos := 0 ;
for InPos := 0 to BytesRead - 1 do begin
if InBuf^[ InPos ] in Valid then begin
inc( OutPos ) ;
end ;
end ;
if OutPos > 0 then BlockWrite( OutFile, OutBuf^, OutPos ) ;
until BytesRead <> SizeOf( InBuf^ ) ;
CloseFile( InFile ) ;
CloseFile( OutFile ) ;
finally
if OutBuf <> NIL then Dispose( OutBuf ) ;
Dispose( InBuf ) ;
end ;
end;
|
Применять это можно приблизительно так:
ProcessFile( 'SOURCE.RAW', 'NEW.RAW', [ 10, 13, 32..255 ] ) ;
|
- Mike Scott [000865]