summaryrefslogtreecommitdiff
path: root/uidesigner
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2009-07-09 16:17:11 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2009-07-09 16:17:11 +0200
commit0494b7671d627f8f3ee2485875d934e5640ea904 (patch)
tree1de569b3ee7e45f106930cdf8cff7f0e15c1eee9 /uidesigner
parent2ff0e5096c48215d58551a7d198a56f8322af3c9 (diff)
downloadfpGUI-0494b7671d627f8f3ee2485875d934e5640ea904.tar.xz
UIDesigner: Replace BlockRead() with TFileStream in LoadFile() method
Diffstat (limited to 'uidesigner')
-rw-r--r--uidesigner/vfdfile.pas37
1 files changed, 10 insertions, 27 deletions
diff --git a/uidesigner/vfdfile.pas b/uidesigner/vfdfile.pas
index efcbedbd..d505fae8 100644
--- a/uidesigner/vfdfile.pas
+++ b/uidesigner/vfdfile.pas
@@ -243,55 +243,38 @@ begin
deletelen := endp - startp + length(endmarker);
end
else
- dropmarker := True// error: end marker did not found
+ begin
+ dropmarker := True; // error: end marker did not found
//Writeln('file error: ',endmarker,' marker wasn''t found.');
// block length = 0
- ;
+ end;
end;
Delete(FParsedData, startp, deletelen);
-
if not dropmarker then
AddBlock(startp, bname, formname, datablock);
-
end;
-
until startp <= 0;
//writeln(FParsedData);
-
Result := BlockCount;
end;
function TVFDFile.LoadFile(fname: string): boolean;
var
- ff: file;
- s: string;
- cnt: integer;
+ fs: TFileStream;
begin
Result := False;
- AssignFile(ff, fpgToOSEncoding(fname));
+ fs := TFileStream.Create(fpgToOSEncoding(fname), fmOpenRead);
try
- Reset(ff, 1);
- except
- Exit;
- end;
-
- FFileData := '';
- try
- while not EOF(ff) do
- begin
- SetLength(s, 4096);
- BlockRead(ff, s[1], length(s), cnt);
- FFileData := FFileData + copy(s, 1, cnt);
- if cnt < length(s) then
- break;
- end;
+ FFileData := ''; // make sure it is empty
+ SetLength(FFileData, fs.Size);
+ fs.Read(FFileData[1], fs.Size);
+ //Writeln('data length: ',fs.Size);
Result := True;
finally
- CloseFile(ff);
+ fs.Free;
end;
- //Writeln('data length: ',length(FFileData));
end;
function TVFDFile.MergeBlocks: string;