xref: /haiku/headers/os/storage/FindDirectory.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2002-2015, Haiku Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _FIND_DIRECTORY_H
6 #define _FIND_DIRECTORY_H
7 
8 
9 #include <image.h>
10 
11 
12 typedef enum {
13 	/* Per volume directories */
14 	B_DESKTOP_DIRECTORY					= 0,
15 	B_TRASH_DIRECTORY,
16 
17 	/* System directories */
18 	B_SYSTEM_DIRECTORY					= 1000,
19 	B_SYSTEM_ADDONS_DIRECTORY			= 1002,
20 	B_SYSTEM_BOOT_DIRECTORY,
21 	B_SYSTEM_FONTS_DIRECTORY,
22 	B_SYSTEM_LIB_DIRECTORY,
23 	B_SYSTEM_SERVERS_DIRECTORY,
24 	B_SYSTEM_APPS_DIRECTORY,
25 	B_SYSTEM_BIN_DIRECTORY,
26 	B_SYSTEM_DOCUMENTATION_DIRECTORY	= 1010,
27 	B_SYSTEM_PREFERENCES_DIRECTORY,
28 	B_SYSTEM_TRANSLATORS_DIRECTORY,
29 	B_SYSTEM_MEDIA_NODES_DIRECTORY,
30 	B_SYSTEM_SOUNDS_DIRECTORY,
31 	B_SYSTEM_DATA_DIRECTORY,
32 	B_SYSTEM_DEVELOP_DIRECTORY,
33 	B_SYSTEM_PACKAGES_DIRECTORY,
34 	B_SYSTEM_HEADERS_DIRECTORY,
35 
36 	B_SYSTEM_ETC_DIRECTORY				= 2008,
37 	B_SYSTEM_SETTINGS_DIRECTORY			= 2010,
38 	B_SYSTEM_LOG_DIRECTORY				= 2012,
39 	B_SYSTEM_SPOOL_DIRECTORY,
40 	B_SYSTEM_TEMP_DIRECTORY,
41 	B_SYSTEM_VAR_DIRECTORY,
42 	B_SYSTEM_CACHE_DIRECTORY			= 2020,
43 
44 	B_SYSTEM_NONPACKAGED_DIRECTORY		= 2023,
45 	B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
46 	B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY,
47 	B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY,
48 	B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
49 	B_SYSTEM_NONPACKAGED_DATA_DIRECTORY,
50 	B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY,
51 	B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY,
52 	B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY,
53 	B_SYSTEM_NONPACKAGED_LIB_DIRECTORY,
54 	B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY,
55 	B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY,
56 
57 	/* User directories. These are interpreted in the context
58 	   of the user making the find_directory call. */
59 	B_USER_DIRECTORY					= 3000,
60 	B_USER_CONFIG_DIRECTORY,
61 	B_USER_ADDONS_DIRECTORY,
62 	B_USER_BOOT_DIRECTORY,
63 	B_USER_FONTS_DIRECTORY,
64 	B_USER_LIB_DIRECTORY,
65 	B_USER_SETTINGS_DIRECTORY,
66 	B_USER_DESKBAR_DIRECTORY,
67 	B_USER_PRINTERS_DIRECTORY,
68 	B_USER_TRANSLATORS_DIRECTORY,
69 	B_USER_MEDIA_NODES_DIRECTORY,
70 	B_USER_SOUNDS_DIRECTORY,
71 	B_USER_DATA_DIRECTORY,
72 	B_USER_CACHE_DIRECTORY,
73 	B_USER_PACKAGES_DIRECTORY,
74 	B_USER_HEADERS_DIRECTORY,
75 	B_USER_NONPACKAGED_DIRECTORY,
76 	B_USER_NONPACKAGED_ADDONS_DIRECTORY,
77 	B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY,
78 	B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY,
79 	B_USER_NONPACKAGED_BIN_DIRECTORY,
80 	B_USER_NONPACKAGED_DATA_DIRECTORY,
81 	B_USER_NONPACKAGED_FONTS_DIRECTORY,
82 	B_USER_NONPACKAGED_SOUNDS_DIRECTORY,
83 	B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY,
84 	B_USER_NONPACKAGED_LIB_DIRECTORY,
85 	B_USER_NONPACKAGED_HEADERS_DIRECTORY,
86 	B_USER_NONPACKAGED_DEVELOP_DIRECTORY,
87 	B_USER_DEVELOP_DIRECTORY,
88 	B_USER_DOCUMENTATION_DIRECTORY,
89 	B_USER_SERVERS_DIRECTORY,
90 	B_USER_APPS_DIRECTORY,
91 	B_USER_BIN_DIRECTORY,
92 	B_USER_PREFERENCES_DIRECTORY,
93 	B_USER_ETC_DIRECTORY,
94 	B_USER_LOG_DIRECTORY,
95 	B_USER_SPOOL_DIRECTORY,
96 	B_USER_VAR_DIRECTORY,
97 
98 	/* Global directories. */
99 	B_APPS_DIRECTORY					= 4000,
100 	B_PREFERENCES_DIRECTORY,
101 	B_UTILITIES_DIRECTORY,
102 	B_PACKAGE_LINKS_DIRECTORY,
103 
104 	/* Obsolete: Legacy BeOS definition to be phased out */
105 	B_BEOS_DIRECTORY					= 1000,
106 	B_BEOS_SYSTEM_DIRECTORY,
107 	B_BEOS_ADDONS_DIRECTORY,
108 	B_BEOS_BOOT_DIRECTORY,
109 	B_BEOS_FONTS_DIRECTORY,
110 	B_BEOS_LIB_DIRECTORY,
111 	B_BEOS_SERVERS_DIRECTORY,
112 	B_BEOS_APPS_DIRECTORY,
113 	B_BEOS_BIN_DIRECTORY,
114 	B_BEOS_ETC_DIRECTORY,
115 	B_BEOS_DOCUMENTATION_DIRECTORY,
116 	B_BEOS_PREFERENCES_DIRECTORY,
117 	B_BEOS_TRANSLATORS_DIRECTORY,
118 	B_BEOS_MEDIA_NODES_DIRECTORY,
119 	B_BEOS_SOUNDS_DIRECTORY,
120 } directory_which;
121 
122 
123 /* find_path[s]() flags */
124 enum {
125 	B_FIND_PATH_CREATE_DIRECTORY			= 0x0001,
126 	B_FIND_PATH_CREATE_PARENT_DIRECTORY		= 0x0002,
127 	B_FIND_PATH_EXISTING_ONLY				= 0x0004,
128 
129 	B_FIND_PATHS_SYSTEM_ONLY				= 0x0010,
130 	B_FIND_PATHS_USER_ONLY					= 0x0020,
131 };
132 
133 
134 typedef enum path_base_directory {
135 	B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY,
136 	B_FIND_PATH_ADD_ONS_DIRECTORY,
137 	B_FIND_PATH_APPS_DIRECTORY,
138 	B_FIND_PATH_BIN_DIRECTORY,
139 	B_FIND_PATH_BOOT_DIRECTORY,
140 	B_FIND_PATH_CACHE_DIRECTORY,
141 	B_FIND_PATH_DATA_DIRECTORY,
142 	B_FIND_PATH_DEVELOP_DIRECTORY,
143 	B_FIND_PATH_DEVELOP_LIB_DIRECTORY,
144 	B_FIND_PATH_DOCUMENTATION_DIRECTORY,
145 	B_FIND_PATH_ETC_DIRECTORY,
146 	B_FIND_PATH_FONTS_DIRECTORY,
147 	B_FIND_PATH_HEADERS_DIRECTORY,
148 	B_FIND_PATH_LIB_DIRECTORY,
149 	B_FIND_PATH_LOG_DIRECTORY,
150 	B_FIND_PATH_MEDIA_NODES_DIRECTORY,
151 	B_FIND_PATH_PACKAGES_DIRECTORY,
152 	B_FIND_PATH_PREFERENCES_DIRECTORY,
153 	B_FIND_PATH_SERVERS_DIRECTORY,
154 	B_FIND_PATH_SETTINGS_DIRECTORY,
155 	B_FIND_PATH_SOUNDS_DIRECTORY,
156 	B_FIND_PATH_SPOOL_DIRECTORY,
157 	B_FIND_PATH_TRANSLATORS_DIRECTORY,
158 	B_FIND_PATH_VAR_DIRECTORY,
159 
160 	/* find_path() only */
161 	B_FIND_PATH_IMAGE_PATH			= 1000,
162 	B_FIND_PATH_PACKAGE_PATH,
163 } path_base_directory;
164 
165 
166 #ifdef __cplusplus
167 extern "C" {
168 #endif
169 
170 /* C interface */
171 
172 status_t find_directory(directory_which which, dev_t volume, bool createIt,
173 	char* pathString, int32 length);
174 
175 status_t find_path(const void* codePointer, path_base_directory baseDirectory,
176 	const char* subPath, char* pathBuffer, size_t bufferSize);
177 
178 status_t find_path_etc(const void* codePointer, const char* dependency,
179 	const char* architecture, path_base_directory baseDirectory,
180 	const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize);
181 
182 status_t find_path_for_path(const char* path, path_base_directory baseDirectory,
183 	const char* subPath, char* pathBuffer, size_t bufferSize);
184 
185 status_t find_path_for_path_etc(const char* path, const char* dependency,
186 	const char* architecture, path_base_directory baseDirectory,
187 	const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize);
188 
189 status_t find_paths(path_base_directory baseDirectory, const char* subPath,
190 	char*** _paths, size_t* _pathCount);
191 
192 status_t find_paths_etc(const char* architecture,
193 	path_base_directory baseDirectory, const char* subPath, uint32 flags,
194 	char*** _paths, size_t* _pathCount);
195 
196 
197 #ifdef __cplusplus
198 }
199 
200 /* C++ interface */
201 
202 class BVolume;
203 class BPath;
204 
205 
206 status_t find_directory(directory_which which, BPath* path,
207 	bool createIt = false, BVolume* volume = NULL);
208 
209 
210 #endif	/* __cplusplus */
211 
212 #endif	/* _FIND_DIRECTORY_H */
213