diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-08-09 13:45:30 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2019-08-12 13:31:59 +0200 |
commit | 37a16fee05f2ee528c8556af9f4337a909e58de5 (patch) | |
tree | fbb29752990919ee836128994a194a2370bfa3e0 /core/os | |
parent | 5441aaf768d6dd4c3d8465e6b340ae38ddc7db1d (diff) |
Export: Remove temp files from cache after export
So far we left most temporary files lying around, so this attempts to
fix that.
I added a helper method to DirAccess to factor out the boilerplate of
creating a DirAccess, checking if the file exists, remove it or print
an error on failure.
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/dir_access.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 704eedae5b..3c0528112b 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -97,6 +97,18 @@ public: virtual Error rename(String p_from, String p_to) = 0; virtual Error remove(String p_name) = 0; + // Meant for editor code when we want to quickly remove a file without custom + // handling (e.g. removing a cache file). + static void remove_file_or_error(String p_path) { + DirAccess *da = create(ACCESS_FILESYSTEM); + if (da->file_exists(p_path)) { + if (da->remove(p_path) != OK) { + ERR_FAIL_MSG("Cannot remove file or directory: " + p_path); + } + } + memdelete(da); + } + virtual String get_filesystem_type() const = 0; static String get_full_path(const String &p_path, AccessType p_access); static DirAccess *create_for_path(const String &p_path); |