summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bdb5b5a)
raw | patch | inline | side by side (parent: bdb5b5a)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 13 Oct 2019 00:21:38 +0000 (03:21 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 13 Oct 2019 00:22:55 +0000 (03:22 +0300) |
src/shared/utils.pas | patch | blob | history |
diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index 5ef58845df0057b088866ef616bbf1e1f6b3ebcf..867f0dcbef1befffb33b7d3a66cc40b57eeb360e 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
interface
uses
- SysUtils, Classes;
+ SysUtils, Classes, md5;
// ////////////////////////////////////////////////////////////////////////// //
procedure ZeroMemory (Dest: Pointer; Len: LongWord); inline;
+type
+ TDiskFileInfo = record
+ diskName: AnsiString;
+ size: LongInt;
+ age: LongInt;
+ // not changed by info getter; used in other parts of the code
+ userName: AnsiString;
+ tag: Integer;
+ hash: TMD5Digest;
+ udata: Pointer;
+ end;
+
+function GetDiskFileInfo (fname: AnsiString; var info: TDiskFileInfo): Boolean;
+
+
implementation
uses
end;
+function GetDiskFileInfo (fname: AnsiString; var info: TDiskFileInfo): Boolean;
+var
+ age: LongInt;
+ size: LongInt;
+ handle: THandle;
+begin
+ result := false;
+ if (length(fname) = 0) then exit;
+ if not findFileCI(fname) then exit;
+ // get age
+ age := FileAge(fname);
+ if (age = -1) then exit;
+ // get size
+ handle := FileOpen(fname, fmOpenRead or fmShareDenyNone);
+ if (handle = THandle(-1)) then exit;
+ size := FileSeek(handle, 0, fsFromEnd);
+ FileClose(handle);
+ if (size = -1) then exit;
+ // fill info
+ info.diskName := fname;
+ info.size := size;
+ info.age := age;
+ result := true;
+end;
+
+
(*
var
ss: ShortString;