Slightly enhance open SQL file mechanism:

- Open the file in "read and leave" mode, don't lock it for write operations. This fixes opening a file which is opened and write locked in another application
- Handle exceptions for ReadTextfile in QueryLoad which was malfunctioning yet, lead to an AV.
- Enhance inline documentation
This commit is contained in:
Ansgar Becker
2008-07-05 10:00:55 +00:00
parent b335a120ec
commit ab291881e1
2 changed files with 26 additions and 42 deletions

View File

@ -2339,7 +2339,7 @@ end;
}
procedure OpenTextFile(const Filename: String; out Stream: TFileStream; out FileCharset: TFileCharset);
begin
Stream := TFileStream.Create(Filename, fmOpenRead or fmShareDenyWrite);
Stream := TFileStream.Create(Filename, fmOpenRead or fmShareDenyNone);
Stream.Position := 0;
FileCharset := GetFileCharset(Stream);
end;
@ -2545,12 +2545,9 @@ var
Stream: TFileStream;
FileCharset: TFileCharset;
begin
try
OpenTextfile(Filename, Stream, FileCharset);
Result := ReadTextfileChunk(Stream, FileCharset);
finally
Stream.Free;
end;
OpenTextfile(Filename, Stream, FileCharset);
Result := ReadTextfileChunk(Stream, FileCharset);
Stream.Free;
end;