载入中...
搜索中...
未找到
eve::filesystem::Filesystem类 参考abstract

EVENGINE_API_FOUNDATION public API. 更多...

#include <Filesystem.h>

类 eve::filesystem::Filesystem 继承关系图:
eve::Module eve::service::IFileSystem eve::filesystem::physfs::Filesystem

类

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()

eve::filesystem::Filesystem::Filesystem ( )
inline

在文件 Filesystem.h 第 55 行定义.

◆ ~Filesystem()

virtual eve::filesystem::Filesystem::~Filesystem ( )
inlinevirtual

被 eve::filesystem::physfs::Filesystem 重载.

在文件 Filesystem.h 第 56 行定义.

成员函数说明

◆ allowMountingForPath()

virtual void eve::filesystem::Filesystem::allowMountingForPath ( const std::string &  path)
pure virtual

Allows a full (OS-dependent) path to be used with Filesystem::mount.

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 mountExternalReadOnly().

◆ append()

virtual void eve::filesystem::Filesystem::append ( std::string  filename,
const void *  data,
int64_t  size 
) const
pure virtual

Append data to a file, creating it if it doesn't exist.

参数
filenameThe name of the file to write to.
dataThe data to append.
sizeThe size in bytes of the data to append.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ areSymlinksEnabled()

virtual bool eve::filesystem::Filesystem::areSymlinksEnabled ( ) const
pure virtual

Gets whether symbolic link support is enabled.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ createDirectory()

virtual bool eve::filesystem::Filesystem::createDirectory ( std::string  dir)
pure virtual

Creates a directory. Write dir must be set.

参数
dirThe directory to create.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ fileExists()

bool eve::filesystem::Filesystem::fileExists ( const std::string &  path)
inlineoverridevirtual

True when the path exists (file or directory).

实现了 eve::service::IFileSystem.

在文件 Filesystem.h 第 80 行定义.

引用了 info , 以及 path.

◆ getAppdataDirectory()

virtual std::string eve::filesystem::Filesystem::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.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ getCRequirePath()

virtual std::vector< std::string > & eve::filesystem::Filesystem::getCRequirePath ( )
pure virtual

◆ getDirectoryItems()

virtual std::vector< std::string > eve::filesystem::Filesystem::getDirectoryItems ( std::string  dir)
pure virtual

This "native" method returns a table of all files in a given directory.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ getExecutablePath()

std::string eve::filesystem::Filesystem::getExecutablePath ( ) const
virtual

Gets the full platform-dependent path to the executable.

在文件 Filesystem.cpp 第 287 行定义.

引用了 buffer.

◆ getIdentity()

virtual std::string eve::filesystem::Filesystem::getIdentity ( ) const
pure virtual

◆ getInfo()

virtual bool eve::filesystem::Filesystem::getInfo ( std::string  filepath,
Info &  info 
) const
pure virtual

Gets information about the item at the specified filepath. Returns false if nothing exists at the path.

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 eve::model3d::EveFileSystem::exists().

◆ getLastWatchPath()

virtual std::string eve::filesystem::Filesystem::getLastWatchPath ( ) const
pure virtual

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 eve::cmd::Cmdline::McpHost().

◆ getLastWatchRealPath()

virtual std::string eve::filesystem::Filesystem::getLastWatchRealPath ( ) const
pure virtual

◆ getRealDirectory()

virtual std::string eve::filesystem::Filesystem::getRealDirectory ( std::string  filename) const
pure virtual

Gets the real directory path containing the file.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ getRequirePath()

virtual std::vector< std::string > & eve::filesystem::Filesystem::getRequirePath ( )
pure virtual

◆ getSaveDirectory()

virtual std::string eve::filesystem::Filesystem::getSaveDirectory ( )
pure virtual

Gets the full path of the save folder.

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 writeTextAtomic().

◆ getSource()

virtual std::string eve::filesystem::Filesystem::getSource ( ) const
pure virtual

