diff options
Diffstat (limited to 'core/os/dir_access.h')
-rw-r--r-- | core/os/dir_access.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/core/os/dir_access.h b/core/os/dir_access.h index bde19bd5ae..d3eb1e13f6 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -34,10 +34,6 @@ #include "core/typedefs.h" #include "core/ustring.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - //@ TODO, excellent candidate for THREAD_SAFE MACRO, should go through all these and add THREAD_SAFE where it applies class DirAccess { public: @@ -71,7 +67,6 @@ protected: public: virtual Error list_dir_begin() = 0; ///< This starts dir listing - virtual String get_next(bool *p_is_dir); // compatibility virtual String get_next() = 0; virtual bool current_is_dir() const = 0; virtual bool current_is_hidden() const = 0; @@ -98,6 +93,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); |