]> git.sesse.net Git - vlc/blobdiff - src/os2/dirs.c
aout: fix cleanup after error
[vlc] / src / os2 / dirs.c
index 598e1c4bcb188288903b136218ce071daa331022..d4a7669445acc58f686d30f23d48e92e02fa6e8e 100644 (file)
@@ -1,23 +1,23 @@
 /*****************************************************************************
  * dirs.c: OS/2 directories configuration
  *****************************************************************************
- * Copyright (C) 2010 the VideoLAN team
+ * Copyright (C) 2010 VLC authors and VideoLAN
  *
  * Authors: KO Myung-Hun <komh@chollian.net>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 #include <vlc_charset.h>
 #include "config/configuration.h"
 
-static char *config_GetVlcDir (void)
+char *config_GetLibDir (void)
 {
-    return FromLocaleDup (psz_vlcpath);
+    HMODULE hmod;
+    CHAR    psz_path[CCHMAXPATH + 4];
+
+    DosQueryModFromEIP( &hmod, NULL, 0, NULL, NULL, ( ULONG )system_Init );
+    DosQueryModuleName( hmod, sizeof( psz_path ), psz_path );
+
+    /* remove the DLL name */
+    char *slash = strrchr( psz_path, '\\');
+    if( slash == NULL )
+        abort();
+    strcpy(slash + 1, PACKAGE);
+    return FromLocaleDup(psz_path);
 }
 
 /**
@@ -40,27 +51,19 @@ static char *config_GetVlcDir (void)
  *
  * @return a nul-terminated string or NULL. Use free() to release it.
  */
-char *config_GetDataDirDefault (void)
+char *config_GetDataDir (void)
 {
-    char *datadir = config_GetVlcDir();
+    const char *path = getenv ("VLC_DATA_PATH");
+    if (path)
+        return strdup (path);
 
+    char *datadir = config_GetLibDir();
     if (datadir)
         /* replace last lib\vlc with share */
         strcpy ( datadir + strlen (datadir) - 7, "share");
-
     return datadir;
 }
 
-/**
- * Determines the architecture-dependent data directory
- *
- * @return a string (always succeeds).
- */
-const char *config_GetLibDir (void)
-{
-    abort ();
-}
-
 /**
  * Determines the system configuration directory.
  *
@@ -68,7 +71,8 @@ const char *config_GetLibDir (void)
  */
 const char *config_GetConfDir( void )
 {
-    return config_GetVlcDir ();
+#warning FIXME: memory leak
+    return config_GetLibDir ();
 }
 
 char *config_GetUserDir (vlc_userdir_t type)
@@ -89,5 +93,5 @@ char *config_GetUserDir (vlc_userdir_t type)
         case VLC_VIDEOS_DIR:
             break;
     }
-    return config_GetVlcDir ();
+    return config_GetLibDir ();
 }