source: FileSystem/UFileManager.pas

Last change on this file was 390, checked in by chronos, 12 years ago
File size: 3.0 KB
Line 
1// In development
2
3unit UFileManager;
4
5{$mode delphi}{$H+}
6
7interface
8
9uses
10 Classes, SysUtils;
11
12type
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
70implementation
71
72{ TFileSystem }
73
74function TFileSystem.OpenDirectory(Path: string): TDirectory;
75begin
76 Result := TDirectory.Create;
77 Result.FileSystem := Self;
78 Result.Path := Path;
79end;
80
81{ TDiskManager }
82
83function TDiskManager.OpenFileSystem(Identification: string): TFileSystem;
84begin
85
86end;
87
88{ TDirectory }
89
90function TDirectory.GetAbsoluteName: string;
91begin
92 Result := FileSystem.Identification + DriveSeparator + Path;
93end;
94
95procedure TDirectory.MoveTo(Target: TDirectory);
96begin
97
98end;
99
100procedure TDirectory.CopyTo(Target: TDirectory);
101begin
102
103end;
104
105procedure TDirectory.Rename(const Name: string);
106begin
107 //RenameDir(Self.Path, Name);
108end;
109
110procedure TDirectory.Delete;
111begin
112 RemoveDir(Path);
113end;
114
115function TDirectory.Exists: Boolean;
116begin
117 Result := DirectoryExists(AbsoluteName);
118end;
119
120function TDirectory.GetFile(const Name: string): TFile;
121begin
122 Result := TFile.Create;
123 Result.Path := Self;
124 Result.Name := Name;
125end;
126
127{ TFile }
128
129function TFile.GetAbsoluteName: string;
130begin
131 Result := Path.AbsoluteName + DirectorySeparator + Name +
132 ExtensionSeparator + Extension;
133end;
134
135function TFile.GetSize: Integer;
136begin
137
138end;
139
140procedure TFile.SetSize(AValue: Integer);
141begin
142
143end;
144
145function TFile.ReadInteger: Integer;
146begin
147
148end;
149
150procedure TFile.WriteInteger(const Value: Integer);
151begin
152
153end;
154
155function TFile.Exists: Boolean;
156begin
157 Result := FileExists(AbsoluteName);
158end;
159
160procedure TFile.Delete;
161begin
162 DeleteFile(AbsoluteName);
163end;
164
165procedure TFile.Rename(const Name: string);
166begin
167 RenameFile(AbsoluteName, Name);
168end;
169
170end.
171
Note: See TracBrowser for help on using the repository browser.