1 /*****************************************************************************
2 * dirs_macos.c: Mac OS X directories configuration
3 *****************************************************************************
4 * Copyright (C) 2001-2009 the VideoLAN team
5 * Copyright © 2007-2009 Rémi Denis-Courmont
7 * Authors: Gildas Bazin <gbazin@videolan.org>
8 * Felix Paul Kühne <fkuehne at videolan dot org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_common.h>
31 #include "../libvlc.h"
32 #include <vlc_charset.h>
33 #include <vlc_configuration.h>
35 static char *configdir = NULL;
36 static char *datadir = NULL;
38 static pthread_once_t once = PTHREAD_ONCE_INIT;
40 static void init_dirs( void )
42 configdir = config_GetUserDir(VLC_CONFIG_DIR);
43 datadir = config_GetUserDir(VLC_DATA_DIR);
46 const char *config_GetConfDir( void )
48 pthread_once(&once, init_dirs);
52 const char *config_GetDataDir (void)
54 pthread_once(&once, init_dirs);
58 static char *config_GetHomeDir (void)
60 const char *home = getenv ("HOME");
65 return FromLocaleDup (home);
68 char *config_GetUserDir (vlc_userdir_t type)
71 char *psz_parent = config_GetHomeDir ();
77 psz_path = "%s/Library/Preferences/VLC";
79 case VLC_TEMPLATES_DIR:
81 psz_path = "%s/Library/Application Support/VLC";
84 psz_path = "%s/Desktop";
86 case VLC_DOWNLOAD_DIR:
87 psz_path = "%s/Downloads";
89 case VLC_DOCUMENTS_DIR:
90 psz_path = "%s/Documents";
93 psz_path = "%s/Music";
95 case VLC_PICTURES_DIR:
96 psz_path = "%s/Pictures";
99 psz_path = "%s/Movies";
101 case VLC_PUBLICSHARE_DIR:
102 psz_path = "%s/Public";
105 psz_path = "%s/Library/Caches/org.videolan.vlc";
111 if( asprintf( &psz_dir, psz_path, psz_parent ) == -1 )