Commit 70d34026 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Skins2: reimplement rmDir on Windows with ShellApi

parent 8dc8e064
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <winuser.h> #include <winuser.h>
#include <wingdi.h> #include <wingdi.h>
#include <tchar.h> #include <tchar.h>
#include <shellapi.h>
#include "win32_factory.hpp" #include "win32_factory.hpp"
#include "win32_graphics.hpp" #include "win32_graphics.hpp"
...@@ -478,39 +479,20 @@ void Win32Factory::changeCursor( CursorType_t type ) const ...@@ -478,39 +479,20 @@ void Win32Factory::changeCursor( CursorType_t type ) const
void Win32Factory::rmDir( const string &rPath ) void Win32Factory::rmDir( const string &rPath )
{ {
WIN32_FIND_DATAA find; LPWSTR dir = ToWide( rPath.c_str() );
string file; SHFILEOPSTRUCTW file_op = {
string findFiles = rPath + "\\*"; NULL,
HANDLE handle = FindFirstFileA( findFiles.c_str(), &find ); FO_DELETE,
dir,
while( handle != INVALID_HANDLE_VALUE ) NULL,
{ FOF_NOCONFIRMATION |
// If file is neither "." nor ".." FOF_NOERRORUI |
if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) ) FOF_SILENT,
{ false,
// Set file name NULL,
file = rPath + "\\" + (string)find.cFileName; TEXT("") };
// If file is a directory, delete it recursively SHFileOperationW(&file_op);
if( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
rmDir( file );
}
// Else, it is a file so simply delete it
else
{
DeleteFileA( file.c_str() );
}
}
// If no more file in directory, exit while
if( !FindNextFileA( handle, &find ) )
break;
}
// Now directory is empty so can be removed
FindClose( handle );
RemoveDirectoryA( rPath.c_str() );
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment