]> git.sesse.net Git - vlc/blob - src/config/dirs_macos.c
Cleanup
[vlc] / src / config / dirs_macos.c
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
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *          Felix Paul Kühne <fkuehne at videolan dot org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc_common.h>
30
31 #include "../libvlc.h"
32 #include <vlc_charset.h>
33 #include <vlc_configuration.h>
34
35
36 const char *config_GetConfDir( void )
37 {
38     return config_GetUserDir (VLC_CONFIG_DIR);
39 }
40
41 const char *config_GetDataDir (void)
42 {
43     return config_GetUserDir (VLC_DATA_DIR);
44 }
45
46 static char *config_GetHomeDir (void)
47 {
48     const char *home = getenv ("HOME");
49
50     if (home == NULL)
51         home = "/tmp";
52
53     return FromLocaleDup (home);
54 }
55
56 char *config_GetUserDir (vlc_userdir_t type)
57 {
58     char *psz_dir;
59     const char *psz_parent = config_GetHomeDir ();
60     const char *psz_path;
61
62     switch (type)
63     {
64         case VLC_CONFIG_DIR:
65             psz_path = "%s/Library/Preferences/VLC";
66             break;
67         case VLC_TEMPLATES_DIR:
68         case VLC_DATA_DIR:
69             psz_path = "%s/Library/Application Support/VLC";
70             break;
71         case VLC_DESKTOP_DIR:
72             psz_path = "%s/Desktop";
73             break;
74         case VLC_DOWNLOAD_DIR:
75             psz_path = "%s/Downloads";
76             break;
77         case VLC_DOCUMENTS_DIR:
78             psz_path = "%s/Documents";
79             break;
80         case VLC_MUSIC_DIR:
81             psz_path = "%s/Music";
82             break;
83         case VLC_PICTURES_DIR:
84             psz_path = "%s/Pictures";
85             break;
86         case VLC_VIDEOS_DIR:
87             psz_path = "%s/Movies";
88             break;
89         case VLC_PUBLICSHARE_DIR:
90             psz_path = "%s/Public";
91             break;
92         case VLC_CACHE_DIR:
93             psz_path = "%s/Library/Caches/org.videolan.vlc";
94             break;
95         case VLC_HOME_DIR:
96         default:
97             psz_path = "%s";
98     }
99     if( asprintf( &psz_dir, psz_path, psz_parent ) == -1 )
100         psz_dir = NULL;
101     return psz_dir;
102 }