Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetDataFromFile;
- var
- CurrentFile : TFileByte; // file of Byte
- NumOfCharLeft : Integer;
- begin
- Assign(CurrentFile, PathToFile);
- Reset(CurrentFile);
- NumOfCharLeft := FileSize(CurrentFile) - NumOfCharRead;
- Seek(CurrentFile, NumOfCharRead);
- { Читаем информацию из файла (CurrentFile) и помещаем
- данные в буфер (Buffer). Когда размер не прочитанной
- информации с файла меньше размера буфера,
- то считываем оставшуюся информацию и устанавливаем
- значение "True" в IsEndOfFile }
- if (NumOfCharLeft < BufferSize) then
- begin
- SetLength(Result, NumOfCharLeft);
- BlockRead(CurrentFile, PChar(Result)^, NumOfCharLeft);
- IsEndOfFile := True;
- end
- else if (NumOfCharLeft > BufferSize) then
- begin
- SetLength(Result, BufferSize);
- BlockRead(CurrentFile, PChar(Result)^, BufferSize);
- Inc(NumOfCharRead, BufferSize);
- end;
- CloseFile(CurrentFile);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement