Erich E. Hoover : msidb: Add support for wildcard table import.

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


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

Author: Erich E. Hoover <erich.e.hoover at gmail.com>
Date:   Sat Mar 16 21:15:39 2019 -0600

msidb: Add support for wildcard table import.

msidb allows multiple tables to be imported with the use of
standard wildcards.  For example, both Feature and
FeatureComponent tables can be imported simultaneously like so:
msidb -d package.msi -f . -i 'Feature*'

Please note that it is important to quote the wildcard to prevent
files from being passed instead of the intended pattern.

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/main.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/programs/msidb/main.c b/programs/msidb/main.c
index 98ba133..36255c4 100644
--- a/programs/msidb/main.c
+++ b/programs/msidb/main.c
@@ -450,6 +450,7 @@ static int import_table( struct msidb_state *state, const WCHAR *table_path )
 static int import_tables( struct msidb_state *state )
 {
     const WCHAR idt_ext[] = { '.','i','d','t',0 };
+    const WCHAR wildcard[] = { '*',0 };
     struct msidb_listentry *data;
 
     LIST_FOR_EACH_ENTRY( data, &state->table_list, struct msidb_listentry, entry )
@@ -458,6 +459,41 @@ static int import_tables( struct msidb_state *state )
         WCHAR table_path[MAX_PATH];
         WCHAR *ext;
 
+        /* permit specifying tables with wildcards ('Feature*') */
+        if (strstrW( table_name, wildcard ) != NULL)
+        {
+            WIN32_FIND_DATAW f;
+            HANDLE handle;
+            WCHAR *path;
+            DWORD len;
+
+            len = strlenW( state->table_folder ) + 1 + strlenW( table_name ) + 1; /* %s/%s\0 */
+            path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+            if (path == NULL)
+                return 0;
+            lstrcpyW( path, state->table_folder );
+            PathAddBackslashW( path );
+            lstrcatW( path, table_name );
+            handle = FindFirstFileW( path, &f );
+            HeapFree( GetProcessHeap(), 0, path );
+            if (handle == INVALID_HANDLE_VALUE)
+                return 0;
+            do
+            {
+                if (f.cFileName[0] == '.' && !f.cFileName[1]) continue;
+                if (f.cFileName[0] == '.' && f.cFileName[1] == '.' && !f.cFileName[2]) continue;
+                if (f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
+                if ((ext = PathFindExtensionW( f.cFileName )) == NULL) continue;
+                if (lstrcmpW( ext, idt_ext ) != 0) continue;
+                if (!import_table( state, f.cFileName ))
+                {
+                    FindClose( handle );
+                    return 0; /* failed, do not commit changes */
+                }
+            } while (FindNextFileW( handle, &f ));
+            FindClose( handle );
+            continue;
+        }
         /* permit specifying tables by filename (*.idt) */
         if ((ext = PathFindExtensionW( table_name )) == NULL || lstrcmpW( ext, idt_ext ) != 0)
         {




More information about the wine-cvs mailing list