Kaydet (Commit) 013d1e01 authored tarafından Eilidh McAdam's avatar Eilidh McAdam

Ensure correct import of msi tables using wildcard character

Change-Id: I3e1800d73250a8a630dd37329189b13cfae311e9
üst d607a9c3
...@@ -279,15 +279,15 @@ static BOOL msidbExportStream(LPCWSTR dbfile, LPCWSTR wdir, LPCWSTR streamName) ...@@ -279,15 +279,15 @@ static BOOL msidbExportStream(LPCWSTR dbfile, LPCWSTR wdir, LPCWSTR streamName)
/*********************************************************************** /***********************************************************************
* msidbImportTables * msidbImportTables
* *
* Takes a list of tables or '*' (for all) to export to text archive * Takes a list of tables or '*' (for all) to import from text archive
* files in specified folder * files in specified folder
* *
* For each table, a file called <tablename>.idt is exported containing * For each table, a file called <tablename>.idt is imported containing
* tab separated ASCII. * tab separated ASCII.
* *
* Examples (note wildcard escape for *nix/bash): * Examples (note wildcard escape for *nix/bash):
* msidb -d <pathtomsi>.msi -f <workdir> -e \* * msidb -d <pathtomsi>.msi -f <workdir> -i \*
* msidb -d <pathtomsi>.msi -f <workdir> -e File Directory Binary * msidb -d <pathtomsi>.msi -f <workdir> -i File Directory Binary
**********************************************************************/ **********************************************************************/
static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOOL create) static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOOL create)
{ {
...@@ -323,13 +323,17 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO ...@@ -323,13 +323,17 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
{ {
while ((ent = readdir(dir)) != NULL) while ((ent = readdir(dir)) != NULL)
{ {
if (ent->d_type != DT_REG) continue;
fileName = ent->d_name; fileName = ent->d_name;
if (strcmp(fileName+strlen(fileName)-4*sizeof(fileName[0]), ".idt") != 0) continue;
if (strcmp(fileName, ".") == 0 || strcmp(fileName, "..") == 0) continue; if (strcmp(fileName, ".") == 0 || strcmp(fileName, "..") == 0) continue;
tableFile = strdupAtoW(CP_ACP, fileName); tableFile = strdupAtoW(CP_ACP, fileName);
r = MsiDatabaseImportW(dbhandle, wdir, tableFile); r = MsiDatabaseImportW(dbhandle, wdir, tableFile);
free(tableFile); free(tableFile);
} }
} }
else
return FALSE;
closedir(dir); closedir(dir);
free(dirNameA); free(dirNameA);
} }
...@@ -343,7 +347,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO ...@@ -343,7 +347,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
lstrcpyW(tableFile, tables[i]); lstrcpyW(tableFile, tables[i]);
lstrcatW(tableFile, ext); lstrcatW(tableFile, ext);
r = MsiDatabaseImportW(dbhandle, wdir, tableFile); r = MsiDatabaseImportW(dbhandle, wdir, tableFile);
free(tableFile); free(tableFile);
...@@ -353,6 +356,7 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO ...@@ -353,6 +356,7 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
} }
} }
} }
MsiDatabaseCommit(dbhandle); MsiDatabaseCommit(dbhandle);
MsiCloseHandle(dbhandle); MsiCloseHandle(dbhandle);
return TRUE; return TRUE;
...@@ -476,10 +480,9 @@ int wmain(int argc, WCHAR *argv[]) ...@@ -476,10 +480,9 @@ int wmain(int argc, WCHAR *argv[])
i = 0; i = 0;
while (argv[2] && argv[2][0] != '-' && i < 10) while (argv[2] && argv[2][0] != '-' && i < 10)
{ {
argv++; argc--; i++;
iTables[i] = argv[2]; iTables[i] = argv[2];
argv++; argc--; i++;
} }
break; break;
case 'e': /* Export tables */ case 'e': /* Export tables */
i = 0; i = 0;
...@@ -550,6 +553,9 @@ int wmain(int argc, WCHAR *argv[]) ...@@ -550,6 +553,9 @@ int wmain(int argc, WCHAR *argv[])
if (!msidbExportStorage(dbfile, wdir, storageName)) if (!msidbExportStorage(dbfile, wdir, storageName))
return 6; return 6;
if (!iTables[0] && !oTables[0] && !streamName && !streamFiles[0] && !storageNames[0] && !storageName)
return 7;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment