Changeset 16f32e1500887c0dcd33cb06ad71759a81a52878

Show
Ignore:
Timestamp:
09/09/07 18:10:45 (10 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1189354245 +0000
git-parent:

[e8f97c66ab6815875ab48a03fe768faee3ca5b3f]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1189354245 +0000
Message:

On OSes other than Windows, Mac OS X and BeOS (so it's Linux) comply with the XDG Base Directory Specification version 0.6. The old configuration file (vlcrc) will be copied to the new location. Other data like caches will have to be rebuilt (the album art cache in VLC was new in 0.9.0 so it's ok to lose it). Closes #1267

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • NEWS

    r65cd4a4 r16f32e1  
    112112     finished: http://wiki.xmms2.xmms.se/index.php/Media_Player_Interfaces . 
    113113   * Motion module use disk accelerometers to keep video horizontal 
     114 
     115Linux Port: 
     116 * VLC now complies with the XDG Base Directory Specification version 0.6 
     117   http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html 
     118   (which means that VLC doesn't use the $HOME/.vlc directory anymore) 
    114119 
    115120Capture: 
  • include/main.h

    r2e0409a r16f32e1  
    3939    int                    i_argc;           ///< command line arguments count 
    4040    char **                ppsz_argv;        ///< command line arguments 
    41     char *                 psz_homedir;      ///< configuration directory 
    42     char *                 psz_userdir;      ///< user's home directory 
     41 
     42    char *                 psz_homedir;      ///< user's home directory 
     43    char *                 psz_configdir;    ///< user's configuration directory 
     44    char *                 psz_datadir;      ///< user's data/cache directory 
     45 
    4346    char *                 psz_configfile;   ///< location of config file 
    4447 
  • include/vlc_config.h

    rfbf4c80 r16f32e1  
    4848 * outputting an error message (in second) */ 
    4949#define THREAD_COND_TIMEOUT             1 
    50  
    51 /* The configuration file and directory */ 
    52 #if defined (SYS_BEOS) 
    53 #  define CONFIG_DIR                    "config/settings/VideoLAN Client" 
    54 #elif defined (__APPLE__) 
    55 #  define CONFIG_DIR                    "Library/Preferences/VLC" 
    56 #elif defined( WIN32 ) || defined( UNDER_CE ) 
    57 #  define CONFIG_DIR                    "vlc" 
    58 #else 
    59 #  define CONFIG_DIR                    ".vlc" 
    60 #endif 
    61 #define CONFIG_FILE                     "vlcrc" 
    62 #define PLUGINSCACHE_DIR                "cache" 
    6350 
    6451/***************************************************************************** 
  • modules/access_filter/record.c

    rb75e050 r16f32e1  
    149149    { 
    150150        free( psz ); 
    151         if( p_access->p_libvlc->psz_homedir ) 
     151        if( p_access->p_libvlc->psz_homedir ) /* XXX: This should never happen */ 
    152152            psz = strdup( p_access->p_libvlc->psz_homedir ); 
    153153    } 
  • modules/control/http/util.c

    r45444ce r16f32e1  
    990990        char *dir; 
    991991        /* This is incomplete : we should also support the ~cmassiot/ syntax. */ 
    992         asprintf( &dir, "%s%s", p_intf->p_libvlc->psz_userdir, psz_dir + 1 ); 
     992        asprintf( &dir, "%s%s", p_intf->p_libvlc->psz_homedir, psz_dir + 1 ); 
    993993        free( psz_dir ); 
    994994        psz_dir = dir; 
  • modules/gui/skins2/win32/win32_factory.cpp

    r3ea2708 r16f32e1  
    226226 
    227227    // Initialize the resource path 
    228     m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_homedir + 
    229                                "\\" + CONFIG_DIR + "\\skins" ); 
    230     m_resourcePath.push_back( (string)config_GetDataDir() + 
     228    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_datadir + 
     229                               "\\skins" ); 
     230    m_resourcePath.push_back( (dstring)config_GetDataDir() + 
    231231                              "\\skins" ); 
    232232    m_resourcePath.push_back( (string)config_GetDataDir() + 
  • modules/gui/skins2/x11/x11_factory.cpp

    r65e0358 r16f32e1  
    7272 
    7373    // Initialize the resource path 
    74     m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_homedir + 
    75         m_dirSep + CONFIG_DIR + "/skins2" ); 
     74    m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_datadir + 
     75                              + "/skins2" ); 
    7676    m_resourcePath.push_back( (string)"share/skins2" ); 
    7777    m_resourcePath.push_back( (string)DATA_PATH + "/skins2" ); 
  • modules/misc/gnutls.c

    r8917f56 r16f32e1  
    703703    vlc_object_attach( p_session, p_tls ); 
    704704 
    705     const char *homedir = p_tls->p_libvlc->psz_homedir, 
     705    const char *homedir = p_tls->p_libvlc->psz_datadir, 
    706706               *datadir = config_GetDataDir (); 
    707707    size_t l1 = strlen (homedir), l2 = strlen (datadir); 
    708     char path[((l1 > l2) ? l1 : l2) + sizeof ("/"CONFIG_DIR"/ssl/private")]; 
    709     //                              > sizeof ("/"CONFIG_DIR"/ssl/certs") 
     708    char path[((l1 > l2) ? l1 : l2) + sizeof ("/ssl/private")]; 
     709    //                              > sizeof ("/ssl/certs") 
    710710    //                              > sizeof ("/ca-certificates.crt") 
    711711 
     
    720720    if (var_CreateGetBool (p_tls, "tls-check-cert")) 
    721721    { 
    722         sprintf (path, "%s/"CONFIG_DIR"/ssl/certs", homedir); 
     722        sprintf (path, "%s/ssl/certs", homedir); 
    723723        gnutls_Addx509Directory ((vlc_object_t *)p_session, 
    724724                                  p_sys->x509_cred, path, VLC_FALSE); 
     
    732732        p_session->pf_handshake2 = gnutls_ContinueHandshake; 
    733733 
    734     sprintf (path, "%s/"CONFIG_DIR"/ssl/private", homedir); 
     734    sprintf (path, "%s/ssl/private", homedir); 
    735735    gnutls_Addx509Directory ((vlc_object_t *)p_session, p_sys->x509_cred, 
    736736                             path, VLC_TRUE); 
  • modules/misc/logger.c

    r1b67b68 r16f32e1  
    202202            char *psz_homedir = p_this->p_libvlc->psz_homedir; 
    203203 
    204             if( !psz_homedir ) 
     204            if( !psz_homedir ) /* XXX: This should never happen */ 
    205205            { 
    206206                msg_Err( p_this, "unable to find home directory" ); 
  • modules/misc/lua/vlclua.c

    ra9a8900 r16f32e1  
    246246    char **ppsz_dir; 
    247247 
    248     if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP CONFIG_DIR DIR_SEP "%s", p_this->p_libvlc->psz_homedir
    249             luadirname ) < 0 ) 
     248    if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP "%s"
     249                   p_this->p_libvlc->psz_datadir, luadirname ) < 0 ) 
    250250        return VLC_ENOMEM; 
    251251 
  • src/control/media_library.c

    r7fecb1e r16f32e1  
    8989                           libvlc_exception_t * p_e ) 
    9090{ 
    91     const char *psz_homedir = p_mlib->p_libvlc_instance->p_libvlc_int->psz_homedir; 
     91    const char *psz_datadir = p_mlib->p_libvlc_instance->p_libvlc_int->psz_datadir; 
    9292    char * psz_uri; 
    9393 
    94     if( !psz_homedir ) 
     94    if( !psz_datadir ) /* XXX: i doubt that this can ever happen */ 
    9595    { 
    96         libvlc_exception_raise( p_e, "Can't get HOME DIR" ); 
     96        libvlc_exception_raise( p_e, "Can't get data directory" ); 
    9797        return; 
    9898    } 
    9999 
    100     if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP CONFIG_DIR DIR_SEP 
    101                         "ml.xsp", psz_homedir ) == -1 ) 
     100    if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp", 
     101                  psz_datadir ) == -1 ) 
    102102    { 
    103103        libvlc_exception_raise( p_e, "Can't get create the path" ); 
  • src/input/meta.c

    r10f0097 r16f32e1  
    274274        char * psz_artist_sanitized = ArtCacheGetSanitizedFileName( psz_artist ); 
    275275 
    276         snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP CONFIG_DIR DIR_SEP 
     276        snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP 
    277277                  "art" DIR_SEP "artistalbum" DIR_SEP "%s" DIR_SEP "%s", 
    278                       p_obj->p_libvlc->psz_homedir, 
     278                      p_obj->p_libvlc->psz_datadir, 
    279279                      psz_artist_sanitized, psz_album_sanitized ); 
    280280        free( psz_album_sanitized ); 
     
    284284    { 
    285285        char * psz_title_sanitized = ArtCacheGetSanitizedFileName( psz_title ); 
    286         snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP CONFIG_DIR DIR_SEP 
     286        snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP 
    287287                  "art" DIR_SEP "title" DIR_SEP "%s", 
    288                   p_obj->p_libvlc->psz_homedir, 
     288                  p_obj->p_libvlc->psz_datadir, 
    289289                  psz_title_sanitized ); 
    290290        free( psz_title_sanitized ); 
  • src/libvlc-common.c

    r56040f0 r16f32e1  
    326326 
    327327    /* Set the config file stuff */ 
    328     p_libvlc->psz_homedir = config_GetHomeDir(); 
    329     p_libvlc->psz_userdir = config_GetUserDir(); 
    330     if( p_libvlc->psz_userdir == NULL ) 
    331         p_libvlc->psz_userdir = strdup(p_libvlc->psz_homedir); 
    332     p_libvlc->psz_configfile = config_GetPsz( p_libvlc, "config" ); 
    333     if( (p_libvlc->psz_configfile != NULL) && (p_libvlc->psz_configfile[0] == '~') 
    334          && (p_libvlc->psz_configfile[1] == '/') ) 
    335     { 
    336         char *psz = malloc( strlen(p_libvlc->psz_userdir) 
    337                              + strlen(p_libvlc->psz_configfile) ); 
    338         if( psz ) 
    339         { 
    340             /* This is incomplete : we should also support the ~cmassiot/ syntax. */ 
    341             sprintf( psz, "%s/%s", p_libvlc->psz_userdir, 
    342                                 p_libvlc->psz_configfile + 2 ); 
    343             free( p_libvlc->psz_configfile ); 
    344             p_libvlc->psz_configfile = psz; 
    345         } /* else keep old config stuff */ 
    346     } 
     328    p_libvlc->psz_homedir    = config_GetHomeDir(); 
     329    p_libvlc->psz_configdir  = config_GetConfigDir( p_libvlc ); 
     330    p_libvlc->psz_datadir    = config_GetUserDataDir( p_libvlc ); 
     331    p_libvlc->psz_configfile = config_GetCustomConfigFile( p_libvlc ); 
    347332 
    348333    /* Check for plugins cache options */ 
     
    10681053 
    10691054    FREENULL( p_libvlc->psz_homedir ); 
    1070     FREENULL( p_libvlc->psz_userdir ); 
     1055    FREENULL( p_libvlc->psz_configdir ); 
     1056    FREENULL( p_libvlc->psz_datadir ); 
    10711057    FREENULL( p_libvlc->psz_configfile ); 
    10721058    FREENULL( p_libvlc->p_hotkeys ); 
  • src/modules/configuration.c

    r56bdc14 r16f32e1  
    8585int IsConfigStringType (int type) 
    8686{ 
    87     static const unsigned char config_types[] =  
     87    static const unsigned char config_types[] = 
    8888    { 
    8989        CONFIG_ITEM_STRING, CONFIG_ITEM_FILE, CONFIG_ITEM_MODULE, 
     
    9999static int IsConfigIntegerType (int type) 
    100100{ 
    101     static const unsigned char config_types[] =  
     101    static const unsigned char config_types[] = 
    102102    { 
    103103        CONFIG_ITEM_INTEGER, CONFIG_ITEM_KEY, CONFIG_ITEM_BOOL, 
     
    787787static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode ) 
    788788{ 
    789     static const char psz_subpath[] = DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE; 
    790     const char *psz_filename = p_obj->p_libvlc->psz_configfile; 
    791     const char *psz_homedir = p_obj->p_libvlc->psz_homedir; 
    792     size_t i_buflen = 0; 
     789    char *psz_filename = p_obj->p_libvlc->psz_configfile; 
    793790    FILE *p_stream; 
    794791 
    795     if( psz_filename == NULL ) 
    796     { 
    797         if( psz_homedir == NULL ) 
    798         { 
    799             msg_Err( p_obj, "no home directory defined" ); 
    800             return NULL; 
    801         } 
    802  
    803         i_buflen = strlen(psz_homedir) + sizeof(psz_subpath) + 1; 
    804     } 
    805  
    806     char buf[i_buflen]; 
    807     if( psz_filename == NULL ) 
    808     { 
    809         sprintf( buf, "%s%s", psz_homedir, psz_subpath ); 
    810         psz_filename = buf; 
     792    if( !psz_filename ) 
     793    { 
     794        psz_filename = config_GetConfigFile( p_obj->p_libvlc ); 
    811795    } 
    812796 
    813797    msg_Dbg( p_obj, "opening config file (%s)", psz_filename ); 
     798 
    814799    p_stream = utf8_fopen( psz_filename, mode ); 
    815800    if( p_stream == NULL && errno != ENOENT ) 
    816         msg_Err( p_obj, "cannot open config file (%s): %s", psz_filename, strerror(errno) ); 
     801    { 
     802        msg_Err( p_obj, "cannot open config file (%s): %s", 
     803                 psz_filename, strerror(errno) ); 
     804 
     805    } 
     806#if !( defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS) ) 
     807    else if( p_stream == NULL && errno == ENOENT && mode[0] == 'r' ) 
     808    { 
     809        /* This is the fallback for pre XDG Base Directory 
     810         * Specification configs */ 
     811        char *psz_old; 
     812        if( asprintf( &psz_old, "%s" DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE, 
     813                  p_obj->p_libvlc->psz_homedir ) != -1 ) 
     814        { 
     815            p_stream = utf8_fopen( psz_old, mode ); 
     816            if( p_stream ) 
     817            { 
     818                /* Old config file found. We want to write it at the 
     819                 * new location now. */ 
     820                msg_Info( p_obj->p_libvlc, "Found old config file at %s. " 
     821                          "VLC will now use %s.", psz_old, psz_filename ); 
     822                char *psz_readme; 
     823                if( asprintf(&psz_readme,"%s"DIR_SEP CONFIG_DIR DIR_SEP"README", 
     824                              p_obj->p_libvlc->psz_homedir ) != -1 ) 
     825                { 
     826                    FILE *p_readme = utf8_fopen( psz_readme, "wt" ); 
     827                    if( p_readme ) 
     828                    { 
     829                        fputs( "The VLC media player configuration folder has " 
     830                               "moved to comply with the XDG Base " 
     831                               "Directory Specification version 0.6. Your " 
     832                               "configuration has been copied to the new " 
     833                               "location (", p_readme ); 
     834                        fputs( p_obj->p_libvlc->psz_configdir, p_readme ); 
     835                        fputs( "). You can delete this directory and " 
     836                               "all its contents.", p_readme ); 
     837                        fclose( p_readme ); 
     838                    } 
     839                    free( psz_readme ); 
     840                } 
     841            } 
     842            free( psz_old ); 
     843        } 
     844    } 
     845#endif 
     846    else if( p_stream != NULL ) 
     847    { 
     848        p_obj->p_libvlc->psz_configfile = psz_filename; 
     849    } 
    817850 
    818851    return p_stream; 
     
    10181051    if( utf8_mkdir( psz_dirname ) && ( errno != EEXIST ) ) 
    10191052    { 
     1053        if( errno == ENOENT ) 
     1054        { 
     1055            /* Let's try to create the parent directory */ 
     1056            char *psz_parent = strdup( psz_dirname ); 
     1057            char *psz_end = strrchr( psz_parent, DIR_SEP_CHAR ); 
     1058            if( psz_end && psz_end != psz_parent ) 
     1059            { 
     1060                *psz_end = '\0'; 
     1061                if( config_CreateDir( p_this, psz_parent ) == 0 ) 
     1062                { 
     1063                    if( !utf8_mkdir( psz_dirname ) ) 
     1064                    { 
     1065                        free( psz_parent ); 
     1066                        return 0; 
     1067                    } 
     1068                } 
     1069            } 
     1070            free( psz_parent ); 
     1071        } 
    10201072        msg_Err( p_this, "could not create %s (%s)", 
    10211073                 psz_dirname, strerror(errno) ); 
     
    10601112    vlc_mutex_lock( &p_this->p_libvlc->config_lock ); 
    10611113 
    1062     if (p_this->p_libvlc->psz_configfile == NULL
    1063     { 
    1064         const char *psz_homedir = p_this->p_libvlc->psz_homedir; 
    1065         if( !psz_homedir ) 
    1066         { 
    1067             msg_Err( p_this, "no home directory defined" ); 
     1114    if( p_this->p_libvlc->psz_configfile == NULL
     1115    { 
     1116        const char *psz_configdir = p_this->p_libvlc->psz_configdir; 
     1117        if( !psz_configdir ) /* XXX: This should never happen */ 
     1118        { 
     1119            msg_Err( p_this, "no configuration directory defined" ); 
    10681120            vlc_mutex_unlock( &p_this->p_libvlc->config_lock ); 
    10691121            return -1; 
    10701122        } 
    10711123 
    1072         char dirname[strlen (psz_homedir) + sizeof (DIR_SEP CONFIG_DIR)]; 
    1073         sprintf (dirname, "%s" DIR_SEP CONFIG_DIR, psz_homedir); 
    1074         config_CreateDir (p_this, dirname); 
    1075     } 
    1076  
    1077     file = config_OpenConfigFile (p_this, "rt"); 
    1078     if (file != NULL) 
     1124        config_CreateDir( p_this, psz_configdir ); 
     1125    } 
     1126 
     1127    file = config_OpenConfigFile( p_this, "rt" ); 
     1128    if( file != NULL ) 
    10791129    { 
    10801130        /* look for file size */ 
     
    15791629                        return -1; 
    15801630                    } 
    1581    
     1631 
    15821632                    psz_name = (char *)p_conf->psz_current; 
    15831633                    p_conf = config_FindConfig( p_this, psz_name ); 
     
    18161866} 
    18171867 
     1868/** 
     1869 * Get the user's home directory 
     1870 */ 
    18181871char *config_GetHomeDir( void ) 
    18191872{ 
     1873    return GetDir( VLC_FALSE ); 
     1874} 
     1875 
     1876/** 
     1877 * Get the user's main data and config directory: 
     1878 *   - on windows that's the App Data directory; 
     1879 *   - on other OSes it's the same as the home directory. 
     1880 */ 
     1881char *config_GetUserDir( void ); 
     1882char *config_GetUserDir( void ) 
     1883{ 
    18201884    return GetDir( VLC_TRUE ); 
    18211885} 
    18221886 
    1823 char *config_GetUserDir( void ) 
    1824 
    1825     return GetDir( VLC_FALSE ); 
    1826 
    1827  
     1887/** 
     1888 * Get the user's VLC configuration directory 
     1889 */ 
     1890char *config_GetConfigDir( libvlc_int_t *p_libvlc ) 
     1891
     1892    char *psz_dir; 
     1893#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS) 
     1894    char *psz_parent = config_GetUserDir(); 
     1895    if( !psz_parent ) psz_parent = p_libvlc->psz_homedir; 
     1896    if( asprintf( &psz_dir, "%s" DIR_SEP CONFIG_DIR, psz_parent ) == -1 ) 
     1897        return NULL; 
     1898    return psz_dir; 
     1899#else 
     1900    /* XDG Base Directory Specification - Version 0.6 */ 
     1901    char *psz_env = getenv( "XDG_CONFIG_HOME" ); 
     1902    if( psz_env ) 
     1903    { 
     1904        if( asprintf( &psz_dir, "%s/vlc", psz_env ) == -1 ) 
     1905            return NULL; 
     1906        return psz_dir; 
     1907    } 
     1908    psz_env = getenv( "HOME" ); 
     1909    if( !psz_env ) psz_env = p_libvlc->psz_homedir; /* not part of XDG spec but we want a sensible fallback */ 
     1910    if( asprintf( &psz_dir, "%s/.config/vlc", psz_env ) == -1 ) 
     1911        return NULL; 
     1912    return psz_dir; 
     1913#endif 
     1914
     1915 
     1916/** 
     1917 * Get the user's VLC data and cache directory 
     1918 * (used for stuff like the modules cache, the album art cache, ...) 
     1919 */ 
     1920char *config_GetUserDataDir( libvlc_int_t *p_libvlc ) 
     1921
     1922    char *psz_dir; 
     1923#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS) 
     1924    char *psz_parent = config_GetUserDir(); 
     1925    if( !psz_parent ) psz_parent = p_libvlc->psz_homedir; 
     1926    if( asprintf( &psz_dir, "%s" DIR_SEP CONFIG_DIR, psz_parent ) == -1 ) 
     1927        return NULL; 
     1928    return psz_dir; 
     1929#else 
     1930    /* XDG Base Directory Specification - Version 0.6 */ 
     1931    char *psz_env = getenv( "XDG_DATA_HOME" ); 
     1932    if( psz_env ) 
     1933    { 
     1934        if( asprintf( &psz_dir, "%s/vlc", psz_env ) == -1 ) 
     1935            return NULL; 
     1936        return psz_dir; 
     1937    } 
     1938    psz_env = getenv( "HOME" ); 
     1939    if( !psz_env ) psz_env = p_libvlc->psz_homedir; /* not part of XDG spec but we want a sensible fallback */ 
     1940    if( asprintf( &psz_dir, "%s/.local/share/vlc", psz_env ) == -1 ) 
     1941        return NULL; 
     1942    return psz_dir; 
     1943#endif 
     1944
     1945 
     1946/** 
     1947 * Get the user's configuration file 
     1948 */ 
     1949char *config_GetConfigFile( libvlc_int_t *p_libvlc ) 
     1950
     1951    char *psz_configfile; 
     1952    if( asprintf( &psz_configfile, "%s" DIR_SEP CONFIG_FILE, 
     1953                  p_libvlc->psz_configdir ) == -1 ) 
     1954        return NULL; 
     1955    return psz_configfile; 
     1956
     1957 
     1958/** 
     1959 * Get the user's configuration file when given with the --config option 
     1960 */ 
     1961char *config_GetCustomConfigFile( libvlc_int_t *p_libvlc ) 
     1962
     1963    char *psz_configfile = config_GetPsz( p_libvlc, "config" ); 
     1964    if( psz_configfile != NULL ) 
     1965    { 
     1966        if( psz_configfile[0] == '~' && psz_configfile[1] == '/' ) 
     1967        { 
     1968            /* This is incomplete: we should also support the ~cmassiot/ syntax */ 
     1969            char *psz_buf; 
     1970            if( asprintf( &psz_buf, "%s/%s", p_libvlc->psz_homedir, 
     1971                          psz_configfile + 2 ) == -1 ) 
     1972            { 
     1973                free( psz_configfile ); 
     1974                return NULL; 
     1975            } 
     1976            free( psz_configfile ); 
     1977            psz_configfile = psz_buf; 
     1978        } 
     1979    } 
     1980    return psz_configfile; 
     1981
    18281982 
    18291983static int ConfigStringToKey( const char *psz_key ) 
  • src/modules/configuration.h

    rb8802c3 r16f32e1  
    3434 
    3535void config_SetCallbacks( module_config_t *, module_config_t *, size_t ); 
    36 void config_UnsetCallbacks ( module_config_t *, size_t ); 
     36void config_UnsetCallbacks( module_config_t *, size_t ); 
    3737 
    3838#define config_LoadCmdLine(a,b,c,d) __config_LoadCmdLine(VLC_OBJECT(a),b,c,d) 
    3939#define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b) 
    4040 
    41 int   __config_LoadCmdLine  ( vlc_object_t *, int *, char *[], vlc_bool_t ); 
    42 char *   config_GetHomeDir     ( void ); 
    43 char *   config_GetUserDir     ( void ); 
    44 int    __config_LoadConfigFile ( vlc_object_t *, const char * ); 
     41int __config_LoadCmdLine   ( vlc_object_t *, int *, char *[], vlc_bool_t ); 
     42char *config_GetHomeDir    ( void ); 
     43char *config_GetConfigDir  ( libvlc_int_t * ); 
     44char *config_GetUserDataDir( libvlc_int_t * ); 
     45char *config_GetConfigFile ( libvlc_int_t * ); 
     46char *config_GetCustomConfigFile( libvlc_int_t * ); 
     47int __config_LoadConfigFile( vlc_object_t *, const char * ); 
    4548 
    46 int IsConfigStringType (int type); 
     49int IsConfigStringType( int type ); 
     50 
     51/* The configuration file and directory */ 
     52#if defined (SYS_BEOS) 
     53#  define CONFIG_DIR                    "config/settings/VideoLAN Client" 
     54#elif defined (__APPLE__) 
     55#  define CONFIG_DIR                    "Library/Preferences/VLC" 
     56#elif defined( WIN32 ) || defined( UNDER_CE ) 
     57#  define CONFIG_DIR                    "vlc" 
     58#else 
     59#  define CONFIG_DIR                    ".vlc" 
     60#endif 
     61#define CONFIG_FILE                     "vlcrc" 
     62#define PLUGINSCACHE_DIR                "cache" 
    4763 
    4864# ifdef __cplusplus 
  • src/modules/modules.c

    rf73343d r16f32e1  
    16661666static void CacheLoad( vlc_object_t *p_this ) 
    16671667{ 
    1668     char *psz_filename, *psz_homedir; 
     1668    char *psz_filename, *psz_datadir; 
    16691669    FILE *file; 
    16701670    int i, j, i_size, i_read; 
     
    16761676    libvlc_global_data_t *p_libvlc_global = vlc_global(); 
    16771677 
    1678     psz_homedir = p_this->p_libvlc->psz_homedir; 
    1679     if( !psz_homedir ) 
    1680     { 
    1681         msg_Err( p_this, "psz_homedir is null" ); 
    1682         return; 
    1683     } 
    1684  
    1685     i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s"DIR_SEP"%s"
    1686             psz_homedir, CONFIG_DIR, PLUGINSCACHE_DIR, CacheName() ); 
     1678    psz_datadir = p_this->p_libvlc->psz_datadir; 
     1679    if( !psz_datadir ) /* XXX: this should never happen */ 
     1680    { 
     1681        msg_Err( p_this, "Unable to get cache directory" ); 
     1682        return; 
     1683    } 
     1684 
     1685    i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s"
     1686            psz_datadir, PLUGINSCACHE_DIR, CacheName() ); 
    16871687    if( i_size <= 0 ) 
    16881688    { 
     
    20232023        "#   http://www.brynosaurus.com/cachedir/\r\n"; 
    20242024 
    2025     char *psz_filename, *psz_homedir; 
     2025    char *psz_filename, *psz_datadir; 
    20262026    FILE *file; 
    20272027    int i, j, i_cache; 
     
    20302030    libvlc_global_data_t *p_libvlc_global = vlc_global(); 
    20312031 
    2032     psz_homedir = p_this->p_libvlc->psz_homedir; 
    2033     if( !psz_homedir ) 
    2034     { 
    2035         msg_Err( p_this, "psz_homedir is null" ); 
    2036         return; 
    2037     } 
     2032    psz_datadir = p_this->p_libvlc->psz_datadir; 
     2033    if( !psz_datadir ) /* XXX: this should never happen */ 
     2034    { 
     2035        msg_Err( p_this, "Unable to get cache directory" ); 
     2036        return; 
     2037    } 
     2038 
    20382039    psz_filename = 
    2039        (char *)malloc( sizeof(DIR_SEP CONFIG_DIR DIR_SEP PLUGINSCACHE_DIR DIR_SEP ) + 
    2040                        strlen(psz_homedir) + strlen(CacheName()) ); 
     2040       (char *)malloc( sizeof(DIR_SEP PLUGINSCACHE_DIR DIR_SEP ) + 
     2041                       strlen(psz_datadir) + strlen(CacheName()) ); 
    20412042 
    20422043    if( !psz_filename ) 
     
    20462047    } 
    20472048 
    2048     sprintf( psz_filename, "%s"DIR_SEP"%s", psz_homedir, CONFIG_DIR ); 
     2049    sprintf( psz_filename, "%s", psz_datadir ); 
    20492050 
    20502051    config_CreateDir( p_this, psz_filename ); 
     
    20632064    } 
    20642065 
    2065     sprintf( psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s"DIR_SEP"%s", psz_homedir, CONFIG_DIR
     2066    sprintf( psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s", psz_datadir
    20662067             PLUGINSCACHE_DIR, CacheName() ); 
    20672068 
  • src/playlist/loadsave.c

    r92ebfe8 r16f32e1  
    9090int playlist_MLLoad( playlist_t *p_playlist ) 
    9191{ 
    92     const char *psz_homedir = p_playlist->p_libvlc->psz_homedir; 
     92    const char *psz_datadir = p_playlist->p_libvlc->psz_datadir; 
    9393    char *psz_uri = NULL; 
    9494    input_item_t *p_input; 
    9595 
    9696    if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS; 
    97     if( !psz_homedir ) 
     97    if( !psz_datadir ) /* XXX: This should never happen */ 
    9898    { 
    99         msg_Err( p_playlist, "no home directory, cannot load media library") ; 
     99        msg_Err( p_playlist, "no data directory, cannot load media library") ; 
    100100        return VLC_EGENERIC; 
    101101    } 
    102102 
    103     if( asprintf( &psz_uri, "%s" DIR_SEP CONFIG_DIR DIR_SEP 
    104                         "ml.xsp", psz_homedir ) == -1 ) 
     103    if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xsp", psz_datadir ) == -1 ) 
    105104    { 
    106105        psz_uri = NULL; 
     
    116115    free( psz_uri ); 
    117116 
    118     if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP CONFIG_DIR DIR_SEP 
    119                         "ml.xsp", psz_homedir ) == -1 ) 
     117    if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp", 
     118                  psz_datadir ) == -1 ) 
    120119    { 
    121120        psz_uri = NULL; 
     
    147146int playlist_MLDump( playlist_t *p_playlist ) 
    148147{ 
    149     char *psz_homedir = p_playlist->p_libvlc->psz_homedir; 
     148    char *psz_datadir = p_playlist->p_libvlc->psz_datadir; 
    150149    if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS; 
    151     if( !psz_homedir ) 
     150    if( !psz_datadir ) /* XXX: This should never happen */ 
    152151    { 
    153         msg_Err( p_playlist, "no home directory, cannot save media library") ; 
     152        msg_Err( p_playlist, "no data directory, cannot save media library") ; 
    154153        return VLC_EGENERIC; 
    155154    } 
    156155 
    157     char psz_dirname[ strlen( psz_homedir ) 
    158                       + sizeof( DIR_SEP CONFIG_DIR DIR_SEP "ml.xsl")]; 
    159     sprintf( psz_dirname, "%s" DIR_SEP CONFIG_DIR, psz_homedir ); 
     156    char psz_dirname[ strlen( psz_datadir ) 
     157                      + sizeof( DIR_SEP "ml.xsl")]; 
     158    sprintf( psz_dirname, "%s", psz_datadir ); 
    160159    if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) ) 
    161160    { 
     
    164163 
    165164    strcat( psz_dirname, DIR_SEP "ml.xsp" ); 
    166      
     165 
    167166    stats_TimerStart( p_playlist, "ML Dump", STATS_TIMER_ML_DUMP ); 
    168167    playlist_Export( p_playlist, psz_dirname, p_playlist->p_ml_category, 
  • src/video_output/vout_intf.c

    rf3b32f6 r16f32e1  
    620620        if( p_mypicturesdir == NULL ) 
    621621        { 
    622             if( asprintf( &val.psz_string, "%s\\" CONFIG_DIR
     622            if( asprintf( &val.psz_string, "%s"
    623623                          p_vout->p_libvlc->psz_homedir ) == -1 ) 
    624624                val.psz_string = NULL; 
     
    633633 
    634634#else 
    635     if( !val.psz_string && p_vout->p_libvlc->psz_homedir ) 
    636     { 
    637         if( asprintf( &val.psz_string, "%s/" CONFIG_DIR, 
    638                       p_vout->p_libvlc->psz_homedir ) == -1 ) 
     635    /* XXX: This saves in the data directory. Shouldn't we try saving 
     636     *      to psz_homedir/Desktop or something nicer ? */ 
     637    if( !val.psz_string && p_vout->p_libvlc->psz_datadir ) 
     638    { 
     639        if( asprintf( &val.psz_string, "%s", 
     640                      p_vout->p_libvlc->psz_datadir ) == -1 ) 
    639641            val.psz_string = NULL; 
    640642    }