msi: Handle the special table _ForceCodepage in MsiDatabaseExport.
This commit is contained in:
parent
7d529228d3
commit
a8d87a86cc
|
@ -849,12 +849,29 @@ static UINT msi_export_row( MSIRECORD *row, void *arg )
|
|||
return msi_export_record( arg, row, 1 );
|
||||
}
|
||||
|
||||
static UINT msi_export_forcecodepage( HANDLE handle )
|
||||
{
|
||||
DWORD sz;
|
||||
|
||||
static const char data[] = "\r\n\r\n0\t_ForceCodepage\r\n";
|
||||
|
||||
FIXME("Read the codepage from the strings table!\n");
|
||||
|
||||
sz = lstrlenA(data) + 1;
|
||||
if (!WriteFile(handle, data, sz, &sz, NULL))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table,
|
||||
LPCWSTR folder, LPCWSTR file )
|
||||
{
|
||||
static const WCHAR query[] = {
|
||||
's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','%','s',0 };
|
||||
static const WCHAR szbs[] = { '\\', 0 };
|
||||
static const WCHAR forcecodepage[] = {
|
||||
'_','F','o','r','c','e','C','o','d','e','p','a','g','e',0 };
|
||||
MSIRECORD *rec = NULL;
|
||||
MSIQUERY *view = NULL;
|
||||
LPWSTR filename;
|
||||
|
@ -882,6 +899,12 @@ UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table,
|
|||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
if (!lstrcmpW( table, forcecodepage ))
|
||||
{
|
||||
r = msi_export_forcecodepage( handle );
|
||||
goto done;
|
||||
}
|
||||
|
||||
r = MSI_OpenQuery( db, &view, query, table );
|
||||
if (r == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -915,8 +938,8 @@ UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table,
|
|||
msiobj_release( &view->hdr );
|
||||
}
|
||||
|
||||
done:
|
||||
CloseHandle( handle );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -5701,6 +5701,70 @@ static void test_noquotes(void)
|
|||
DeleteFileA(msifile);
|
||||
}
|
||||
|
||||
static void read_file_data(LPCSTR filename, LPSTR buffer)
|
||||
{
|
||||
OFSTRUCT ofs;
|
||||
HFILE file;
|
||||
DWORD read;
|
||||
|
||||
file = OpenFile(filename, &ofs, OF_READ);
|
||||
ZeroMemory(buffer, MAX_PATH);
|
||||
ReadFile((HANDLE)file, buffer, MAX_PATH, &read, NULL);
|
||||
CloseHandle((HANDLE)file);
|
||||
}
|
||||
|
||||
static void test_forcecodepage(void)
|
||||
{
|
||||
MSIHANDLE hdb;
|
||||
const char *query;
|
||||
char buffer[MAX_PATH];
|
||||
UINT r;
|
||||
|
||||
DeleteFile(msifile);
|
||||
|
||||
r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
query = "SELECT * FROM `_ForceCodepage`";
|
||||
r = run_query(hdb, 0, query);
|
||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
|
||||
|
||||
query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
|
||||
r = run_query(hdb, 0, query);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
query = "SELECT * FROM `_ForceCodepage`";
|
||||
r = run_query(hdb, 0, query);
|
||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
|
||||
|
||||
r = MsiDatabaseCommit(hdb);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
query = "SELECT * FROM `_ForceCodepage`";
|
||||
r = run_query(hdb, 0, query);
|
||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
|
||||
|
||||
MsiCloseHandle(hdb);
|
||||
|
||||
r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
query = "SELECT * FROM `_ForceCodepage`";
|
||||
r = run_query(hdb, 0, query);
|
||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
|
||||
|
||||
r = MsiDatabaseExport(hdb, "_ForceCodepage", CURR_DIR, "forcecodepage.idt");
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
read_file_data("forcecodepage.idt", buffer);
|
||||
ok(!lstrcmpA(buffer, "\r\n\r\n0\t_ForceCodepage\r\n"),
|
||||
"Expected \"\r\n\r\n0\t_ForceCodepage\r\n\", got \"%s\"", buffer);
|
||||
|
||||
MsiCloseHandle(hdb);
|
||||
DeleteFileA(msifile);
|
||||
DeleteFileA("forcecodepage.idt");
|
||||
}
|
||||
|
||||
START_TEST(db)
|
||||
{
|
||||
test_msidatabase();
|
||||
|
@ -5735,4 +5799,5 @@ START_TEST(db)
|
|||
test_quotes();
|
||||
test_carriagereturn();
|
||||
test_noquotes();
|
||||
test_forcecodepage();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue