diff options
author | Marcelo Fernandez <marcelofg55@gmail.com> | 2017-09-25 10:15:11 -0300 |
---|---|---|
committer | Marcelo Fernandez <marcelofg55@gmail.com> | 2017-09-25 21:49:01 -0300 |
commit | 20918587d39c5c9c370e3b4beccf883f553d9b3e (patch) | |
tree | b0035e8e35dbe0d4cbf97dc6a05e946bcbd5dc64 /platform/windows | |
parent | 09800ac65079599c568679b53962a313182885ea (diff) | |
download | redot-engine-20918587d39c5c9c370e3b4beccf883f553d9b3e.tar.gz |
FileSystemDock will now remove files/dirs to trashcan using OS::move_to_trash
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/os_windows.cpp | 27 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index db7cd0b938..d715c51a71 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2373,6 +2373,33 @@ bool OS_Windows::is_disable_crash_handler() const { return crash_handler.is_disabled(); } +Error OS_Windows::move_to_trash(const String &p_path) { + SHFILEOPSTRUCTA sf; + TCHAR *from = new TCHAR[p_path.length() + 2]; + strcpy(from, p_path.utf8().get_data()); + from[p_path.length()] = 0; + from[p_path.length() + 1] = 0; + + sf.hwnd = hWnd; + sf.wFunc = FO_DELETE; + sf.pFrom = from; + sf.pTo = NULL; + sf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; + sf.fAnyOperationsAborted = FALSE; + sf.hNameMappings = NULL; + sf.lpszProgressTitle = NULL; + + int ret = SHFileOperation(&sf); + delete[] from; + + if (ret) { + ERR_PRINTS("SHFileOperation error: " + itos(ret)); + return FAILED; + } + + return OK; +} + OS_Windows::OS_Windows(HINSTANCE _hInstance) { key_event_pos = 0; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 8a955aa224..bc1dc318cb 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -290,6 +290,8 @@ public: void disable_crash_handler(); bool is_disable_crash_handler() const; + virtual Error move_to_trash(const String &p_path); + OS_Windows(HINSTANCE _hInstance); ~OS_Windows(); }; |