MMFFILE.INT 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {========================================================================}
  2. {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
  3. {========================================================================}
  4. {= All Rights Reserved =}
  5. {========================================================================}
  6. {= D 01099 Dresden = Tel.: +0351-8012255 =}
  7. {= Loewenstr.7a = info@swiftsoft.de =}
  8. {========================================================================}
  9. {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
  10. {========================================================================}
  11. {= This code is for reference purposes only and may not be copied or =}
  12. {= distributed in any format electronic or otherwise except one copy =}
  13. {= for backup purposes. =}
  14. {= =}
  15. {= No Delphi Component Kit or Component individually or in a collection=}
  16. {= subclassed or otherwise from the code in this unit, or associated =}
  17. {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
  18. {= without express permission from SwiftSoft. =}
  19. {= =}
  20. {= For more licence informations please refer to the associated =}
  21. {= HelpFile. =}
  22. {========================================================================}
  23. {= $Date: 20.01.1998 - 18:00:00 $ =}
  24. {========================================================================}
  25. unit MMFFile;
  26. {$I COMPILER.INC}
  27. interface
  28. uses
  29. Windows,
  30. SysUtils,
  31. Controls,
  32. Classes,
  33. MMSystem,
  34. MMObj,
  35. MMUtils,
  36. MMString,
  37. MMSearch;
  38. type
  39. EMMFastFileError = class(Exception);
  40. PFileEntry = ^TFileEntry;
  41. TFileEntry = record
  42. Name : String;
  43. Size : Longint;
  44. Offset : Longint;
  45. Deleted: Boolean;
  46. end;
  47. PFileEntryArray = ^TFileEntryArray;
  48. TFileEntryArray = array[0..0] of TFileEntry;
  49. PFileHandle = ^TFileHandle;
  50. TFileHandle = record
  51. inUse: Boolean;
  52. Pos : Longint;
  53. Size : Longint;
  54. pfe : PFileEntry;
  55. end;
  56. PFileHandleArray = ^TFileHandleArray;
  57. TFileHandleArray = array[0..0] of TFileHandle;
  58. {-- TMMFastFile -----------------------------------------------------}
  59. TMMFastFile = class(TMMComponent)
  60. public
  61. constructor Create(AOwner: TComponent); override;
  62. destructor Destroy; override;
  63. procedure Init;
  64. procedure Done;
  65. procedure Pack;
  66. function AddFile(const Name: TFileName): TFileName;
  67. procedure RemoveFile(const Name: TFileName);
  68. procedure RenameFile(const OldName, NewName: TFileName);
  69. procedure ExtractFile(const Name, Path: TFileName);
  70. function FileExists(const Name: TFileName): Boolean;
  71. function FileSize(const Name: TFileName): integer;
  72. function FileOpen(const Name: TFileName): PFileHandle;
  73. procedure FileClose(pfh: PFileHandle);
  74. function FileLock(pfh: PFileHandle; pos, size: integer): Pointer;
  75. procedure FileUnlock(pfh: PFileHandle; pos, size: integer);
  76. function FileRead(pfh: PFileHandle; Buffer: PChar; size: integer): integer;
  77. function FileSeek(pfh: PFileHandle; pos, origin: integer): integer;
  78. property Count: integer read GetCount;
  79. property FileEntrys[index: integer]: TFileEntry read GetFileEntrys;
  80. property Files[index: integer]: string read GetFiles;
  81. property FilesByName[Name: string]: string read GetFilesByName;
  82. published
  83. property OnChange: TNotifyEvent read FOnChange write FOnChange;
  84. property OnHandlesLost: TNotifyEvent read FOnHandlesLost write FOnHandlesLost;
  85. property FileName: TFileName read FFileName write SetFileName;
  86. property MaxFiles: integer read FMaxFiles write SetMaxFiles default 50;
  87. property MaxHandles: integer read FMaxHandles write SetMaxHandles default 10;
  88. end;
  89. implementation