From 15823c0a5a1c7718d095e3ecb983108272c8a9fb Mon Sep 17 00:00:00 2001
From: Martell Malone <martellmalone@gmail.com>
Date: Tue, 25 Nov 2014 21:20:09 +0000
Subject: [PATCH 1/7] Use libdir for plugins on msys2

---
 src/win32/dirs.c                            | 38 +++++++++-
 modules/gui/skins2/win32/win32_factory.cpp  | 2  ++
 2 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/win32/dirs.c b/src/win32/dirs.c
index 8a8876a1a2..2343579375 100644
--- a/src/win32/dirs.c
+++ b/src/win32/dirs.c
@@ -200,7 +200,15 @@ char *config_GetLibDir (void)
         goto error;
     *file = L'\0';
 
-    return FromWide (wpath);
+    file = wcsrchr (wpath, L'\\');
+    if (file == NULL)
+        goto error;
+    *file = L'\0';
+
+    wchar_t wpathlib[MAX_PATH];
+    wsprintf(wpathlib,L"%s\\lib\\vlc", wpath);
+
+    return FromWide (wpathlib);
 error:
     abort ();
 #endif
@@ -216,8 +216,36 @@
 
 char *config_GetDataDir (void)
 {
+#ifdef __MINGW32__
+    /* Get our full path */
+    MEMORY_BASIC_INFORMATION mbi;
+    if (!VirtualQuery (config_GetLibDir, &mbi, sizeof(mbi)))
+        goto error;
+
+    wchar_t wpath[MAX_PATH];
+    if (!GetModuleFileName ((HMODULE) mbi.AllocationBase, wpath, MAX_PATH))
+        goto error;
+
+    wchar_t *file = wcsrchr (wpath, L'\\');
+    if (file == NULL)
+        goto error;
+    *file = L'\0';
+
+    file = wcsrchr (wpath, L'\\');
+    if (file == NULL)
+        goto error;
+    *file = L'\0';
+
+    wchar_t wpathlib[MAX_PATH];
+    wsprintf(wpathlib,L"%s\\share", wpath);
+
+    return FromWide (wpathlib);
+error:
+    abort ();
+#else
     const char *path = getenv ("VLC_DATA_PATH");
     return (path != NULL) ? strdup (path) : config_GetLibDir ();
+#endif
 }
 
 static char *config_GetShellDir (int csidl)
diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 8a8876a1a2..2343579375 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -239,6 +239,8 @@
     datadir = config_GetDataDir();
     m_resourcePath.push_back( (std::string)datadir + "\\skins" );
     m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
+    m_resourcePath.push_back( (std::string)datadir + "\\vlc\\skins" );
+    m_resourcePath.push_back( (std::string)datadir + "\\vlc\\skins2" );
     m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
     m_resourcePath.push_back( (std::string)datadir + "\\share\\skins2" );
     free( datadir );
-- 
2.15.0
