| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- {========================================================================}
- {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
- {========================================================================}
- {= All Rights Reserved =}
- {========================================================================}
- {= D 01099 Dresden = Tel.: +0351-8012255 =}
- {= Loewenstr.7a = info@swiftsoft.de =}
- {========================================================================}
- {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
- {========================================================================}
- {= This code is for reference purposes only and may not be copied or =}
- {= distributed in any format electronic or otherwise except one copy =}
- {= for backup purposes. =}
- {= =}
- {= No Delphi Component Kit or Component individually or in a collection=}
- {= subclassed or otherwise from the code in this unit, or associated =}
- {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
- {= without express permission from SwiftSoft. =}
- {= =}
- {= For more licence informations please refer to the associated =}
- {= HelpFile. =}
- {========================================================================}
- {= $Date: 20.01.1998 - 18:00:00 $ =}
- {========================================================================}
- unit MMFFile;
- {$I COMPILER.INC}
- interface
- uses
- Windows,
- SysUtils,
- Controls,
- Classes,
- MMSystem,
- MMObj,
- MMUtils,
- MMString,
- MMSearch;
- type
- EMMFastFileError = class(Exception);
- PFileEntry = ^TFileEntry;
- TFileEntry = record
- Name : String;
- Size : Longint;
- Offset : Longint;
- Deleted: Boolean;
- end;
- PFileEntryArray = ^TFileEntryArray;
- TFileEntryArray = array[0..0] of TFileEntry;
- PFileHandle = ^TFileHandle;
- TFileHandle = record
- inUse: Boolean;
- Pos : Longint;
- Size : Longint;
- pfe : PFileEntry;
- end;
- PFileHandleArray = ^TFileHandleArray;
- TFileHandleArray = array[0..0] of TFileHandle;
- {-- TMMFastFile -----------------------------------------------------}
- TMMFastFile = class(TMMComponent)
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure Init;
- procedure Done;
- procedure Pack;
- function AddFile(const Name: TFileName): TFileName;
- procedure RemoveFile(const Name: TFileName);
- procedure RenameFile(const OldName, NewName: TFileName);
- procedure ExtractFile(const Name, Path: TFileName);
- function FileExists(const Name: TFileName): Boolean;
- function FileSize(const Name: TFileName): integer;
- function FileOpen(const Name: TFileName): PFileHandle;
- procedure FileClose(pfh: PFileHandle);
- function FileLock(pfh: PFileHandle; pos, size: integer): Pointer;
- procedure FileUnlock(pfh: PFileHandle; pos, size: integer);
- function FileRead(pfh: PFileHandle; Buffer: PChar; size: integer): integer;
- function FileSeek(pfh: PFileHandle; pos, origin: integer): integer;
- property Count: integer read GetCount;
- property FileEntrys[index: integer]: TFileEntry read GetFileEntrys;
- property Files[index: integer]: string read GetFiles;
- property FilesByName[Name: string]: string read GetFilesByName;
- published
- property OnChange: TNotifyEvent read FOnChange write FOnChange;
- property OnHandlesLost: TNotifyEvent read FOnHandlesLost write FOnHandlesLost;
- property FileName: TFileName read FFileName write SetFileName;
- property MaxFiles: integer read FMaxFiles write SetMaxFiles default 50;
- property MaxHandles: integer read FMaxHandles write SetMaxHandles default 10;
- end;
- implementation
|