Debian Codegraph @

src/file/dirs_darwin.c

raw
1 /*
2 * This file is part of libbluray
3 * Copyright (C) 2012 Konstantin Pavlov
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see
17 * <http://www.gnu.org/licenses/>.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #endif
23
24 #include "dirs.h"
25
26 #include <CoreFoundation/CoreFoundation.h>
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31
32 #include "util/strutl.h"
33 #include "util/logging.h"
34
35 #define USER_CFG_DIR "Library/Preferences"
36 #define USER_CACHE_DIR "Library/Caches"
37 #define USER_DATA_DIR "Library"
38 #define SYSTEM_CFG_DIR "/Library/Preferences"
39
40
41 char *file_get_config_home(void)
42 {
43 const char *user_home = getenv("HOME");
44 if (user_home && *user_home) {
45 return str_printf("%s/%s", user_home, USER_CFG_DIR);
46 }
47
48 BD_DEBUG(DBG_FILE, "Can't find user home directory ($HOME) !\n");
49 return NULL;
50 }
51
52 char *file_get_data_home(void)
53 {
54 const char *user_home = getenv("HOME");
55 if (user_home && *user_home) {
56 return str_printf("%s/%s", user_home, USER_DATA_DIR);
57 }
58
59 BD_DEBUG(DBG_FILE, "Can't find user home directory ($HOME) !\n");
60 return NULL;
61 }
62
63 char *file_get_cache_home(void)
64 {
65 const char *user_home = getenv("HOME");
66 if (user_home && *user_home) {
67 return str_printf("%s/%s", user_home, USER_CACHE_DIR);
68 }
69
70 BD_DEBUG(DBG_FILE, "Can't find user home directory ($HOME) !\n");
71 return NULL;
72 }
73
74 const char *file_get_config_system(const char *dir)
75 {
76 if (!dir) {
77 // first call
78 return SYSTEM_CFG_DIR;
79 }
80
81 return NULL;
82 }