summaryrefslogtreecommitdiffstats
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
authorPoommetee Ketson <poommetee@protonmail.com>2017-10-02 23:52:09 +0700
committerGitHub <noreply@github.com>2017-10-02 23:52:09 +0700
commit478fd21e07fd4092e3a099556d4004e34ae31177 (patch)
tree45f4cee59e852440f43b2e9e8c17e879053f8eb7 /platform/windows/os_windows.cpp
parent34ea27138072446947ee12bfcaba288f9ff825e5 (diff)
parent20918587d39c5c9c370e3b4beccf883f553d9b3e (diff)
downloadredot-engine-478fd21e07fd4092e3a099556d4004e34ae31177.tar.gz
Merge pull request #11575 from marcelofg55/move_path_to_trash
FileSystemDock will now remove files/dirs to trashcan using OS::move_to_trash
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp27
1 files changed, 27 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;