-
Notifications
You must be signed in to change notification settings - Fork 579
Expand file tree
/
Copy pathFileSystem.cs
More file actions
257 lines (241 loc) · 12.1 KB
/
FileSystem.cs
File metadata and controls
257 lines (241 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
using System;
using System.Collections.Generic;
using System.IO;
using Cosmos.HAL.BlockDevice;
using Cosmos.System.FileSystem.Listing;
namespace Cosmos.System.FileSystem
{
/// <summary>
/// FileSystem abstract class.
/// </summary>
public abstract class FileSystem
{
/// <summary>
/// Initializes a new instance of the <see cref="FileSystem"/> class.
/// </summary>
/// <param name="aDevice">A partiton managed by the filesystem.</param>
/// <param name="aRootPath">A root path.</param>
/// <param name="aSize">A partition size.</param>
protected FileSystem(Partition aDevice, string aRootPath, long aSize)
{
Device = aDevice;
RootPath = aRootPath;
Size = aSize;
}
/// <summary>
/// Print filesystem info.
/// </summary>
/// <exception cref="IOException">Thrown on I/O error.</exception>
public abstract void DisplayFileSystemInfo();
/// <summary>
/// Get list of sub-directories in a directory.
/// </summary>
/// <param name="baseDirectory">A base directory.</param>
/// <returns>DirectoryEntry list.</returns>
/// <exception cref="ArgumentNullException">Thrown when baseDirectory is null / memory error.</exception>
/// <exception cref="OverflowException">Thrown when data lenght is greater then Int32.MaxValue.</exception>
/// <exception cref="Exception">Thrown when data size invalid / invalid directory entry type.</exception>
/// <exception cref="ArgumentException">Thrown on memory error.</exception>
/// <exception cref="ArgumentOutOfRangeException">Thrown on memory error.</exception>
/// <exception cref="DecoderFallbackException">Thrown on memory error.</exception>
public abstract List<DirectoryEntry> GetDirectoryListing(DirectoryEntry baseDirectory);
/// <summary>
/// Get root directory.
/// </summary>
/// <returns>DirectoryEntry value.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown when root directory address is smaller then root directory address.</exception>
/// <exception cref="ArgumentNullException">Thrown when filesystem is null.</exception>
/// <exception cref="ArgumentException">Thrown when root path is null or empty.</exception>
public abstract DirectoryEntry GetRootDirectory();
/// <summary>
/// Create directory.
/// </summary>
/// <param name="aParentDirectory">A parent directory.</param>
/// <param name="aNewDirectory">A new directory name.</param>
/// <returns>DirectoryEntry value.</returns>
/// <exception cref="ArgumentNullException">
/// <list type="bullet">
/// <item>Thrown when aParentDirectory is null.</item>
/// <item>aNewDirectory is null or empty.</item>
/// <item>memory error.</item>
/// </list>
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">Thrown on memory error / unknown directory entry type.</exception>
/// <exception cref="OverflowException">Thrown when data lenght is greater then Int32.MaxValue.</exception>
/// <exception cref="Exception">Thrown when data size invalid / invalid directory entry type / memory error.</exception>
/// <exception cref="ArgumentException">Thrown on memory error.</exception>
/// <exception cref="DecoderFallbackException">Thrown on memory error.</exception>
/// <exception cref="RankException">Thrown on fatal error.</exception>
/// <exception cref="ArrayTypeMismatchException">Thrown on fatal error.</exception>
/// <exception cref="InvalidCastException">Thrown on memory error.</exception>
public abstract DirectoryEntry CreateDirectory(DirectoryEntry aParentDirectory, string aNewDirectory);
/// <summary>
/// Create file.
/// </summary>
/// <param name="aParentDirectory">A parent directory.</param>
/// <param name="aNewFile">A new file name.</param>
/// <returns>DirectoryEntry value.</returns>
/// <exception cref="ArgumentNullException">
/// <list type="bullet">
/// <item>Thrown when aParentDirectory is null.</item>
/// <item>aNewFile is null or empty.</item>
/// <item>memory error.</item>
/// </list>
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">Thrown on memory error / unknown directory entry type.</exception>
/// <exception cref="OverflowException">Thrown when data lenght is greater then Int32.MaxValue.</exception>
/// <exception cref="Exception">Thrown when data size invalid / invalid directory entry type / memory error.</exception>
/// <exception cref="ArgumentException">Thrown on memory error.</exception>
/// <exception cref="DecoderFallbackException">Thrown on memory error.</exception>
/// <exception cref="RankException">Thrown on fatal error.</exception>
/// <exception cref="ArrayTypeMismatchException">Thrown on fatal error.</exception>
/// <exception cref="InvalidCastException">Thrown on memory error.</exception>
public abstract DirectoryEntry CreateFile(DirectoryEntry aParentDirectory, string aNewFile);
/// <summary>
/// Delete directory.
/// </summary>
/// <param name="aDirectoryEntry">A directory entry to delete.</param>
/// <exception cref="NotImplementedException">Thrown when given entry type is unknown.</exception>
/// <exception cref="Exception">
/// <list type="bullet">
/// <item>Thrown when tring to delete root directory.</item>
/// <item>directory entry type is invalid.</item>
/// <item>data size invalid.</item>
/// <item>FAT table not found.</item>
/// <item>out of memory.</item>
/// </list>
/// </exception>
/// <exception cref="OverflowException">Thrown when data lenght is greater then Int32.MaxValue.</exception>
/// <exception cref="ArgumentNullException">
/// <list type="bullet">
/// <item>Thrown when aDirectoryEntry is null.</item>
/// <item>aData is null.</item>
/// <item>Out of memory.</item>
/// </list>
/// </exception>
/// <exception cref="RankException">Thrown on fatal error.</exception>
/// <exception cref="ArrayTypeMismatchException">Thrown on fatal error.</exception>
/// <exception cref="InvalidCastException">Thrown when the data in aData is corrupted.</exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <list type = "bullet" >
/// <item>Thrown when the data length is 0 or greater then Int32.MaxValue.</item>
/// <item>Entrys matadata offset value is invalid.</item>
/// </list>
/// </exception>
/// <exception cref="ArgumentException">
/// <list type="bullet">
/// <item>aData length is 0.</item>
/// </list>
/// </exception>
/// <exception cref="NotSupportedException">Thrown when FAT type is unknown.</exception>
public abstract void DeleteDirectory(DirectoryEntry aPath);
/// <summary>
/// Delete file.
/// </summary>
/// <param name="aDirectoryEntry">A directory entry to delete.</param>
/// <exception cref="NotImplementedException">Thrown when given entry type is unknown.</exception>
/// <exception cref="Exception">
/// <list type="bullet">
/// <item>Thrown when tring to delete root directory.</item>
/// <item>directory entry type is invalid.</item>
/// <item>data size invalid.</item>
/// <item>FAT table not found.</item>
/// <item>out of memory.</item>
/// </list>
/// </exception>
/// <exception cref="OverflowException">
/// <list type="bullet">
/// <item>Thrown when data lenght is greater then Int32.MaxValue.</item>
/// <item>The number of clusters in the FAT entry is greater than Int32.MaxValue.</item>
/// </list>
/// </exception>
/// <exception cref="ArgumentNullException">
/// <list type="bullet">
/// <item>Thrown when aDirectoryEntry is null.</item>
/// <item>aData is null.</item>
/// <item>Out of memory.</item>
/// </list>
/// </exception>
/// <exception cref="RankException">Thrown on fatal error.</exception>
/// <exception cref="ArrayTypeMismatchException">Thrown on fatal error.</exception>
/// <exception cref="InvalidCastException">Thrown when the data in aData is corrupted.</exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <list type = "bullet" >
/// <item>Thrown when the data length is 0 or greater then Int32.MaxValue.</item>
/// <item>The size of the chain is less then zero.</item>
/// <item>Entrys matadata offset value is invalid.</item>
/// </list>
/// </exception>
/// <exception cref="ArgumentException">
/// <list type="bullet">
/// <item>Thrown when FAT type is unknown.</item>
/// <item>aData length is 0.</item>
/// </list>
/// </exception>
/// <exception cref="NotSupportedException">Thrown when FAT type is unknown.</exception>
public abstract void DeleteFile(DirectoryEntry aPath);
/// <summary>
/// Get device.
/// </summary>
protected Partition Device { get; }
/// <summary>
/// Get root path.
/// </summary>
public string RootPath { get; }
/// <summary>
/// Get size.
/// </summary>
public long Size { get; }
/// <summary>
/// Get available free space.
/// </summary>
public abstract long AvailableFreeSpace { get; }
/// <summary>
/// Get total free space.
/// </summary>
public abstract long TotalFreeSpace { get; }
/// <summary>
/// Get type.
/// </summary>
public abstract string Type { get; }
/// <summary>
/// Get label.
/// </summary>
public abstract string Label { get; set; }
/// <summary>
/// Format drive. (delete all)
/// </summary>
/// <param name="aDriveFormat">Drive format. E.g. FAT32, FAT16...</param>
/// <param name="aQuick">Quick format. If false, partition is filled with 0.</param>
/// <exception cref="ArgumentOutOfRangeException">
/// <list type = "bullet" >
/// <item>Thrown when the data length is 0 or greater then Int32.MaxValue.</item>
/// <item>Entrys matadata offset value is invalid.</item>
/// <item>Fatal error.</item>
/// </list>
/// </exception>
/// <exception cref="ArgumentNullException">Thrown when filesystem is null / memory error.</exception>
/// <exception cref="ArgumentException">
/// <list type="bullet">
/// <item>Data length is 0.</item>
/// <item>Root path is null or empty.</item>
/// <item>Memory error.</item>
/// </list>
/// </exception>
/// <exception cref="Exception">
/// <list type="bullet">
/// <item>Thrown when data size invalid.</item>
/// <item>Thrown on unknown file system type.</item>
/// <item>Thrown on fatal error.</item>
/// </list>
/// </exception>
/// <exception cref="OverflowException">Thrown when data lenght is greater then Int32.MaxValue.</exception>
/// <exception cref="DecoderFallbackException">Thrown on memory error.</exception>
/// <exception cref="NotImplementedException">Thrown when FAT type is unknown.</exception>
/// <exception cref="RankException">Thrown on fatal error.</exception>
/// <exception cref="ArrayTypeMismatchException">Thrown on fatal error.</exception>
/// <exception cref="InvalidCastException">Thrown when the data in aData is corrupted.</exception>
/// <exception cref="NotSupportedException">Thrown when FAT type is unknown.</exception>
public abstract void Format(string aDriveFormat, bool aQuick, string Label);
}
}