[390] | 1 | // In development
|
---|
| 2 |
|
---|
| 3 | unit UFileManager;
|
---|
| 4 |
|
---|
| 5 | {$mode delphi}{$H+}
|
---|
| 6 |
|
---|
| 7 | interface
|
---|
| 8 |
|
---|
| 9 | uses
|
---|
| 10 | Classes, SysUtils;
|
---|
| 11 |
|
---|
| 12 | type
|
---|
| 13 | TDirectory = class;
|
---|
| 14 | TFileSystem = class;
|
---|
| 15 |
|
---|
| 16 | { TFile }
|
---|
| 17 |
|
---|
| 18 | TFile = class
|
---|
| 19 | private
|
---|
| 20 | function GetAbsoluteName: string;
|
---|
| 21 | function GetSize: Integer;
|
---|
| 22 | procedure SetSize(AValue: Integer);
|
---|
| 23 | public
|
---|
| 24 | Path: TDirectory;
|
---|
| 25 | Name: string;
|
---|
| 26 | Extension: string;
|
---|
| 27 | function ReadInteger: Integer;
|
---|
| 28 | procedure WriteInteger(const Value: Integer);
|
---|
| 29 | function Exists: Boolean;
|
---|
| 30 | procedure Delete;
|
---|
| 31 | procedure Rename(const Name: string);
|
---|
| 32 | property Size: Integer read GetSize write SetSize;
|
---|
| 33 | property AbsoluteName: string read GetAbsoluteName;
|
---|
| 34 | end;
|
---|
| 35 |
|
---|
| 36 | { TDirectory }
|
---|
| 37 |
|
---|
| 38 | TDirectory = class
|
---|
| 39 | private
|
---|
| 40 | function GetAbsoluteName: string;
|
---|
| 41 | public
|
---|
| 42 | FileSystem: TFileSystem;
|
---|
| 43 | Path: string;
|
---|
| 44 | procedure MoveTo(Target: TDirectory);
|
---|
| 45 | procedure CopyTo(Target: TDirectory);
|
---|
| 46 | procedure Rename(const Name: string);
|
---|
| 47 | procedure Delete;
|
---|
| 48 | function Exists: Boolean;
|
---|
| 49 | function GetFile(const Name: string): TFile;
|
---|
| 50 | property AbsoluteName: string read GetAbsoluteName;
|
---|
| 51 | end;
|
---|
| 52 |
|
---|
| 53 | { TFileSystem }
|
---|
| 54 |
|
---|
| 55 | TFileSystem = class
|
---|
| 56 | Identification: string;
|
---|
| 57 | Name: string;
|
---|
| 58 | Format: string;
|
---|
| 59 | function OpenDirectory(Path: string): TDirectory;
|
---|
| 60 | end;
|
---|
| 61 |
|
---|
| 62 | { TDiskManager }
|
---|
| 63 |
|
---|
| 64 | TDiskManager = class
|
---|
| 65 | function OpenFileSystem(Identification: string): TFileSystem;
|
---|
| 66 | end;
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | implementation
|
---|
| 71 |
|
---|
| 72 | { TFileSystem }
|
---|
| 73 |
|
---|
| 74 | function TFileSystem.OpenDirectory(Path: string): TDirectory;
|
---|
| 75 | begin
|
---|
| 76 | Result := TDirectory.Create;
|
---|
| 77 | Result.FileSystem := Self;
|
---|
| 78 | Result.Path := Path;
|
---|
| 79 | end;
|
---|
| 80 |
|
---|
| 81 | { TDiskManager }
|
---|
| 82 |
|
---|
| 83 | function TDiskManager.OpenFileSystem(Identification: string): TFileSystem;
|
---|
| 84 | begin
|
---|
| 85 |
|
---|
| 86 | end;
|
---|
| 87 |
|
---|
| 88 | { TDirectory }
|
---|
| 89 |
|
---|
| 90 | function TDirectory.GetAbsoluteName: string;
|
---|
| 91 | begin
|
---|
| 92 | Result := FileSystem.Identification + DriveSeparator + Path;
|
---|
| 93 | end;
|
---|
| 94 |
|
---|
| 95 | procedure TDirectory.MoveTo(Target: TDirectory);
|
---|
| 96 | begin
|
---|
| 97 |
|
---|
| 98 | end;
|
---|
| 99 |
|
---|
| 100 | procedure TDirectory.CopyTo(Target: TDirectory);
|
---|
| 101 | begin
|
---|
| 102 |
|
---|
| 103 | end;
|
---|
| 104 |
|
---|
| 105 | procedure TDirectory.Rename(const Name: string);
|
---|
| 106 | begin
|
---|
| 107 | //RenameDir(Self.Path, Name);
|
---|
| 108 | end;
|
---|
| 109 |
|
---|
| 110 | procedure TDirectory.Delete;
|
---|
| 111 | begin
|
---|
| 112 | RemoveDir(Path);
|
---|
| 113 | end;
|
---|
| 114 |
|
---|
| 115 | function TDirectory.Exists: Boolean;
|
---|
| 116 | begin
|
---|
| 117 | Result := DirectoryExists(AbsoluteName);
|
---|
| 118 | end;
|
---|
| 119 |
|
---|
| 120 | function TDirectory.GetFile(const Name: string): TFile;
|
---|
| 121 | begin
|
---|
| 122 | Result := TFile.Create;
|
---|
| 123 | Result.Path := Self;
|
---|
| 124 | Result.Name := Name;
|
---|
| 125 | end;
|
---|
| 126 |
|
---|
| 127 | { TFile }
|
---|
| 128 |
|
---|
| 129 | function TFile.GetAbsoluteName: string;
|
---|
| 130 | begin
|
---|
| 131 | Result := Path.AbsoluteName + DirectorySeparator + Name +
|
---|
| 132 | ExtensionSeparator + Extension;
|
---|
| 133 | end;
|
---|
| 134 |
|
---|
| 135 | function TFile.GetSize: Integer;
|
---|
| 136 | begin
|
---|
| 137 |
|
---|
| 138 | end;
|
---|
| 139 |
|
---|
| 140 | procedure TFile.SetSize(AValue: Integer);
|
---|
| 141 | begin
|
---|
| 142 |
|
---|
| 143 | end;
|
---|
| 144 |
|
---|
| 145 | function TFile.ReadInteger: Integer;
|
---|
| 146 | begin
|
---|
| 147 |
|
---|
| 148 | end;
|
---|
| 149 |
|
---|
| 150 | procedure TFile.WriteInteger(const Value: Integer);
|
---|
| 151 | begin
|
---|
| 152 |
|
---|
| 153 | end;
|
---|
| 154 |
|
---|
| 155 | function TFile.Exists: Boolean;
|
---|
| 156 | begin
|
---|
| 157 | Result := FileExists(AbsoluteName);
|
---|
| 158 | end;
|
---|
| 159 |
|
---|
| 160 | procedure TFile.Delete;
|
---|
| 161 | begin
|
---|
| 162 | DeleteFile(AbsoluteName);
|
---|
| 163 | end;
|
---|
| 164 |
|
---|
| 165 | procedure TFile.Rename(const Name: string);
|
---|
| 166 | begin
|
---|
| 167 | RenameFile(AbsoluteName, Name);
|
---|
| 168 | end;
|
---|
| 169 |
|
---|
| 170 | end.
|
---|
| 171 |
|
---|