Class VFSManager
VFSManager (Virtual File System Manager) class. Used to manage files and directories.
Inheritance
Inherited Members
Namespace: Cosmos.System.FileSystem.VFS
Assembly: Cosmos.System2.dll
Syntax
public static class VFSManager
Methods
| Improve this Doc View SourceCreateDirectory(String)
Create directory.
Declaration
public static DirectoryEntry CreateDirectory(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the directory. |
Returns
Type | Description |
---|---|
DirectoryEntry | DirectoryEntry value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException | Thrown on memory error / unknown directory entry type. |
System.OverflowException | Thrown when data lenght is greater then Int32.MaxValue. |
System.Exception |
|
System.ArgumentException |
|
System.RankException | Thrown on fatal error. |
System.ArrayTypeMismatchException | Thrown on fatal error. |
System.InvalidCastException | Thrown on memory error. |
System.IO.PathTooLongException | Thrown when The aPath is longer than the system defined maximum length. |
CreateFile(String)
Create a file.
Declaration
public static DirectoryEntry CreateFile(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the file. |
Returns
Type | Description |
---|---|
DirectoryEntry | DirectoryEntry value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if aPath is null. |
System.ArgumentException | Thrown if aPath is empty or contains invalid chars. |
System.Exception |
|
System.IO.PathTooLongException | Thrown when aPath is longer than the system defined max lenght. |
DeleteDirectory(String, Boolean)
Delete directory.
Declaration
public static void DeleteDirectory(string aPath, bool recursive)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the directory. |
System.Boolean | recursive | Recursive delete (not empty directory). |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.OverflowException |
|
System.Exception |
|
System.IO.IOException | Thrown if specified path isn't a directory / trying to delete not empty directory not recursivly / directory contains a corrupted file. |
System.UnauthorizedAccessException | Thrown when trying to delete unknown type entry. |
DeleteFile(String)
Delete a file.
Declaration
public static void DeleteFile(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the file. |
Exceptions
Type | Condition |
---|---|
System.Exception |
|
System.UnauthorizedAccessException | Thrown when the specified path isn't a file |
DirectoryExists(DirectoryEntry)
Check if directory exists.
Declaration
public static bool DirectoryExists(DirectoryEntry aEntry)
Parameters
Type | Name | Description |
---|---|---|
DirectoryEntry | aEntry | A entry of the directory. |
Returns
Type | Description |
---|---|
System.Boolean | bool value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when aEntry is null. |
DirectoryExists(String)
Check if directory exists.
Declaration
public static bool DirectoryExists(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the directory. |
Returns
Type | Description |
---|---|
System.Boolean | bool value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aPath is null or empty. |
FileExists(DirectoryEntry)
Check if file exists.
Declaration
public static bool FileExists(DirectoryEntry aEntry)
Parameters
Type | Name | Description |
---|---|---|
DirectoryEntry | aEntry | A entry of the file. |
Returns
Type | Description |
---|---|
System.Boolean | bool value. |
FileExists(String)
Check if file exists.
Declaration
public static bool FileExists(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the file. |
Returns
Type | Description |
---|---|
System.Boolean | bool value. |
GetAltDirectorySeparatorChar()
Get alt. directory separator char.
Declaration
public static char GetAltDirectorySeparatorChar()
Returns
Type | Description |
---|---|
System.Char | char value. |
GetAvailableFreeSpace(String)
Get available free space.
Declaration
public static long GetAvailableFreeSpace(string aDriveId)
Parameters
Type | Name | Description |
---|---|---|
System.String | aDriveId | A drive id to get the size of. |
Returns
Type | Description |
---|---|
System.Int64 | long value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aDriveId is null or empty. |
System.Exception | Unable to determine filesystem for path: + aDriveId |
GetDirectory(String)
Get directory.
Declaration
public static DirectoryEntry GetDirectory(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the directory. |
Returns
Type | Description |
---|---|
DirectoryEntry | DirectoryEntry value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.OverflowException |
|
System.Exception |
|
GetDirectoryListing(String)
Get directory listing.
Declaration
public static List<DirectoryEntry> GetDirectoryListing(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the entry. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<DirectoryEntry> | DirectoryEntry list value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.OverflowException |
|
System.Exception |
|
GetDirectorySeparatorChar()
Get directory separator char.
Declaration
public static char GetDirectorySeparatorChar()
Returns
Type | Description |
---|---|
System.Char | char value. |
GetDisks()
Gets all of the disks
Declaration
public static List<Disk> GetDisks()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<Disk> | All of the disks on the system |
GetFile(String)
Get file.
Declaration
public static DirectoryEntry GetFile(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the file. |
Returns
Type | Description |
---|---|
DirectoryEntry | DirectoryEntry value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.OverflowException |
|
System.Exception |
|
GetFileAttributes(String)
Get file attributes.
Declaration
public static FileAttributes GetFileAttributes(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to the file |
Returns
Type | Description |
---|---|
System.IO.FileAttributes | FileAttributes value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.OverflowException |
|
System.Exception |
|
GetFileStream(String)
Get file stream.
Declaration
public static Stream GetFileStream(string aPathname)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPathname | A path to the file. |
Returns
Type | Description |
---|---|
System.IO.Stream | Stream value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.OverflowException |
|
System.Exception |
|
GetFileSystemLabel(String)
Get file system label.
Declaration
public static string GetFileSystemLabel(string aDriveId)
Parameters
Type | Name | Description |
---|---|---|
System.String | aDriveId | A drive id. |
Returns
Type | Description |
---|---|
System.String | string value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aDriveId is null or empty. |
System.Exception | Unable to determine filesystem for path: + aDriveId |
GetFileSystemType(String)
Get file system type.
Declaration
public static string GetFileSystemType(string aDriveId)
Parameters
Type | Name | Description |
---|---|---|
System.String | aDriveId | A drive id. |
Returns
Type | Description |
---|---|
System.String | string value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aDriveId is null or empty. |
System.Exception | Unable to determine filesystem for path: + aDriveId |
GetFullPath(DirectoryEntry)
Get full path to the entry.
Declaration
public static string GetFullPath(DirectoryEntry aEntry)
Parameters
Type | Name | Description |
---|---|---|
DirectoryEntry | aEntry | A entry. |
Returns
Type | Description |
---|---|
System.String | string value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when aEntry is null. |
GetInvalidFileNameChars()
Get invalid filename chars.
Declaration
public static char[] GetInvalidFileNameChars()
Returns
Type | Description |
---|---|
System.Char[] | char array value. |
GetInvalidPathCharsWithAdditionalChecks()
Get invalid path chars with additional checks.
Declaration
public static char[] GetInvalidPathCharsWithAdditionalChecks()
Returns
Type | Description |
---|---|
System.Char[] | char array value. |
GetLogicalDrives()
Get logical drivers list.
Declaration
public static List<string> GetLogicalDrives()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | List of strings value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if filesystem is null. |
System.ArgumentOutOfRangeException | Thrown when root directory address is smaller then root directory address. |
System.ArgumentException | Thrown when root path is null or empty. |
GetMaxPath()
Get max path.
Declaration
public static int GetMaxPath()
Returns
Type | Description |
---|---|
System.Int32 | int value. |
GetNextFilesystemLetter()
Gets the next file system letter. For internal cosmos use only.
Declaration
public static string GetNextFilesystemLetter()
Returns
Type | Description |
---|---|
System.String | Next file system letter |
GetParent(String)
Gets the parent directory entry from the path.
Declaration
public static DirectoryEntry GetParent(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | The full path to the current directory entry. |
Returns
Type | Description |
---|---|
DirectoryEntry | The parent directory entry. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.OverflowException |
|
System.Exception |
|
GetPathSeparator()
Get path separator char.
Declaration
public static char GetPathSeparator()
Returns
Type | Description |
---|---|
System.Char | char value. |
GetRealInvalidPathChars()
Get real invalid path chars.
Declaration
public static char[] GetRealInvalidPathChars()
Returns
Type | Description |
---|---|
System.Char[] | char array value. |
GetTotalFreeSpace(String)
Get total free space.
Declaration
public static long GetTotalFreeSpace(string aDriveId)
Parameters
Type | Name | Description |
---|---|---|
System.String | aDriveId | A drive id to get the size of. |
Returns
Type | Description |
---|---|
System.Int64 | long value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aDriveId is null or empty. |
System.Exception | Unable to determine filesystem for path: + aDriveId |
GetTotalSize(String)
Get total size in bytes.
Declaration
public static long GetTotalSize(string aDriveId)
Parameters
Type | Name | Description |
---|---|---|
System.String | aDriveId | A drive id to get the size of. |
Returns
Type | Description |
---|---|
System.Int64 | long value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aDriveId is null or empty. |
System.Exception | Unable to determine filesystem for path: + aDriveId |
GetTrimEndChars()
Get trim end chars.
Declaration
public static char[] GetTrimEndChars()
Returns
Type | Description |
---|---|
System.Char[] | char array value. |
GetVolume(String)
Get volume.
Declaration
public static DirectoryEntry GetVolume(string aVolume)
Parameters
Type | Name | Description |
---|---|---|
System.String | aVolume | The volume root path. |
Returns
Type | Description |
---|---|
DirectoryEntry | A directory entry for the volume. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aVolume is null or empty. |
System.Exception | Unable to determine filesystem for path: + aVolume |
System.ArgumentNullException | Thrown if aVolume / filesystem is null. |
System.ArgumentOutOfRangeException | Thrown when root directory address is smaller then root directory address. |
GetVolumes()
Gets the volumes for all registered file systems.
Declaration
public static List<DirectoryEntry> GetVolumes()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<DirectoryEntry> | A list of directory entries for all volumes. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if filesystem is null. |
System.ArgumentOutOfRangeException | Thrown when root directory address is smaller then root directory address. |
System.ArgumentException | Thrown when root path is null or empty. |
GetVolumeSeparatorChar()
Get volume separator char.
Declaration
public static char GetVolumeSeparatorChar()
Returns
Type | Description |
---|---|
System.Char | char value. |
IsValidDriveId(String)
Check if drive id is valid.
Declaration
public static bool IsValidDriveId(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath |
Returns
Type | Description |
---|---|
System.Boolean | bool value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if aPath length is smaller then 2, or greater than Int32.MaxValue. |
RegisterVFS(VFSBase, Boolean, Boolean)
Register VFS. Initialize the VFS.
Declaration
public static void RegisterVFS(VFSBase aVFS, bool aShowInfo = true, bool aAllowReinitialise = false)
Parameters
Type | Name | Description |
---|---|---|
VFSBase | aVFS | A VFS to register. |
System.Boolean | aShowInfo | |
System.Boolean | aAllowReinitialise |
Exceptions
Type | Condition |
---|---|
System.Exception | Thrown if VFS already registered / memory error. |
System.IO.IOException | Thrown on I/O exception. |
System.ArgumentNullException | Thrown on memory error. |
System.OverflowException | Thrown on memory error. |
System.ArgumentException | Thrown on memory error. |
System.ArgumentOutOfRangeException | Thrown on memory error. |
System.IO.PathTooLongException | Thrown on fatal error. |
System.IO.FileNotFoundException | Thrown on memory error. |
System.IO.DirectoryNotFoundException | Thrown on fatal error. |
SetFileAttributes(String, FileAttributes)
Sets the attributes for a File / Directory. Not implemented.
Declaration
public static void SetFileAttributes(string aPath, FileAttributes fileAttributes)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | The path of the File / Directory. |
System.IO.FileAttributes | fileAttributes | The attributes of the File / Directory. |
Exceptions
Type | Condition |
---|---|
System.NotImplementedException | Thrown always |
SetFileSystemLabel(String, String)
Set file system type.
Declaration
public static void SetFileSystemLabel(string aDriveId, string aLabel)
Parameters
Type | Name | Description |
---|---|---|
System.String | aDriveId | A drive id. |
System.String | aLabel | A label to be set. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when aDriveId is null or empty. |
System.Exception | Unable to determine filesystem for path: + aDriveId |
SplitPath(String)
Split path.
Declaration
public static string[] SplitPath(string aPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | aPath | A path to split. |
Returns
Type | Description |
---|---|
System.String[] | string array. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown on fatal error. |
ThrowIfNotRegistered()
Throws an Exception if VFS is not registered.
Declaration
public static void ThrowIfNotRegistered()