(svn r12373) -Fix [FS#1849]: win32 music driver fails if path is too long (128 chars is too much for mci it seems), so retry using the short path name (8.3 style) if available
authorglx
Sat, 15 Mar 2008 21:20:40 +0000
changeset 8700 df3adf076096
parent 8699 831349476467
child 8701 9dac8a2a8d45
(svn r12373) -Fix [FS#1849]: win32 music driver fails if path is too long (128 chars is too much for mci it seems), so retry using the short path name (8.3 style) if available
src/music/win32_m.cpp
--- a/src/music/win32_m.cpp	Sat Mar 15 21:12:08 2008 +0000
+++ b/src/music/win32_m.cpp	Sat Mar 15 21:20:40 2008 +0000
@@ -61,7 +61,12 @@
 {
 	MidiSendCommand(_T("close all"));
 
-	if (MidiSendCommand(_T("open \"%s\" type sequencer alias song"), OTTD2FS(filename)) != 0) return false;
+	if (MidiSendCommand(_T("open \"%s\" type sequencer alias song"), OTTD2FS(filename)) != 0) {
+		/* Let's try the "short name" */
+		TCHAR buf[MAX_PATH];
+		if (GetShortPathName(OTTD2FS(filename), buf, MAX_PATH) == 0) return false;
+		if (MidiSendCommand(_T("open \"%s\" type sequencer alias song"), buf) != 0) return false;
+	}
 
 	return MidiSendCommand(_T("play song from 0")) == 0;
 }