> For the complete documentation index, see [llms.txt](https://mandor-labs.gitbook.io/mandor-labs-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mandor-labs.gitbook.io/mandor-labs-docs/save-load/getting-started/file-system.md).

# File System

If you are targeting consoles like PlayStation or Nintendo Switch, you must implement a custom file system to handle reading and writing save files.&#x20;

{% stepper %}
{% step %}

### Create Custom File & Directory Handler

This is basic example how to create custom FS

<details>

<summary>Create Custom File Handler</summary>

```csharp
public class CustomFileHandler : FSFile
{
		/// <summary>
    /// Write all text into a file
    /// </summary>
		public override void WriteAllText(string path,string content,object options = null)
		{
				//write your code here
		}
		
		/// <summary>
    /// Write all bytes into a file
    /// </summary>
		public override void WriteAllBytes(string path,byte[] content,object options = null)
		{
        //write your code here
    }
    
    /// <summary>
    /// Read all text from a file
    /// </summary>
    public override string ReadAllText(string path){
        //write your code here
    }
    
    /// <summary>
    /// Read all bytes from a file
    /// </summary>
    public override byte[] ReadAllBytes(string path){
       //write code here
    }
    
    /// <summary>
    /// Check file exists
    /// </summary>
    public override bool Exist(string path){
        //write code here
    }
		
		/// <summary>
    /// Delete a file
    /// </summary>
    public override void Delete(string path){
        //write code here
    }
		
		/// <summary>
    /// Move a file to new path
    /// </summary>
    public override void Move(string src,string dst){
        //write code here
    }
		
		/// <summary>
    /// Get last modified file
    /// </summary>
    public DateTime GetLastModified(string path){
        //write code here
    } 
}

```

</details>

<details>

<summary>Create Custom Directory Handler</summary>

```csharp
public class CustomDirectoryHandler : FSDirectory
{
    /// <summary>
    /// Create directory
    /// </summary>
    public override void Create(string rPath){
       //write your code here
    }

    /// <summary>
    /// Check directory exists or not
    /// </summary>
    public override bool Exists(string rPath){
        //write your code here
    }

    /// <summary>
    /// Delete directory
    /// </summary>
    public override void Delete(string rPath){
        //write your code here
    }

    /// <summary>
    /// Get file from directory
    /// </summary>
    public override string GetFile(string rPath){
        //write your code here
    }

    /// <summary>
    /// Get files from the directory
    /// </summary>
    public override string[] GetFiles(string rPath,string extension,SearchOption option){
        //write your code here
    }

    /// <summary>
    /// Get full path from relative path
    /// </summary>
    protected override string GetPath(string rPath){
		    //Adjust this code according to your platform
    }
}

```

</details>
{% endstep %}

{% step %}

### Use Custom File & Directory Handler

This example will show you how to use your custom FS

```csharp
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void InitializeOnLoad()
{
    //Use custom directory handler
    new CustomDirectoryHandler().Use();
    
    //use custom file handler
    new CustomFileHandler().Use();
}
```

{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mandor-labs.gitbook.io/mandor-labs-docs/save-load/getting-started/file-system.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
