> For the complete documentation index, see [llms.txt](https://luffyyy.gitbook.io/beardlib/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://luffyyy.gitbook.io/beardlib/api/beardlibfilemanager.md).

# File Manager

Updated for version 4.0.

## BeardLibFileManager class

*Used to be called FileManager*

Access it via BeardLib.Managers.File

### Functions

| Function                                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AddFile(String/Idstring ext, String/Idstring path, String file)                          | Adds a file to the game. Works in Linux. (Thanks Znix!) `ext` is the extension inside the game (See type [here](https://luffyyy.gitbook.io/beardlib/modules/addfilesmodule)#does-not-need-load-true)) `path` is the path **inside** the game and `file` is the path to the file including extension. You should use this function if you are planning on adding files through lua as BeardLib also adds its to a list so some functions like `PackageManager:has` will return true.                                                                                                                                                                                 |
| AddFileWithCheck(String/Idstring ext, String/Idstring path, String file)                 | Same as `AddFile` but checks if file exists before adding. Logs a message if it doesn't exist                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| RemoveFile(String/Idstring ext, String/Idstring path)                                    | Removes a file from the game `ext` and `path` same as in `AddFile`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ScriptReplaceFile(String/Idstring ext, String/Idstring path, String file, Table options) | Adds a scriptdata modification to the list. If your mod has a BeardLib config file you may want to use the [module](https://luffyyy.gitbook.io/beardlib/modules/scriptreplacementsmodule) `ext` being the scriptdata extension (sequence\_manager, environment, world, mission, continent, etc), `path` is the path to the scriptdata you want to modify (or add), `file` is the path to the modification/scriptdata. `options` is a table containing some parameters which are: `use_clbk` a callback that is called before doing the process to check if to proceed with the process. You may be interested in using if you want to have an option before merging |
| ScriptReplaceFile(String/Idstring ext, String/Idstring path, Table tbl, Table options)   | Like `ScriptReplaceFile` but instead of a file doing the modification it uses a table with the data. `tbl` being the modification data/scriptdata. Since it doesn't load anything it doesn't need `type` in options.                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Has(String/Idstring ext, String/Idstring path)                                           | A function to check if file `path` with extension `ext` exists in Beardlib. Called in `PackageManager:has`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| HasScriptMod(String/Idstring ext, String/Idstring path)                                  | A function to check if a scriptdata modification/addition exists in BeardLib. Called in `PackageManager:has` and `DB:has`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| LoadAsset(String/Idstring ext, String/Idstring path, String file\_path)                  | Loads a file into the game fully. `ext` is the extension of the file (in the game), `path` is the path in the game, and `file_path` is the full path of the file (normally this is not required but it's useful so you can see if the file loaded through DevLog) Some files need this (Some like units are loaded automatically before spawning, see list [here](https://luffyyy.gitbook.io/beardlib/modules/addfilesmodule)#types-load)). Remember that adding a file to the game isn't the same as loading in diesel. Diesel is weird a little so some files need that extra push to be fully loaded and usable                                                  |
| UnloadAsset(String/Idstring ext, String/Idstring path, String file\_path)                | Unloads file with extension `ext` and path `path`. `file_path` is not required but recommended                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Process(Idstring ids\_ext, Idstring ids\_path, Idstring name\_mt)                        | A core function called automatically after `PackageManager:script_data`. No need to call it                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Update(Number t, Number dt)                                                              | Update function for the class. Called automatically by BeardLib                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |


---

# 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:

```
GET https://luffyyy.gitbook.io/beardlib/api/beardlibfilemanager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