Gets the path to the game source. Returns a 0-length string if the source has not been set.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ getSourceBaseDirectory()

virtual std::string eve::filesystem::Filesystem::getSourceBaseDirectory ( ) const
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.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ getUserDirectory()

virtual std::string eve::filesystem::Filesystem::getUserDirectory ( )
pure virtual

Gets the user home directory.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ getWatchCount()

virtual int eve::filesystem::Filesystem::getWatchCount ( ) const
pure virtual

◆ getWorkingDirectory()

virtual std::string eve::filesystem::Filesystem::getWorkingDirectory ( )
pure virtual

Gets the current working directory.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ init()

virtual void eve::filesystem::Filesystem::init ( const char *  arg0)
pure virtual

◆ isAndroidSaveExternal()

virtual bool eve::filesystem::Filesystem::isAndroidSaveExternal ( ) const
inlinevirtual

Gets whether the Android save is external. Returns a bool.

在文件 Filesystem.h 第 109 行定义.

被这些函数引用 eve::filesystem::physfs::Filesystem::setIdentity().

◆ isFused()

virtual bool eve::filesystem::Filesystem::isFused ( ) const
pure virtual

◆ isRealDirectory()

bool eve::filesystem::Filesystem::isRealDirectory ( const std::string &  path) const
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]

virtual bool eve::filesystem::Filesystem::mount ( Data *  data,
std::string  archivename,
std::string  mountpoint,
bool  appendToPath = false 
)
pure virtual

◆ mount() [2/2]

virtual bool eve::filesystem::Filesystem::mount ( std::string  archive,
std::string  mountpoint,
bool  appendToPath = false 
)
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.

参数
pathAbsolute OS directory to mount.
mountpointVirtual directory visible to game code.
返回
True when the mount succeeds.

在文件 Filesystem.cpp 第 256 行定义.

引用了 allowMountingForPath(), mount() , 以及 path.

◆ mountRealDirectory()

virtual bool eve::filesystem::Filesystem::mountRealDirectory ( std::string  realDir,
std::string  mountpoint,
bool  appendToPath = false 
)
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.

参数
realDirAbsolute OS path to an existing directory.
mountpointVirtual path to mount at ("" = "/").
appendToPathFalse = highest priority (searched first).

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ newFile()

virtual File * eve::filesystem::Filesystem::newFile ( std::string  filename) const
pure virtual

Creates a new file.

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 eve::model3d::EveFileSystem::open().

◆ newFileData()

FileData * eve::filesystem::Filesystem::newFileData ( const void *  data,
std::string  filename,
size_t  size 
) const
virtual

Creates a new FileData object. Data will be copied.

参数
dataPointer to the data.
sizeThe size of the data.
filenameThe full filename used to file type identification.

在文件 Filesystem.cpp 第 263 行定义.

引用了 EV_PARAM_CHECK, eve::filesystem::FileData::getData() , 以及 size.

◆ pollWatch()

virtual std::string eve::filesystem::Filesystem::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()

virtual FileData * eve::filesystem::Filesystem::read ( std::string  filename,
int64_t  size = File::ALL 
) const
pure virtual

Reads data from a file.

参数
filenameThe name of the file to read from.
sizeThe size in bytes of the data to read.

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 eve::model3d::Model3D::bakeModel(), eve::map::loadTilesetManifestFile() , 以及 readText().

◆ readFile()

bool eve::filesystem::Filesystem::readFile ( const std::string &  path,
std::vector< uint8_t > &  out 
)
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

Read a UTF-8 string from the virtual filesystem.

参数
filenameRelative virtual path.
返回
File contents, or an empty string when the file cannot be read.

在文件 Filesystem.cpp 第 181 行定义.

引用了 bytes, read() , 以及 text.

◆ remove()

virtual bool eve::filesystem::Filesystem::remove ( std::string  file)
pure virtual

Removes a file (or directory).

参数
fileThe file or directory to remove.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ setAndroidSaveExternal()

