Woking on Start Here page for filesystem

This commit is contained in:
Elia Sulimanov 2020-07-02 01:06:17 +03:00
parent abe6924864
commit c19e34b19e
6 changed files with 57 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View file

@ -0,0 +1,57 @@
In this articel we will discuss about using Cosmos VFS (virtual file system).
Cosmos VFS and the VFS manager classes, let you manage your file system.
First, we should create and initialize an instance of the VFS;
```
var fs = new Sys.FileSystem.CosmosVFS();
fs.Initialize();
```
What is done here is that the partitions and file systems list is being initialized, and the file system is being registered.
Right after this lines is done, an message looking like this will apper on your screen:
///////////////////////////////// INITIALIZE.
This message is printed by the initialize method and it provide info about the file system.
After our VFS has been initialized, we can use more interesting functions, lets go over some of them:
1. Get available free space.
```
long available_space = fs.GetAvailableFreeSpace("0:/");
Console.WriteLine("Available Free Space: " + available_space);
```
We use this function to get the size of the available free space in our file system, in bytes.
You have probably noticed the "0:/" argument passed to this function, this is the id of the drive we want to get available free space of.
Cosmos using DOS drive naming system and this is why we use "0".
///////////////////////////////// FREE SPACE.
2. Get file system type.
```
string fs_type = fs.GetFileSystemType("0:/");
Console.WriteLine("File System Type: " + fs_type);
```
This will let us know what the file system type.
///////////////////////////////// TYPE.
3. Get files list.
We start by getting the directory entrys list, using:
```
var directory_list = fs.GetDirectoryListing("0:/");
```
Once we have it, we can get the names of our files:
```
foreach (var directoryEntry in directory_list)
{
Console.WriteLine(directoryEntry.mName);
}
```
///////////////////////////////// FILES LIST.
4. Read files.
This one is more tricky,
We need to get a directoryEntryList, find files in the list and print the content to the screen.
///////////////////////////////// READ.