]> git.sesse.net Git - vlc/commitdiff
* on Win32 the config file is now stored under the "Application Data" folder
authorGildas Bazin <gbazin@videolan.org>
Wed, 24 Apr 2002 23:08:08 +0000 (23:08 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 24 Apr 2002 23:08:08 +0000 (23:08 +0000)
  belonging to the user. (this works if at least IE4 is installed, otherwise
  the old method is used to get the config directory)

src/misc/configuration.c

index f8ea0aaaa4451bb29cd2eb3808d1c3c9bffd04cb..ddb9ece64dfbd9d2531e09b2443ace7b3705327b 100644 (file)
@@ -2,7 +2,7 @@
  * configuration.c management of the modules configuration
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: configuration.c,v 1.19 2002/04/23 14:16:21 sam Exp $
+ * $Id: configuration.c,v 1.20 2002/04/24 23:08:08 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -948,6 +948,45 @@ char *config_GetHomeDir( void )
     struct passwd *p_pw = NULL;
 #endif
 
+#ifdef WIN32
+    typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD,
+                                               LPTSTR );
+#   define CSIDL_FLAG_CREATE 0x8000
+#   define CSIDL_APPDATA 0x1A
+#   define SHGFP_TYPE_CURRENT 0
+
+    HINSTANCE shell32_dll;
+    SHGETFOLDERPATH SHGetFolderPath ;
+
+    /* load the shell32 dll to retreive SHGetFolderPath */
+    if( ( shell32_dll = LoadLibrary("shell32.dll") ) != NULL )
+    {
+        SHGetFolderPath = (void *)GetProcAddress( shell32_dll,
+                                                  "SHGetFolderPathA" );
+        if ( SHGetFolderPath != NULL )
+        {
+            p_homedir = (char *)malloc( MAX_PATH );
+            if( !p_homedir )
+            {
+                intf_ErrMsg( "config error: couldn't malloc p_homedir" );
+                return NULL;
+            }
+
+            /* get the "Application Data" folder for the current user */
+            if( S_OK == SHGetFolderPath( NULL,
+                                         CSIDL_APPDATA | CSIDL_FLAG_CREATE,
+                                         NULL, SHGFP_TYPE_CURRENT,
+                                         p_homedir ) )
+            {
+                FreeLibrary( shell32_dll );
+                return p_homedir;
+            }
+            free( p_homedir );
+        }
+        FreeLibrary( shell32_dll );
+    }
+#endif
+
 #if defined(HAVE_GETPWUID)
     if( ( p_pw = getpwuid( getuid() ) ) == NULL )
 #endif