2023-01-12 20:49:14 +01:00
|
|
|
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
File system
|
|
|
|
===========
|
|
|
|
|
|
|
|
Introduction
|
|
|
|
------------
|
|
|
|
|
|
|
|
A file system manages how assets are stored and how they are accessed.
|
|
|
|
A well-designed file system also allows multiple developers to edit the
|
2024-03-16 20:56:52 +01:00
|
|
|
same source files and assets while collaborating. Pandemonium stores
|
2022-03-18 17:46:08 +01:00
|
|
|
all assets as files in its file system.
|
|
|
|
|
|
|
|
Implementation
|
|
|
|
--------------
|
|
|
|
|
|
|
|
The file system stores resources on disk. Anything, from a script, to a scene or a
|
|
|
|
PNG image is a resource to the engine. If a resource contains properties
|
|
|
|
that reference other resources on disk, the paths to those resources are also
|
|
|
|
included. If a resource has sub-resources that are built-in, the resource is
|
|
|
|
saved in a single file together with all the bundled sub-resources. For
|
|
|
|
example, a font resource is often bundled together with the font textures.
|
|
|
|
|
2024-03-16 20:56:52 +01:00
|
|
|
The Pandemonium file system avoids using metadata files. Existing asset managers and VCSs
|
|
|
|
are better than anything we can implement, so Pandemonium tries its best to play along
|
2022-03-18 17:46:08 +01:00
|
|
|
with SVN, Git, Mercurial, Perforce, etc.
|
|
|
|
|
|
|
|
Example of file system contents:
|
|
|
|
|
|
|
|
|
2023-01-12 22:32:46 +01:00
|
|
|
```
|
2024-03-16 20:56:52 +01:00
|
|
|
/project.pandemonium
|
2022-03-18 17:46:08 +01:00
|
|
|
/enemy/enemy.tscn
|
|
|
|
/enemy/enemy.gd
|
2023-01-12 20:16:00 +01:00
|
|
|
/enemy/enemysprite.png)
|
2022-03-18 17:46:08 +01:00
|
|
|
/player/player.gd
|
2023-01-12 22:32:46 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2024-03-16 20:56:52 +01:00
|
|
|
project.pandemonium
|
2022-03-18 17:46:08 +01:00
|
|
|
-------------
|
|
|
|
|
2024-03-16 20:56:52 +01:00
|
|
|
The `project.pandemonium` file is the project description file, and it is always found
|
2022-03-18 17:46:08 +01:00
|
|
|
at the root of the project. In fact, its location defines where the root is. This
|
2024-03-16 20:56:52 +01:00
|
|
|
is the first file that Pandemonium looks for when opening a project.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
This file contains the project configuration in plain text, using the win.ini
|
2024-03-16 20:56:52 +01:00
|
|
|
format. Even an empty `project.pandemonium` can function as a basic definition of
|
2022-03-18 17:46:08 +01:00
|
|
|
a blank project.
|
|
|
|
|
|
|
|
Path delimiter
|
|
|
|
--------------
|
|
|
|
|
2024-03-16 20:56:52 +01:00
|
|
|
Pandemonium only supports `/` as a path delimiter. This is done for
|
2022-03-18 17:46:08 +01:00
|
|
|
portability reasons. All operating systems support this, even Windows,
|
2024-03-16 20:56:52 +01:00
|
|
|
so a path such as `C:\project\project.pandemonium` needs to be typed as
|
|
|
|
`C:/project/project.pandemonium`.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
Resource path
|
|
|
|
-------------
|
|
|
|
|
|
|
|
When accessing resources, using the host OS file system layout can be
|
|
|
|
cumbersome and non-portable. To solve this problem, the special path
|
2023-01-12 19:43:03 +01:00
|
|
|
`res://` was created.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 19:43:03 +01:00
|
|
|
The path `res://` will always point at the project root (where
|
2024-03-16 20:56:52 +01:00
|
|
|
`project.pandemonium` is located, so `res://project.pandemonium` is always
|
2022-03-18 17:46:08 +01:00
|
|
|
valid).
|
|
|
|
|
|
|
|
This file system is read-write only when running the project locally from
|
|
|
|
the editor. When exported or when running on different devices (such as
|
|
|
|
phones or consoles, or running from DVD), the file system will become
|
|
|
|
read-only and writing will no longer be permitted.
|
|
|
|
|
|
|
|
User path
|
|
|
|
---------
|
|
|
|
|
|
|
|
Writing to disk is still needed for tasks such as saving game state or
|
|
|
|
downloading content packs. To this end, the engine ensures that there is a
|
2023-01-12 19:43:03 +01:00
|
|
|
special path `user://` that is always writable. This path resolves
|
2022-03-18 17:46:08 +01:00
|
|
|
differently depending on the OS the project is running on. Local path
|
2023-01-12 19:29:11 +01:00
|
|
|
resolution is further explained in `doc_data_paths`.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
Host file system
|
|
|
|
----------------
|
|
|
|
|
|
|
|
Alternatively host file system paths can also be used, but this is not recommended
|
|
|
|
for a released product as these paths are not guaranteed to work on all platforms.
|
|
|
|
However, using host file system paths can be useful when writing development
|
2024-03-16 20:56:52 +01:00
|
|
|
tools in Pandemonium.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
Drawbacks
|
|
|
|
---------
|
|
|
|
|
|
|
|
There are some drawbacks to this simple file system design. The first issue is that
|
|
|
|
moving assets around (renaming them or moving them from one path to another inside
|
|
|
|
the project) will break existing references to these assets. These references will
|
|
|
|
have to be re-defined to point at the new asset location.
|
|
|
|
|
2024-03-16 20:56:52 +01:00
|
|
|
To avoid this, do all your move, delete and rename operations from within Pandemonium, on
|
|
|
|
the FileSystem dock. Never move assets from outside Pandemonium, or dependencies will have
|
|
|
|
to be fixed manually (Pandemonium detects this and helps you fix them anyway, but why
|
2022-03-18 17:46:08 +01:00
|
|
|
go the hard route?).
|
|
|
|
|
|
|
|
The second is that, under Windows and macOS, file and path names are case insensitive.
|
2023-01-12 20:16:00 +01:00
|
|
|
If a developer working in a case insensitive host file system saves an asset as `myfile.png)`,
|
|
|
|
but then references it as `myfile.png)`, it will work fine on their platform, but not
|
2022-03-18 17:46:08 +01:00
|
|
|
on other platforms, such as Linux, Android, etc. This may also apply to exported binaries,
|
|
|
|
which use a compressed package to store all files.
|
|
|
|
|
|
|
|
It is recommended that your team clearly define a naming convention for files when
|
2024-03-16 20:56:52 +01:00
|
|
|
working with Pandemonium. One simple fool-proof convention is to only allow lowercase
|
2022-03-18 17:46:08 +01:00
|
|
|
file and path names.
|