티스토리 툴바



2011/12/12 04:47

TextFile - CurrentPosition / Move Position

function TextPos(var F: TextFile): Int64;
var
  TR: TTextRec absolute F;
begin
  Result := FileSeek(TR.Handle, 0, FILE_CURRENT);

  if TR.Mode = fmOutput then
    Inc(Result, TR.BufPos)
  else
    if TR.BufEnd <> 0 then
      Dec(Result, TR.BufEnd - TR.BufPos);
end;
function TextSeek(var F: TextFile; Pos: Int64): boolean;
var
//  Pos64: Int64Rec absolute Pos;
//  resHi: cardinal;
  TR: TTextRec absolute F;
begin
  Result := False;
  if TR.Mode <> fmInput then
    Exit;
  
  FileSeek(TR.Handle, Pos, FILE_BEGIN);
//  resHi := Pos64.Hi;
//  if (SetFilePointer(TR.Handle, Pos64.Lo,@resHi,FILE_BEGIN)<>Pos64.Lo) or (resHi<>Pos64.Hi) then
//    Exit;
//
//  TR.BufEnd := 0; // flush internal reading buffer
//  TR.BufPos := 0;
//  Result := True; // success
  Result := FileSeek(TR.Handle, Pos, FILE_BEGIN) = Pos;
end;
 
저작자 표시
크리에이티브 커먼즈 라이선스
Creative Commons License

'Delphi' 카테고리의 다른 글

TextFile - CurrentPosition / Move Position  (0) 2011/12/12
Delphi FilePath Routine  (0) 2011/12/08
Indy10 UDP Sample  (0) 2011/12/07
TObjectDictionary Sample  (0) 2011/11/02
Trackback 0 Comment 0