From c850fa73316a2f4905e9d250f7966c82e74e208f Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Tue, 1 Mar 2016 10:40:31 +0000 Subject: [PATCH] Added relative paths for DirAccess::remove() Follows similar behaviour to DirAccess::rename() (cherry picked from commit d7052ddba334de3df1190837c6d8589b48799965) --- drivers/unix/dir_access_unix.cpp | 7 +++++-- drivers/windows/dir_access_windows.cpp | 7 +++++-- platform/flash/dir_access_flash.cpp | 4 ++-- platform/osx/dir_access_osx.mm | 7 +++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 23a63be339a..8b097ad25e2 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -292,8 +292,11 @@ Error DirAccessUnix::rename(String p_path,String p_new_path) { } Error DirAccessUnix::remove(String p_path) { - p_path=fix_path(p_path); - + if (p_path.is_rel_path()) + p_path=get_current_dir().plus_file(p_path); + else + p_path=fix_path(p_path); + struct stat flags; if ((stat(p_path.utf8().get_data(),&flags)!=0)) return FAILED; diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 0a413979fc7..b9476b870b7 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -310,8 +310,11 @@ Error DirAccessWindows::rename(String p_path,String p_new_path) { Error DirAccessWindows::remove(String p_path) { - p_path=fix_path(p_path); - + if (p_path.is_rel_path()) + p_path=get_current_dir().plus_file(p_path); + else + p_path=fix_path(p_path); + printf("erasing %s\n",p_path.utf8().get_data()); //WIN32_FILE_ATTRIBUTE_DATA fileInfo; //DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo); diff --git a/platform/flash/dir_access_flash.cpp b/platform/flash/dir_access_flash.cpp index 443242fd99b..ce9eed2c599 100644 --- a/platform/flash/dir_access_flash.cpp +++ b/platform/flash/dir_access_flash.cpp @@ -183,12 +183,12 @@ size_t DirAccessFlash::get_space_left() { Error DirAccessFlash::rename(String p_from, String p_to) { - return FAILED; + ERR_FAIL_V(ERR_UNAVAILABLE); }; Error DirAccessFlash::remove(String p_name) { - return FAILED; + ERR_FAIL_V(ERR_UNAVAILABLE); }; extern char* psp_drive; diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm index e345bea60a2..29f8fda6630 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/osx/dir_access_osx.mm @@ -297,8 +297,11 @@ Error DirAccessOSX::rename(String p_path,String p_new_path) { } Error DirAccessOSX::remove(String p_path) { - p_path=fix_path(p_path); - + if (p_path.is_rel_path()) + p_path=get_current_dir().plus_file(p_path); + else + p_path=fix_path(p_path); + struct stat flags; if ((stat(p_path.utf8().get_data(),&flags)!=0)) return FAILED;