Erich E. Hoover : msidb: Permit specifying tables to import by filename.

Alexandre Julliard julliard at winehq.org
Tue Mar 19 17:09:20 CDT 2019


Module: wine
Branch: master
Commit: dcb3747f5eb4c8bf7ec1ae40a220399e628d7211
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=dcb3747f5eb4c8bf7ec1ae40a220399e628d7211

Author: Erich E. Hoover <erich.e.hoover at gmail.com>
Date:   Sat Mar 16 11:19:26 2019 -0600

msidb: Permit specifying tables to import by filename.

msidb permits tables to be imported by filename (rather than just
the name of the table) when the '.idt' extension is specified.
This feature also allows specifying tables with long filenames:
msidb -d package.msi -f . -i InstallExecuteSequence.idt

Signed-off-by: Erich E. Hoover <erich.e.hoover at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/msidb/Makefile.in |  2 +-
 programs/msidb/main.c      | 22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/programs/msidb/Makefile.in b/programs/msidb/Makefile.in
index bb74041..5efb431 100644
--- a/programs/msidb/Makefile.in
+++ b/programs/msidb/Makefile.in
@@ -1,5 +1,5 @@
 MODULE    = msidb.exe
 APPMODE   = -mconsole -municode
-IMPORTS   = msi
+IMPORTS   = msi shlwapi
 
 C_SRCS = main.c
diff --git a/programs/msidb/main.c b/programs/msidb/main.c
index 4bd065a..98ba133 100644
--- a/programs/msidb/main.c
+++ b/programs/msidb/main.c
@@ -24,6 +24,7 @@
 #include <windows.h>
 #include <msi.h>
 #include <msiquery.h>
+#include <shlwapi.h>
 
 #include "wine/debug.h"
 #include "wine/unicode.h"
@@ -433,17 +434,14 @@ static int extract_streams( struct msidb_state *state )
     return 1;
 }
 
-static int import_table( struct msidb_state *state, const WCHAR *table_name )
+static int import_table( struct msidb_state *state, const WCHAR *table_path )
 {
-    const WCHAR format[] = { '%','.','8','s','.','i','d','t',0 }; /* truncate to 8 characters */
-    WCHAR table_path[MAX_PATH];
     UINT ret;
 
-    snprintfW( table_path, ARRAY_SIZE(table_path), format, table_name );
     ret = MsiDatabaseImportW( state->database_handle, state->table_folder, table_path );
     if (ret != ERROR_SUCCESS)
     {
-        ERR( "Failed to import table '%s', error %d.\n", wine_dbgstr_w(table_name), ret );
+        ERR( "Failed to import table '%s', error %d.\n", wine_dbgstr_w(table_path), ret );
         return 0;
     }
     return 1;
@@ -451,11 +449,23 @@ static int import_table( struct msidb_state *state, const WCHAR *table_name )
 
 static int import_tables( struct msidb_state *state )
 {
+    const WCHAR idt_ext[] = { '.','i','d','t',0 };
     struct msidb_listentry *data;
 
     LIST_FOR_EACH_ENTRY( data, &state->table_list, struct msidb_listentry, entry )
     {
-        if (!import_table( state, data->name ))
+        WCHAR *table_name = data->name;
+        WCHAR table_path[MAX_PATH];
+        WCHAR *ext;
+
+        /* permit specifying tables by filename (*.idt) */
+        if ((ext = PathFindExtensionW( table_name )) == NULL || lstrcmpW( ext, idt_ext ) != 0)
+        {
+            const WCHAR format[] = { '%','.','8','s','.','i','d','t',0 }; /* truncate to 8 characters */
+            snprintfW( table_path, ARRAY_SIZE(table_path), format, table_name );
+            table_name = table_path;
+        }
+        if (!import_table( state, table_name ))
             return 0; /* failed, do not commit changes */
     }
     return 1;




More information about the wine-cvs mailing list