载入中...
搜索中...
未找到
Filesystem.cpp
浏览该文件的文档.
57 if (path.empty() || path.is_absolute() || path.has_root_name() || path.has_root_directory()) return false;
87 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "atomic save replacement is unavailable on the WebGPU filesystem", {}, {}, "filesystem.atomic-write"));
93 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "atomic save path must be relative and cannot traverse parents", relativeText, {}, "filesystem.atomic-write"));
97 eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation, "filesystem write directory is not configured", relativeText, {}, "filesystem.atomic-write"));
102 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "atomic save parent directory does not exist", relativeText, {}, "filesystem.atomic-write"));
107 const std::wstring temporaryPath = targetPath + L".tmp." + std::to_wstring(GetCurrentProcessId()) +
113 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "could not create atomic save temporary file", relativeText, {}, "filesystem.atomic-write"));
117 const DWORD chunk = static_cast<DWORD>(std::min<std::size_t>(text.size() - offset, 0x7fffffffu));
130 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "could not write or flush atomic save temporary file", relativeText, {}, "filesystem.atomic-write"));
136 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "could not atomically replace save file", relativeText, {}, "filesystem.atomic-write"));
145 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "could not create atomic save temporary file", relativeText, {}, "filesystem.atomic-write"));
162 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "could not write or flush atomic save temporary file", relativeText, {}, "filesystem.atomic-write"));
167 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "could not atomically replace save file", relativeText, {}, "filesystem.atomic-write"));
EVEngine assertion entry point, backed by zeroerr.
#define EV_PARAM_CHECK(cond,...)
Validate a function parameter / public API precondition.
Definition Assert.h:30
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
Data buffer paired with a filename (used for type identification).
Definition FileData.h:14
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:\...
virtual void allowMountingForPath(const std::string &path)=0
Allows a full (OS-dependent) path to be used with Filesystem::mount.
virtual bool isAndroidSaveExternal() const
Gets whether the Android save is external. Returns a bool.
Definition Filesystem.h:109
virtual std::string getUserDirectory()=0
Gets the user home directory.
bool writeText(const std::string &filename, const std::string &text) const
Write a UTF-8 string to a file in the configured save directory.
Definition Filesystem.cpp:73
virtual bool setSource(std::string source)=0
Sets the path to the game source. This can only be set once.
virtual std::string getExecutablePath() const
Gets the full platform-dependent path to the executable.
Definition Filesystem.cpp:287
virtual bool setIdentity(std::string ident, bool appendToPath=false)=0
Sets the name of the save folder.
virtual std::vector< std::string > & getRequirePath()=0
virtual std::string getLastWatchRealPath() const =0
std::string readText(const std::string &filename) const
Read a UTF-8 string from the virtual filesystem.
Definition Filesystem.cpp:181
virtual FileData * newFileData(const void *data, std::string filename, size_t size) const
Creates a new FileData object. Data will be copied.
Definition Filesystem.cpp:263
virtual int getWatchCount() const =0
virtual File * newFile(std::string filename) const =0
Creates a new file.
virtual std::string getWorkingDirectory()=0
Gets the current working directory.
virtual void setFused(bool fused)=0
virtual std::vector< std::string > getDirectoryItems(std::string dir)=0
This "native" method returns a table of all files in a given directory.
virtual std::string pollWatch()=0
Pop next watch event kind: "added"|"removed"|"modified"|"movedFrom"|"movedTo". Empty string if queue ...
virtual void unwatchAll()=0
virtual bool unwatch(std::string path)=0
Stop watching a path previously passed to watch().
virtual std::string getRealDirectory(std::string filename) const =0
Gets the real directory path containing the file.
virtual bool isFused() const =0
virtual std::string getAppdataDirectory()=0
Gets the APPDATA directory. On Windows, this is the folder in the APPDATA% enviroment variable....
virtual std::string getSaveDirectory()=0
Gets the full path of the save folder.
virtual bool isRealDirectory(const std::string &path) const
Gets whether the given full (OS-dependent) path is a directory.
Definition Filesystem.cpp:271
virtual std::string getLastWatchPath() const =0
virtual bool remove(std::string file)=0
Removes a file (or directory).
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.
bool mountExternalReadOnly(const std::string &path, const std::string &mountpoint)
Mount an external OS directory for read-only asset access.
Definition Filesystem.cpp:256
virtual bool createDirectory(std::string dir)=0
Creates a directory. Write dir must be set.
virtual std::string getIdentity() const =0
virtual bool areSymlinksEnabled() const =0
Gets whether symbolic link support is enabled.
virtual void write(std::string filename, const void *data, int64_t size) const =0
Write data to a file.
virtual bool setupWriteDirectory()=0
This sets up the save directory. If the it is already set up, nothing happens.
virtual FileData * read(std::string filename, int64_t size=File::ALL) const =0
Reads data from 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.
virtual void setSymlinksEnabled(bool enable)=0
Enable or disable symbolic link support in love.filesystem.
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 void setAndroidSaveExternal(bool external=false)
This sets the save location on Android. False for internal, true for external
Definition Filesystem.h:103
virtual std::vector< std::string > & getCRequirePath()=0
eve::Result< void > writeTextAtomic(std::string_view filename, std::string_view text)
Durably replace a UTF-8 text file in the configured save directory.
Definition Filesystem.cpp:82
virtual bool watch(std::string path)=0
Watch a virtual or absolute OS path (file or directory). File watches monitor the parent directory an...
void exposePreparedFileBindings(ssq::Class &cls)
Install game-thread script submission bindings; retains no class borrow.
Definition PreparedFile.cpp:75
@ InvalidArgument
@ NotFound
@ PreconditionViolation
@ Unsupported
@ Failed
@ Applied