dcbasictypes.pas 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {
  2. Double commander
  3. -------------------------------------------------------------------------
  4. Definitions of basic types.
  5. Copyright (C) 2012 Przemyslaw Nagay ([email protected])
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. }
  18. unit DCBasicTypes;
  19. {$mode objfpc}{$H+}
  20. {$modeswitch advancedrecords}
  21. interface
  22. type
  23. TDynamicStringArray = array of String;
  24. TCharSet = set of Char;
  25. TFileAttrs = Cardinal; // file attributes type regardless of system
  26. TWinFileTime = QWord; // NTFS time (UTC) (2 x DWORD)
  27. TDosFileTime = LongInt; // MS-DOS time (local)
  28. TUnixFileTime = Int64; // UNIX time (UTC)
  29. {$IFDEF MSWINDOWS}
  30. TFileTime = TWinFileTime;
  31. TFileTimeEx = TFileTime;
  32. {$ELSE}
  33. TFileTime = TUnixFileTime;
  34. TFileTimeEx = record
  35. public
  36. sec: int64;
  37. nanosec: int64;
  38. public
  39. constructor create( aSec:int64; aNanosec:int64=0 );
  40. class operator =(l,r : TFileTimeEx): Boolean;
  41. end;
  42. {$ENDIF}
  43. PFileTime = ^TFileTime;
  44. PWinFileTime = ^TWinFileTime;
  45. const
  46. TFileTimeExNull: TFileTimeEx = {$IFDEF MSWINDOWS} 0 {$ELSE} (sec:0; nanosec:-1) {$ENDIF};
  47. implementation
  48. {$IF not DEFINED(MSWINDOWS)}
  49. constructor TFileTimeEx.Create(aSec: Int64; aNanosec: Int64);
  50. begin
  51. Self.sec:= aSec;
  52. Self.nanosec:= aNanosec;
  53. if Self.nanosec < 0 then
  54. Self.nanosec := 0
  55. else if Self.nanosec > 999999999 then
  56. begin
  57. Self.nanosec := 999999999;
  58. end;
  59. end;
  60. class operator TFileTimeEx.=(l,r : TFileTimeEx): Boolean;
  61. begin
  62. Result:= (l.sec=r.sec) and (l.nanosec=r.nanosec);
  63. end;
  64. {$ENDIF}
  65. end.