diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-08-12 14:55:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-12 14:55:15 +0200 |
commit | d7f3de8581c88d88595615db01f177161a032b26 (patch) | |
tree | fbb29752990919ee836128994a194a2370bfa3e0 /core | |
parent | 5441aaf768d6dd4c3d8465e6b340ae38ddc7db1d (diff) | |
parent | 37a16fee05f2ee528c8556af9f4337a909e58de5 (diff) |
Merge pull request #31235 from akien-mga/clean-cache-after-export
Export: Remove temp files from cache after export
Diffstat (limited to 'core')
-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); |