using System; using System.Collections.Generic; using System.IO; using Cosmos.HAL.BlockDevice; using Cosmos.System.FileSystem.FAT; using Cosmos.System.FileSystem.Listing; namespace Cosmos.System.FileSystem { /// /// FileSystem abstract class. /// public abstract class FileSystem { /// /// Initializes a new instance of the class. /// /// A partiton managed by the filesystem. /// A root path. /// A partition size. protected FileSystem(Partition aDevice, string aRootPath, long aSize) { Device = aDevice; RootPath = aRootPath; Size = aSize; } /// /// Print filesystem info. /// /// Thrown on I/O error. public abstract void DisplayFileSystemInfo(); /// /// Get list of sub-directories in a directory. /// /// A base directory. /// DirectoryEntry list. /// Thrown when baseDirectory is null / memory error. /// Thrown when data lenght is greater then Int32.MaxValue. /// Thrown when data size invalid / invalid directory entry type. /// Thrown on memory error. /// Thrown on memory error. /// Thrown on memory error. public abstract List GetDirectoryListing(DirectoryEntry baseDirectory); /// /// Get root directory. /// /// DirectoryEntry value. /// Thrown when root directory address is smaller then root directory address. /// Thrown when filesystem is null. /// Thrown when root path is null or empty. public abstract DirectoryEntry GetRootDirectory(); /// /// Create directory. /// /// A parent directory. /// A new directory name. /// DirectoryEntry value. /// /// /// Thrown when aParentDirectory is null. /// aNewDirectory is null or empty. /// memory error. /// /// /// Thrown on memory error / unknown directory entry type. /// Thrown when data lenght is greater then Int32.MaxValue. /// Thrown when data size invalid / invalid directory entry type / memory error. /// Thrown on memory error. /// Thrown on memory error. /// Thrown on fatal error (contact support). /// Thrown on fatal error (contact support). /// Thrown on memory error. public abstract DirectoryEntry CreateDirectory(DirectoryEntry aParentDirectory, string aNewDirectory); /// /// Create file. /// /// A parent directory. /// A new file name. /// DirectoryEntry value. /// /// /// Thrown when aParentDirectory is null. /// aNewFile is null or empty. /// memory error. /// /// /// Thrown on memory error / unknown directory entry type. /// Thrown when data lenght is greater then Int32.MaxValue. /// Thrown when data size invalid / invalid directory entry type / memory error. /// Thrown on memory error. /// Thrown on memory error. /// Thrown on fatal error (contact support). /// Thrown on fatal error (contact support). /// Thrown on memory error. public abstract DirectoryEntry CreateFile(DirectoryEntry aParentDirectory, string aNewFile); /// /// Delete directory. /// /// A directory entry to delete. /// Thrown when given entry type is unknown. /// /// /// Thrown when tring to delete root directory. /// directory entry type is invalid. /// data size invalid. /// FAT table not found. /// out of memory. /// /// /// Thrown when data lenght is greater then Int32.MaxValue. /// /// /// Thrown when aDirectoryEntry is null. /// aData is null. /// Out of memory. /// /// /// Thrown on fatal error (contact support). /// Thrown on fatal error (contact support). /// Thrown when the data in aData is corrupted. /// /// /// Thrown when the data length is 0 or greater then Int32.MaxValue. /// Entrys matadata offset value is invalid. /// /// /// /// /// aData length is 0. /// /// /// Thrown when FAT type is unknown. public abstract void DeleteDirectory(DirectoryEntry aPath); /// /// Delete file. /// /// A directory entry to delete. /// Thrown when given entry type is unknown. /// /// /// Thrown when tring to delete root directory. /// directory entry type is invalid. /// data size invalid. /// FAT table not found. /// out of memory. /// /// /// /// /// Thrown when data lenght is greater then Int32.MaxValue. /// The number of clusters in the FAT entry is greater than Int32.MaxValue. /// /// /// /// /// Thrown when aDirectoryEntry is null. /// aData is null. /// Out of memory. /// /// /// Thrown on fatal error (contact support). /// Thrown on fatal error (contact support). /// Thrown when the data in aData is corrupted. /// /// /// Thrown when the data length is 0 or greater then Int32.MaxValue. /// The size of the chain is less then zero. /// Entrys matadata offset value is invalid. /// /// /// /// /// Thrown when FAT type is unknown. /// aData length is 0. /// /// /// Thrown when FAT type is unknown. public abstract void DeleteFile(DirectoryEntry aPath); /// /// Get device. /// protected Partition Device { get; } /// /// Get root path. /// public string RootPath { get; } /// /// Get size. /// public long Size { get; } /// /// Get available free space. /// public abstract long AvailableFreeSpace { get; } /// /// Get total free space. /// public abstract long TotalFreeSpace { get; } /// /// Get type. /// public abstract string Type { get; } /// /// Get label. /// public abstract string Label { get; set; } /// /// Format drive. (delete all) /// /// unused. /// unused. /// /// /// Thrown when the data length is 0 or greater then Int32.MaxValue. /// Entrys matadata offset value is invalid. /// Fatal error (contact support). /// /// /// Thrown when filesystem is null / memory error. /// /// /// Data length is 0. /// Root path is null or empty. /// Memory error. /// /// /// /// /// Thrown when data size invalid. /// Thrown on unknown file system type. /// Thrown on fatal error (contact support). /// /// /// Thrown when data lenght is greater then Int32.MaxValue. /// Thrown on memory error. /// Thrown when FAT type is unknown. /// Thrown on fatal error (contact support). /// Thrown on fatal error (contact support). /// Thrown when the data in aData is corrupted. /// Thrown when FAT type is unknown. public abstract void Format(string aDriveFormat, bool aQuick); } }