virtual void eve::filesystem::Filesystem::setAndroidSaveExternal ( bool  external = false)
inlinevirtual

This sets the save location on Android. False for internal, true for external

参数
externalBool for whether Android should use external file storage.

在文件 Filesystem.h 第 103 行定义.

◆ setFused()

virtual void eve::filesystem::Filesystem::setFused ( bool  fused)
pure virtual

◆ setIdentity()

virtual bool eve::filesystem::Filesystem::setIdentity ( std::string  ident,
bool  appendToPath = false 
)
pure virtual

Sets the name of the save folder.

参数
identThe name of the game. Will be used to to create the folder in the LOVE data folder.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ setSource()

virtual bool eve::filesystem::Filesystem::setSource ( std::string  source)
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).
参数
sourcePath to a directory or a .love-file.

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 eve::cmd::Cmdline::McpHost().

◆ setSourceFromMemory()

virtual bool eve::filesystem::Filesystem::setSourceFromMemory ( const void *  data,
size_t  size 
)
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.

参数
dataPointer to the archive bytes.
sizeNumber of bytes.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ setSymlinksEnabled()

virtual void eve::filesystem::Filesystem::setSymlinksEnabled ( bool  enable)
pure virtual

Enable or disable symbolic link support in love.filesystem.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ setupWriteDirectory()

virtual bool eve::filesystem::Filesystem::setupWriteDirectory ( )
pure virtual

This sets up the save directory. If the it is already set up, nothing happens.

返回
True on success, false otherwise.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ unmount() [1/2]

virtual bool eve::filesystem::Filesystem::unmount ( Data *  data)
pure virtual

Unmounts a previously mounted in-memory archive.

返回
True when unmounted.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ unmount() [2/2]

virtual bool eve::filesystem::Filesystem::unmount ( std::string  archive)
pure virtual

Unmounts a previously mounted archive.

返回
True when unmounted.

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ unmountRealDirectory()

virtual bool eve::filesystem::Filesystem::unmountRealDirectory ( std::string  realDir)
pure virtual

Unmounts a directory previously added via mountRealDirectory().

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ unwatch()

virtual bool eve::filesystem::Filesystem::unwatch ( std::string  path)
pure virtual

Stop watching a path previously passed to watch().

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ unwatchAll()

virtual void eve::filesystem::Filesystem::unwatchAll ( )
pure virtual

◆ watch()

virtual bool eve::filesystem::Filesystem::watch ( std::string  path)
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()

virtual eve::Result< void > eve::filesystem::Filesystem::watchRealDirectory ( std::string  realDir,
std::string  reportPath 
)
pure virtual

Watch a real OS directory and report events under a virtual-relative path.

参数
realDirExisting OS directory (absolute or cwd-relative).
reportPathPath 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).

在 eve::filesystem::physfs::Filesystem 内被实现.

◆ write()

virtual void eve::filesystem::Filesystem::write ( std::string  filename,
const void *  data,
int64_t  size 
) const
pure virtual

Write data to a file.

参数
filenameThe name of the file to write to.
dataThe data to write.
sizeThe size in bytes of the data to write.

在 eve::filesystem::physfs::Filesystem 内被实现.

被这些函数引用 eve::model3d::Model3D::bakeModel(), writeText() , 以及 writeTextAtomic().

◆ writeFile()

bool eve::filesystem::Filesystem::writeFile ( const std::string &  path,
const void *  data,
size_t  size 
)
inlineoverridevirtual

Writes bytes to a file.

返回
false when the write fails.

实现了 eve::service::IFileSystem.

在文件 Filesystem.h 第 71 行定义.

引用了 path , 以及 size.

◆ 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.

参数
filenameRelative save path.
textUTF-8 text to write.
返回
True when the write succeeds.

在文件 Filesystem.cpp 第 73 行定义.

引用了 text , 以及 write().

◆ 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.

参数
filenameNon-empty relative save path without parent traversal.
textUTF-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().


该类的文档由以下文件生成: