/////////////////////////////////////////////////////////////// // // DelTree // // // /////////////////////////////////////////////////////////////// bool SharedUtil::DelTree ( const SString& strPath, const SString& strInsideHere ) { // Safety: Make sure strPath is inside strInsideHere WString wstrPath = FromUTF8( strPath ); WString wstrInsideHere = FromUTF8( strInsideHere ); if ( !wstrPath.BeginsWithI( wstrInsideHere ) ) { assert ( 0 ); return false; } DWORD dwBufferSize = ( wstrPath.length() + 3 ) * sizeof( wchar_t ); wchar_t *szBuffer = static_cast < wchar_t* > ( alloca ( dwBufferSize ) ); memset ( szBuffer, 0, dwBufferSize ); wcsncpy ( szBuffer, wstrPath, wstrPath.length() ); SHFILEOPSTRUCTW sfos; sfos.hwnd = NULL; sfos.wFunc = FO_DELETE; sfos.pFrom = szBuffer; // Double NULL terminated sfos.pTo = NULL; sfos.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; int status = SHFileOperationW(&sfos); return status == 0; }