From 767e70ef58c963eef742ee95b64c4c488035c3e7 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Thu, 17 Sep 2015 15:09:24 -0600
Subject: msidb: Add support for exporting with short (DOS) filenames.

Signed-off-by: Erich E. Hoover <erich.e.hoover@wine-staging.com>
---
 programs/msidb/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/programs/msidb/main.c b/programs/msidb/main.c
index 7eb6d8b..49dd11b 100644
--- a/programs/msidb/main.c
+++ b/programs/msidb/main.c
@@ -48,6 +48,7 @@ struct msidb_state
     BOOL create_database;
     BOOL import_tables;
     BOOL export_tables;
+    BOOL short_filenames;
     struct list add_stream_list;
     struct list extract_stream_list;
     struct list kill_stream_list;
@@ -92,6 +93,7 @@ static void show_usage( void )
         "  -f folder         Folder in which to open/save the tables.\n"
         "  -i                Import tables into database.\n"
         "  -k file.cab       Kill (remove) stream/cabinet file from _Streams table.\n"
+        "  -s                Export with short filenames (eight character max).\n"
         "  -x file.cab       Extract stream/cabinet file from _Streams table.\n"
     );
 }
@@ -163,6 +165,9 @@ static int process_argument( struct msidb_state *state, int i, int argc, WCHAR *
         state->kill_streams = TRUE;
         list_append( &state->kill_stream_list, argv[i + 1] );
         return 2;
+    case 's':
+        state->short_filenames = TRUE;
+        return 1;
     case 'x':
         if (i + 1 >= argc) return 0;
         state->extract_streams = TRUE;
@@ -452,7 +457,9 @@ static int import_tables( struct msidb_state *state )
 
 static int export_table( struct msidb_state *state, const WCHAR *table_name )
 {
-    const WCHAR format[] = { '%','s','.','i','d','t',0 };
+    const WCHAR format_dos[] = { '%','.','8','s','.','i','d','t',0 }; /* truncate to 8 characters */
+    const WCHAR format_full[] = { '%','s','.','i','d','t',0 };
+    const WCHAR *format = (state->short_filenames ? format_dos : format_full);
     WCHAR table_path[MAX_PATH];
     UINT ret;
 
-- 
2.5.1

