Alexandre Julliard : setupapi: Abstract the creation of the fake dll destination to a separate function.
Alexandre Julliard
julliard at winehq.org
Thu Oct 15 08:54:39 CDT 2009
Module: wine
Branch: master
Commit: d59a4d189459cff999a60b36e7db7f556c292a26
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d59a4d189459cff999a60b36e7db7f556c292a26
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Oct 15 12:25:11 2009 +0200
setupapi: Abstract the creation of the fake dll destination to a separate function.
---
dlls/setupapi/fakedll.c | 51 +++++++++++++++++++++++++++-------------------
1 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/dlls/setupapi/fakedll.c b/dlls/setupapi/fakedll.c
index 2f9f80c..4dd88d7 100644
--- a/dlls/setupapi/fakedll.c
+++ b/dlls/setupapi/fakedll.c
@@ -367,32 +367,18 @@ done:
return NULL;
}
-/***********************************************************************
- * create_fake_dll
- */
-BOOL create_fake_dll( const WCHAR *name, const WCHAR *source )
+/* create the fake dll destination file */
+static HANDLE create_dest_file( const WCHAR *name )
{
- HANDLE h;
- BOOL ret;
- unsigned int size = 0;
- void *buffer;
-
- /* check for empty name which means to only create the directory */
- if (name[strlenW(name) - 1] == '\\')
- {
- create_directories( name );
- return TRUE;
- }
-
/* first check for an existing file */
- h = CreateFileW( name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
+ HANDLE h = CreateFileW( name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
if (h != INVALID_HANDLE_VALUE)
{
if (!is_fake_dll( h ))
{
TRACE( "%s is not a fake dll, not overwriting it\n", debugstr_w(name) );
CloseHandle( h );
- return TRUE;
+ return 0;
}
/* truncate the file */
SetFilePointer( h, 0, NULL, FILE_BEGIN );
@@ -404,11 +390,34 @@ BOOL create_fake_dll( const WCHAR *name, const WCHAR *source )
h = CreateFileW( name, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL );
if (h == INVALID_HANDLE_VALUE)
- {
ERR( "failed to create %s (error=%u)\n", debugstr_w(name), GetLastError() );
- return FALSE;
- }
}
+ return h;
+}
+
+/***********************************************************************
+ * create_fake_dll
+ */
+BOOL create_fake_dll( const WCHAR *name, const WCHAR *source )
+{
+ HANDLE h;
+ BOOL ret;
+ size_t size;
+ const WCHAR *filename;
+ void *buffer;
+
+ if (!(filename = strrchrW( name, '\\' ))) filename = name;
+ else filename++;
+
+ /* check for empty name which means to only create the directory */
+ if (!filename[0])
+ {
+ create_directories( name );
+ return TRUE;
+ }
+
+ if (!(h = create_dest_file( name ))) return TRUE; /* not a fake dll */
+ if (h == INVALID_HANDLE_VALUE) return FALSE;
if ((buffer = load_fake_dll( source, &size )))
{
More information about the wine-cvs
mailing list