setupapi: if needed create directories for fake dlls (patch)

Mikolaj Zalewski mikolajz at google.com
Mon Aug 20 12:37:29 CDT 2007


-------------- next part --------------
From 0ff1a9f81c755af7e0bc38c6973e5b890b325d1e Mon Sep 17 00:00:00 2001
From: Mikolaj Zalewski <mikolaj at zalewski.pl>
Date: Mon, 20 Aug 2007 10:03:16 -0700
Subject: [PATCH] setupapi: if needed create directories for fake dlls
---
 dlls/setupapi/fakedll.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/dlls/setupapi/fakedll.c b/dlls/setupapi/fakedll.c
index 5bf87c4..37b6c5c 100644
--- a/dlls/setupapi/fakedll.c
+++ b/dlls/setupapi/fakedll.c
@@ -302,9 +302,34 @@ BOOL create_fake_dll( const WCHAR *name,
     else
     {
         h = CreateFileW( name, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL );
+
+        if (h == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND)
+        {
+            WCHAR *path;
+            WCHAR *pathel;
+
+            /* create the directory/directories */
+            path = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1)*sizeof(WCHAR));
+            strcpyW(path, name);
+
+            pathel = strchrW(name, '\\');
+            while (pathel != NULL)
+            {
+                *pathel = 0;
+                if (!CreateDirectoryW(name, NULL))
+                    TRACE("Couldn't create directory %s - error: %d\n", wine_dbgstr_w(name), GetLastError());
+                *pathel = '\\';
+                pathel = strchrW(pathel+1, '\\');
+            }
+
+            HeapFree(GetProcessHeap(), 0, path);
+
+            h = CreateFileW( name, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL );            
+        }
+
         if (h == INVALID_HANDLE_VALUE)
         {
-            WARN( "failed to create %s\n", debugstr_w(name) );
+            ERR( "failed to create %s (last error=%d)\n", debugstr_w(name), GetLastError() );
             return FALSE;
         }
     }
-- 
1.4.1


More information about the wine-patches mailing list