Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure removeDeleters();
- const
- TEMP_FILE_NAME = 'TempFile.bin';
- var
- SourceFile, TempFile: TBinaryFile;
- OneByte: ansichar;
- BufferArray: Array[1..ONLY_DATA_SIZE] of ansichar;
- offset: integer;
- Number: longWord;
- begin
- assign(SourceFile, GetCurrentDir + '\' + FILE_NAME);
- assign(TempFile, GetCurrentDir + '\' + TEMP_FILE_NAME);
- Number := 0;
- rewrite(TempFile);
- reset(SourceFile);
- offset := START_SUBSCRIBER_OFFSET;
- while not EOF(SourceFile) do
- begin
- blockRead(SourceFile, OneByte, 1);
- if (OneByte <> DELETER) then
- begin
- Seek(SourceFile, Offset + NUMBER_LENGTH);
- blockRead(SourceFile, BufferArray, ONLY_DATA_SIZE);
- blockWrite(TempFile, Number, NUMBER_LENGTH);
- blockWrite(TempFile, BufferArray, ONLY_DATA_SIZE);
- inc(Number);
- end;
- Offset := Offset + RECORD_SIZE;
- seek(SourceFile, Offset);
- end;
- closeFile(SourceFile);
- closeFile(TempFile);
- deleteFile(GetCurrentDir + '\' + FILE_NAME);
- RenameFile(GetCurrentDir + '\' + TEMP_FILE_NAME, GetCurrentDir + '\' + FILE_NAME);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement