From 4e2f48ce2c504ca41e381fbbef2fa909c8a0c688 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Sat, 16 Mar 2019 21:15:39 -0600 Subject: [PATCH] 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 Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- programs/msidb/main.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/programs/msidb/main.c b/programs/msidb/main.c index 98ba133a96f..36255c4e896 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) { -- 2.11.4.GIT