[vlc-commits] Portable windows build

Hannes Domani git at videolan.org
Sun Jun 14 17:45:19 CEST 2015


vlc | branch: master | Hannes Domani <ssbssa at yahoo.de> | Thu Mar  5 19:38:12 2015 +0100| [f92239f0410ce696dee5874c9cd69d8b782c6e31] | committer: Jean-Baptiste Kempf

Portable windows build

If a portable/ folder is next to the libvlccore.dll binary, it will use
it for most configuration and other files.

Close #9751, #2114 and #12679

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f92239f0410ce696dee5874c9cd69d8b782c6e31
---

 modules/gui/qt4/qt4.cpp |    9 +++++++++
 src/win32/dirs.c        |   15 +++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index f0d5891..7b0b795 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -483,6 +483,15 @@ static void *Thread( void *obj )
 
 
     /* All the settings are in the .conf/.ini style */
+#ifdef _WIN32
+    char *cConfigDir = config_GetUserDir( VLC_CONFIG_DIR );
+    QString configDir = cConfigDir;
+    free( cConfigDir );
+    if( configDir.endsWith( "\\vlc" ) )
+        configDir.chop( 4 ); /* the "\vlc" dir is added again by QSettings */
+    QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, configDir );
+#endif
+
     p_intf->p_sys->mainSettings = new QSettings(
 #ifdef _WIN32
             QSettings::IniFormat,
diff --git a/src/win32/dirs.c b/src/win32/dirs.c
index fbb48b6..7a62bfc 100644
--- a/src/win32/dirs.c
+++ b/src/win32/dirs.c
@@ -87,6 +87,21 @@ static char *config_GetShellDir (int csidl)
 
 static char *config_GetAppDir (void)
 {
+    /* if portable directory exists, use it */
+    TCHAR path[MAX_PATH];
+    if (GetModuleFileName (NULL, path, MAX_PATH))
+    {
+        TCHAR *lastDir = _tcsrchr (path, '\\');
+        if (lastDir)
+        {
+            _tcscpy (lastDir + 1, TEXT("portable"));
+            DWORD attrib = GetFileAttributes (path);
+            if (attrib != INVALID_FILE_ATTRIBUTES &&
+                    (attrib & FILE_ATTRIBUTE_DIRECTORY))
+                return FromT (path);
+        }
+    }
+
     char *psz_dir;
     char *psz_parent = config_GetShellDir (CSIDL_APPDATA);
 



More information about the vlc-commits mailing list