Программы   Загрузка Партнерство   О компании Контакты  
 
                    
  Карта Сайта   
   

Быстрая обработка файла

Автор: Mike Scott



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 ] ) ;

           




Программы  |  Загрузка  |  Партнерство  |  О компании  |  Контакты

Copyright © LSD Software 2006 - 2011