FileSystemDock will now remove files/dirs to trashcan using OS::move_to_trash

This commit is contained in:
Marcelo Fernandez
2017-09-25 10:15:11 -03:00
parent 09800ac650
commit 20918587d3
9 changed files with 140 additions and 13 deletions

View File

@ -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;