Skip to content

Commit bebe606

Browse files
committed
copy TSimbaFile.DoFileRead lol
1 parent 385855a commit bebe606

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Source/simba.hash.pas

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface
1111

1212
uses
1313
Classes, SysUtils,
14-
simba.base, simba.fs;
14+
simba.base;
1515

1616
type
1717
{$SCOPEDENUMS ON}
@@ -63,13 +63,28 @@ function HashString(Algo: EHashAlgo; const S: String): String;
6363

6464
function HashFile(Algo: EHashAlgo; const FileName: String): String;
6565
var
66+
Stream: TFileStream;
6667
Bytes: TByteArray;
6768
begin
69+
Bytes := [];
70+
Stream := nil;
71+
6872
try
69-
Bytes := TSimbaFile.FileReadBytes((FileName);
73+
Stream := TFileStream.Create(FileName, fmOpenRead);
74+
if (Len = -1) then
75+
Len := $FFFFFF;
76+
SetLength(Bytes, Min(Len, Stream.Size - Offset));
77+
if (Length(Bytes) > 0) then
78+
begin
79+
Stream.Seek(Offset, soBeginning);
80+
Stream.ReadBuffer(Bytes[0], Length(Bytes));
81+
end;
7082
except
7183
end;
7284

85+
if (Stream <> nil) then
86+
Stream.Free();
87+
7388
if (Length(Bytes) > 0) then
7489
Result := HashBuffer(Algo, @Bytes[0], Length(Bytes))
7590
else

0 commit comments

Comments
 (0)