EVENGINE_API_FOUNDATION public API. 更多...
#include <Filesystem.h>
类 | |
| struct | Info |
| Info public API. 更多... | |
Public 成员函数 | |
| Module_REG (Filesystem) | |
| Filesystem () | |
| virtual | ~Filesystem () |
| bool | readFile (const std::string &path, std::vector< uint8_t > &out) override |
| Reads an entire file. | |
| bool | writeFile (const std::string &path, const void *data, size_t size) override |
| Writes bytes to a file. | |
| bool | fileExists (const std::string &path) override |
| True when the path exists (file or directory). | |
| virtual void | init (const char *arg0)=0 |
| virtual void | setFused (bool fused)=0 |
| virtual bool | isFused () const =0 |
| virtual bool | setupWriteDirectory ()=0 |
| This sets up the save directory. If the it is already set up, nothing happens. | |
| virtual void | setAndroidSaveExternal (bool external=false) |
| This sets the save location on Android. False for internal, true for external | |
| virtual bool | isAndroidSaveExternal () const |
| Gets whether the Android save is external. Returns a bool. | |
| virtual bool | setIdentity (std::string ident, bool appendToPath=false)=0 |
| Sets the name of the save folder. | |
| virtual std::string | getIdentity () const =0 |
| virtual bool | setSource (std::string source)=0 |
| Sets the path to the game source. This can only be set once. | |
| virtual bool | setSourceFromMemory (const void *data, size_t size)=0 |
| Loads the game source from a packaged archive (.eve / zip) held entirely in memory and mounts it at "/" (no extraction to disk). The bytes are copied and kept alive for the lifetime of the mounted archive. This can only be set once. | |
| virtual std::string | getSource () const =0 |
| Gets the path to the game source. Returns a 0-length string if the source has not been set. | |
| virtual bool | mount (std::string archive, std::string mountpoint, bool appendToPath=false)=0 |
| Mounts an archive (path or in-memory Data) at a virtual mountpoint. | |
| virtual bool | mount (Data *data, std::string archivename, std::string mountpoint, bool appendToPath=false)=0 |
| virtual bool | mountRealDirectory (std::string realDir, std::string mountpoint, bool appendToPath=false)=0 |
| virtual bool | unmountRealDirectory (std::string realDir)=0 |
| virtual bool | unmount (std::string archive)=0 |
| Unmounts a previously mounted archive. | |
| virtual bool | unmount (Data *data)=0 |
| Unmounts a previously mounted in-memory archive. | |
| virtual File * | newFile (std::string filename) const =0 |
| Creates a new file. | |
| virtual FileData * | newFileData (const void *data, std::string filename, size_t size) const |
| Creates a new FileData object. Data will be copied. | |
| virtual std::string | getWorkingDirectory ()=0 |
| Gets the current working directory. | |
| virtual std::string | getUserDirectory ()=0 |
| Gets the user home directory. | |
| virtual std::string | getAppdataDirectory ()=0 |
| Gets the APPDATA directory. On Windows, this is the folder in the APPDATA% enviroment variable. On Linux, this is the user home folder. | |
| virtual std::string | getSaveDirectory ()=0 |
| Gets the full path of the save folder. | |
| virtual std::string | getSourceBaseDirectory () const =0 |
| Gets the full path to the directory containing the game source. For example if the game source is C:\Games\mygame.love, this will return C:\Games. | |
| virtual std::string | getRealDirectory (std::string filename) const =0 |
| Gets the real directory path containing the file. | |
| virtual bool | getInfo (std::string filepath, Info &info) const =0 |
| Gets information about the item at the specified filepath. Returns false if nothing exists at the path. | |
| virtual bool | createDirectory (std::string dir)=0 |
| Creates a directory. Write dir must be set. | |
| virtual bool | remove (std::string file)=0 |
| Removes a file (or directory). | |
| virtual FileData * | read (std::string filename, int64_t size=File::ALL) const =0 |
| Reads data from a file. | |
| virtual void | write (std::string filename, const void *data, int64_t size) const =0 |
| Write data to a file. | |
| virtual void | append (std::string filename, const void *data, int64_t size) const =0 |
| Append data to a file, creating it if it doesn't exist. | |
| bool | writeText (const std::string &filename, const std::string &text) const |
| Write a UTF-8 string to a file in the configured save directory. | |
| eve::Result< void > | writeTextAtomic (std::string_view filename, std::string_view text) |
| Durably replace a UTF-8 text file in the configured save directory. | |
| std::string | readText (const std::string &filename) const |
| Read a UTF-8 string from the virtual filesystem. | |
| virtual std::vector< std::string > | getDirectoryItems (std::string dir)=0 |
| This "native" method returns a table of all files in a given directory. | |
| virtual void | setSymlinksEnabled (bool enable)=0 |
| Enable or disable symbolic link support in love.filesystem. | |
| virtual bool | areSymlinksEnabled () const =0 |
| Gets whether symbolic link support is enabled. | |
| virtual std::vector< std::string > & | getRequirePath ()=0 |
| virtual std::vector< std::string > & | getCRequirePath ()=0 |
| virtual void | allowMountingForPath (const std::string &path)=0 |
| Allows a full (OS-dependent) path to be used with Filesystem::mount. | |
| bool | mountExternalReadOnly (const std::string &path, const std::string &mountpoint) |
| Mount an external OS directory for read-only asset access. | |
| virtual bool | isRealDirectory (const std::string &path) const |
| Gets whether the given full (OS-dependent) path is a directory. | |
| virtual std::string | getExecutablePath () const |
| Gets the full platform-dependent path to the executable. | |
| virtual bool | watch (std::string path)=0 |
Watch a virtual or absolute OS path (file or directory). File watches monitor the parent directory and filter by basename. Returns false if the path cannot be resolved to a real directory. Relative paths may include .. and are resolved against the working directory. | |
| virtual eve::Result< void > | watchRealDirectory (std::string realDir, std::string reportPath)=0 |
| Watch a real OS directory and report events under a virtual-relative path. | |
| virtual bool | unwatch (std::string path)=0 |
| Stop watching a path previously passed to watch(). | |
| virtual void | unwatchAll ()=0 |
| virtual int | getWatchCount () const =0 |
| virtual std::string | pollWatch ()=0 |
| Pop next watch event kind: "added"|"removed"|"modified"|"movedFrom"|"movedTo". Empty string if queue empty. Path available via getLastWatchPath(). | |
| virtual std::string | getLastWatchPath () const =0 |
| virtual std::string | getLastWatchRealPath () const =0 |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
Public 成员函数 继承自 eve::service::IFileSystem | |
| virtual | ~IFileSystem ()=default |
| Releases IFileSystem resources. | |
额外继承的成员函数 | |
静态 Public 属性 继承自 eve::service::IFileSystem | |
| static constexpr const char * | capabilityName = "IFileSystem" |
详细描述
EVENGINE_API_FOUNDATION public API.
在文件 Filesystem.h 第 43 行定义.
构造及析构函数说明
◆ Filesystem()
|
inline |
在文件 Filesystem.h 第 55 行定义.
◆ ~Filesystem()
|
inlinevirtual |
被 eve::filesystem::physfs::Filesystem 重载.
在文件 Filesystem.h 第 56 行定义.
成员函数说明
◆ allowMountingForPath()
|
pure virtual |
Allows a full (OS-dependent) path to be used with Filesystem::mount.
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 mountExternalReadOnly().
◆ append()
|
pure virtual |
Append data to a file, creating it if it doesn't exist.
- 参数
-
filename The name of the file to write to. data The data to append. size The size in bytes of the data to append.
◆ areSymlinksEnabled()
|
pure virtual |
Gets whether symbolic link support is enabled.
◆ createDirectory()
|
pure virtual |
Creates a directory. Write dir must be set.
- 参数
-
dir The directory to create.
◆ fileExists()
|
inlineoverridevirtual |
True when the path exists (file or directory).
实现了 eve::service::IFileSystem.
在文件 Filesystem.h 第 80 行定义.
◆ getAppdataDirectory()
|
pure virtual |
Gets the APPDATA directory. On Windows, this is the folder in the APPDATA% enviroment variable. On Linux, this is the user home folder.
◆ getCRequirePath()
|
pure virtual |
◆ getDirectoryItems()
|
pure virtual |
This "native" method returns a table of all files in a given directory.
◆ getExecutablePath()
|
virtual |
◆ getIdentity()
|
pure virtual |
◆ getInfo()
|
pure virtual |
Gets information about the item at the specified filepath. Returns false if nothing exists at the path.
◆ getLastWatchPath()
|
pure virtual |
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 eve::cmd::Cmdline::McpHost().
◆ getLastWatchRealPath()
|
pure virtual |
◆ getRealDirectory()
|
pure virtual |
Gets the real directory path containing the file.
◆ getRequirePath()
|
pure virtual |
◆ getSaveDirectory()
|
pure virtual |
Gets the full path of the save folder.
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 writeTextAtomic().
◆ getSource()
|
pure virtual |
Gets the path to the game source. Returns a 0-length string if the source has not been set.
◆ getSourceBaseDirectory()
|
pure virtual |
Gets the full path to the directory containing the game source. For example if the game source is C:\Games\mygame.love, this will return C:\Games.
◆ getUserDirectory()
|
pure virtual |
Gets the user home directory.
◆ getWatchCount()
|
pure virtual |
◆ getWorkingDirectory()
|
pure virtual |
Gets the current working directory.
◆ init()
|
pure virtual |
◆ isAndroidSaveExternal()
|
inlinevirtual |
Gets whether the Android save is external. Returns a bool.
在文件 Filesystem.h 第 109 行定义.
◆ isFused()
|
pure virtual |
◆ isRealDirectory()
|
virtual |
Gets whether the given full (OS-dependent) path is a directory.
在文件 Filesystem.cpp 第 271 行定义.
引用了 path.
被这些函数引用 eve::filesystem::physfs::Filesystem::mountRealDirectory() , 以及 eve::filesystem::physfs::Filesystem::watchRealDirectory().
◆ Module_REG()
| eve::filesystem::Filesystem::Module_REG | ( | Filesystem | ) |
◆ mount() [1/2]
|
pure virtual |
◆ mount() [2/2]
|
pure virtual |
Mounts an archive (path or in-memory Data) at a virtual mountpoint.
- 返回
- True on success; false when the archive is missing or invalid (no exception is thrown for these — check the return value).
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 mountExternalReadOnly().
◆ mountExternalReadOnly()
| bool eve::filesystem::Filesystem::mountExternalReadOnly | ( | const std::string & | path, |
| const std::string & | mountpoint | ||
| ) |
Mount an external OS directory for read-only asset access.
This convenience method authorizes the path and mounts it without changing the filesystem write directory. Files remain outside packaged game data.
- 参数
-
path Absolute OS directory to mount. mountpoint Virtual directory visible to game code.
- 返回
- True when the mount succeeds.
在文件 Filesystem.cpp 第 256 行定义.
引用了 allowMountingForPath(), mount() , 以及 path.
◆ mountRealDirectory()
|
pure virtual |
Mounts a real (OS-level) directory at a virtual mountpoint, bypassing the safety checks in mount(). Used by hot reload to overlay a writable sync directory in front of a read-only bundled/packaged game source.
- 参数
-
realDir Absolute OS path to an existing directory. mountpoint Virtual path to mount at ("" = "/"). appendToPath False = highest priority (searched first).
◆ newFile()
|
pure virtual |
Creates a new file.
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 eve::model3d::EveFileSystem::open().
◆ newFileData()
|
virtual |
Creates a new FileData object. Data will be copied.
- 参数
-
data Pointer to the data. size The size of the data. filename The full filename used to file type identification.
在文件 Filesystem.cpp 第 263 行定义.
引用了 EV_PARAM_CHECK, eve::filesystem::FileData::getData() , 以及 size.
◆ pollWatch()
|
pure virtual |
Pop next watch event kind: "added"|"removed"|"modified"|"movedFrom"|"movedTo". Empty string if queue empty. Path available via getLastWatchPath().
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 eve::cmd::Cmdline::McpHost().
◆ read()
|
pure virtual |
Reads data from a file.
- 参数
-
filename The name of the file to read from. size The size in bytes of the data to read.
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 eve::model3d::Model3D::bakeModel(), eve::map::loadTilesetManifestFile() , 以及 readText().
◆ readFile()
|
inlineoverridevirtual |
Reads an entire file.
- 返回
- false when missing or unreadable.
实现了 eve::service::IFileSystem.
在文件 Filesystem.h 第 58 行定义.
引用了 eve::filesystem::FileData::getData(), eve::filesystem::FileData::getSize() , 以及 path.
◆ readText()
| std::string eve::filesystem::Filesystem::readText | ( | const std::string & | filename | ) | const |
◆ remove()
|
pure virtual |
Removes a file (or directory).
- 参数
-
file The file or directory to remove.
◆ setAndroidSaveExternal()
|
inlinevirtual |
This sets the save location on Android. False for internal, true for external
- 参数
-
external Bool for whether Android should use external file storage.
在文件 Filesystem.h 第 103 行定义.
◆ setFused()
|
pure virtual |
◆ setIdentity()
|
pure virtual |
Sets the name of the save folder.
- 参数
-
ident The name of the game. Will be used to to create the folder in the LOVE data folder.
◆ setSource()
|
pure virtual |
Sets the path to the game source. This can only be set once.
- 返回
- True on success; false when the source was already set or the path does not exist (no exception is thrown for these).
- 参数
-
source Path to a directory or a .love-file.
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 eve::cmd::Cmdline::McpHost().
◆ setSourceFromMemory()
|
pure virtual |
Loads the game source from a packaged archive (.eve / zip) held entirely in memory and mounts it at "/" (no extraction to disk). The bytes are copied and kept alive for the lifetime of the mounted archive. This can only be set once.
- 参数
-
data Pointer to the archive bytes. size Number of bytes.
◆ setSymlinksEnabled()
|
pure virtual |
Enable or disable symbolic link support in love.filesystem.
◆ setupWriteDirectory()
|
pure virtual |
This sets up the save directory. If the it is already set up, nothing happens.
- 返回
- True on success, false otherwise.
◆ unmount() [1/2]
|
pure virtual |
Unmounts a previously mounted in-memory archive.
- 返回
- True when unmounted.
◆ unmount() [2/2]
|
pure virtual |
Unmounts a previously mounted archive.
- 返回
- True when unmounted.
◆ unmountRealDirectory()
|
pure virtual |
Unmounts a directory previously added via mountRealDirectory().
◆ unwatch()
|
pure virtual |
Stop watching a path previously passed to watch().
◆ unwatchAll()
|
pure virtual |
◆ watch()
|
pure virtual |
Watch a virtual or absolute OS path (file or directory). File watches monitor the parent directory and filter by basename. Returns false if the path cannot be resolved to a real directory. Relative paths may include .. and are resolved against the working directory.
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 eve::map::loadConfigFile() , 以及 eve::map::loadTilesetManifestFile().
◆ watchRealDirectory()
|
pure virtual |
Watch a real OS directory and report events under a virtual-relative path.
- 参数
-
realDir Existing OS directory (absolute or cwd-relative). reportPath Path prefix returned by pollWatch (game/VFS relative, posix).
- 返回
- Applied when the OS directory watcher is registered; InvalidArgument when either path is empty, NotFound when realDir is missing or not a directory, Failed when the watcher could not be added. @cost One OS directory watcher for this directory only (not recursive).
◆ write()
|
pure virtual |
Write data to a file.
- 参数
-
filename The name of the file to write to. data The data to write. size The size in bytes of the data to write.
在 eve::filesystem::physfs::Filesystem 内被实现.
被这些函数引用 eve::model3d::Model3D::bakeModel(), writeText() , 以及 writeTextAtomic().
◆ writeFile()
|
inlineoverridevirtual |
Writes bytes to a file.
- 返回
- false when the write fails.
实现了 eve::service::IFileSystem.
在文件 Filesystem.h 第 71 行定义.
◆ writeText()
| bool eve::filesystem::Filesystem::writeText | ( | const std::string & | filename, |
| const std::string & | text | ||
| ) | const |
Write a UTF-8 string to a file in the configured save directory.
- 参数
-
filename Relative save path. text UTF-8 text to write.
- 返回
- True when the write succeeds.
在文件 Filesystem.cpp 第 73 行定义.
◆ writeTextAtomic()
| eve::Result< void > eve::filesystem::Filesystem::writeTextAtomic | ( | std::string_view | filename, |
| std::string_view | text | ||
| ) |
Durably replace a UTF-8 text file in the configured save directory.
- 参数
-
filename Non-empty relative save path without parent traversal. text UTF-8 bytes to write; the method does not retain this view.
- 返回
- Applied after the temporary file and replacement are flushed, or a structured failure.
- 备注
- The previous target remains intact when writing or flushing the temporary file fails. Native desktop/mobile implementations write a sibling temporary file and atomically replace the target. WebGPU returns Unsupported because that guarantee is unavailable. @thread Call on the filesystem owning thread; concurrent writes to the same target are unsupported. @reentrancy Does not invoke callbacks or script code.
在文件 Filesystem.cpp 第 82 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), file, getSaveDirectory(), eve::InvalidArgument, eve::NotFound, offset, eve::PreconditionViolation, relative, sequence, eve::Status::success(), eve::Result< T >::success(), target, text, eve::Unsupported , 以及 write().
该类的文档由以下文件生成:
- src/modules/filesystem/Filesystem.h
- src/modules/filesystem/Filesystem.cpp
Public 成员函数 继承自