> For the complete documentation index, see [llms.txt](https://golua.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://golua.fatality.win/documentation/namespaces/filesystem.md).

# Filesystem

filesystem namespace

## Functions

### read

```lua
fs.read("some_file.txt")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                      path to file                      |

#### Returns:

|                                                  |                                                     |
| :----------------------------------------------: | :-------------------------------------------------: |
| [Value](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) |
|                       data                       |                        string                       |

### read\_stream

```lua
fs.read_stream("some_file.txt")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                      path to file                      |

#### Returns:

|                                                  |                                                     |
| :----------------------------------------------: | :-------------------------------------------------: |
| [Value](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) |
|                       data                       |                    table of char                    |

### write

```lua
fs.write("some_file.txt", "data")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                      path to file                      |
|                         data                         |                        string                       |                  data to write to file                 |

### write\_stream

```lua
fs.write_stream("some_file.txt", {"a", "b", "c"})
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                      path to file                      |
|                         data                         |                    table of char                    |             data in bytes to write to file             |

### remove

```lua
fs.remove("some_file.txt")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                      path to file                      |

### exists

```lua
fs.exists("some_file.txt")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                path to file or directory               |

#### Returns:

|                                                  |                                                     |
| :----------------------------------------------: | :-------------------------------------------------: |
| [Value](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) |
|                true if file exists               |                       boolean                       |

### is\_file

```lua
fs.is_file("some_file.txt")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                      path to file                      |

#### Returns:

|                                                  |                                                     |
| :----------------------------------------------: | :-------------------------------------------------: |
| [Value](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) |
|           true if path leads to a file           |                       boolean                       |

### is\_dir

```lua
fs.is_dir("some_file.txt")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                    path to directory                   |

#### Returns:

|                                                  |                                                     |
| :----------------------------------------------: | :-------------------------------------------------: |
| [Value](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) |
|         true if path leads to a directory        |                       boolean                       |

### create\_dir

```lua
fs.create_dir("folder/some_directory")
```

|                                                      |                                                     |                                                        |
| :--------------------------------------------------: | :-------------------------------------------------: | :----------------------------------------------------: |
| [Parameter](/documentation/namespaces/filesystem.md) | [Datatype](/documentation/namespaces/filesystem.md) | [Description](/documentation/namespaces/filesystem.md) |
|                         path                         |                        string                       |                    path to directory                   |
