[vlc-commits] Skins2: reimplement rmDir on Windows with ShellApi

Jean-Baptiste Kempf git at videolan.org
Tue Jan 15 12:50:53 CET 2013


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Jan 15 12:49:08 2013 +0100| [70d34026113abe4438865b8b1e2557f223f861c8] | committer: Jean-Baptiste Kempf

Skins2: reimplement rmDir on Windows with ShellApi

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=70d34026113abe4438865b8b1e2557f223f861c8
---

 modules/gui/skins2/win32/win32_factory.cpp |   48 +++++++++-------------------
 1 file changed, 15 insertions(+), 33 deletions(-)

diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 3eb404a..e6f1ec3 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -32,6 +32,7 @@
 #include <winuser.h>
 #include <wingdi.h>
 #include <tchar.h>
+#include <shellapi.h>
 
 #include "win32_factory.hpp"
 #include "win32_graphics.hpp"
@@ -478,39 +479,20 @@ void Win32Factory::changeCursor( CursorType_t type ) const
 
 void Win32Factory::rmDir( const string &rPath )
 {
-    WIN32_FIND_DATAA find;
-    string file;
-    string findFiles = rPath + "\\*";
-    HANDLE handle    = FindFirstFileA( findFiles.c_str(), &find );
-
-    while( handle != INVALID_HANDLE_VALUE )
-    {
-        // If file is neither "." nor ".."
-        if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) )
-        {
-            // Set file name
-            file = rPath + "\\" + (string)find.cFileName;
-
-            // If file is a directory, delete it recursively
-            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() );
+    LPWSTR dir = ToWide( rPath.c_str() );
+    SHFILEOPSTRUCTW file_op = {
+        NULL,
+        FO_DELETE,
+        dir,
+        NULL,
+        FOF_NOCONFIRMATION |
+        FOF_NOERRORUI |
+        FOF_SILENT,
+        false,
+        NULL,
+        TEXT("") };
+
+     SHFileOperationW(&file_op);
 }
 
 #endif



More information about the vlc-commits mailing list