Преглед изворни кода

* raise exception when file not found.

git-svn-id: trunk@49166 -
marco пре 4 година
родитељ
комит
763d287af4
1 измењених фајлова са 10 додато и 1 уклоњено
  1. 10 1
      packages/hash/src/sha1.pp

+ 10 - 1
packages/hash/src/sha1.pp

@@ -51,6 +51,8 @@ function SHA1Match(const Digest1, Digest2: TSHA1Digest): Boolean;
 
 implementation
 
+uses sysutils,sysconst;
+
 // inverts the bytes of (Count div 4) cardinals from source to target.
 procedure Invert(Source, Dest: Pointer; Count: PtrUInt);
 var
@@ -257,6 +259,11 @@ begin
   SHA1Final(Context, Result);
 end;
 
+procedure RaiseFileNotFoundException(const fn : String);
+begin
+  raise EFileNotFoundException.Create(SFileNotFound);
+end;
+
 function SHA1File(const Filename: String; const Bufsize: PtrUInt): TSHA1Digest;
 var
   F: File;
@@ -284,7 +291,9 @@ begin
     until Count < BufSize;
     FreeMem(Buf, BufSize);
     Close(F);
-  end;
+  end
+  else
+    RaiseFileNotFoundException(FileName);
 
   SHA1Final(Context, Result);
   FileMode := ofm;