xref: /haiku/headers/os/storage/FindDirectory.h (revision 60b39cd7416028e61e3d30bb3ba28bd3526e6001)
163c96ae5SAxel Dörfler /*
2986e4abcSIngo Weinhold  * Copyright 2002-2013, Haiku Inc. All Rights Reserved.
363c96ae5SAxel Dörfler  * Distributed under the terms of the MIT License.
452a38012Sejakowatz  */
582b75665STyler Dauwalder #ifndef _FIND_DIRECTORY_H
682b75665STyler Dauwalder #define _FIND_DIRECTORY_H
752a38012Sejakowatz 
863c96ae5SAxel Dörfler 
9986e4abcSIngo Weinhold #include <image.h>
1052a38012Sejakowatz 
1152a38012Sejakowatz 
1252a38012Sejakowatz typedef enum {
13e1f3108aSStephan Aßmus 	/* Per volume directories */
1452a38012Sejakowatz 	B_DESKTOP_DIRECTORY					= 0,
1552a38012Sejakowatz 	B_TRASH_DIRECTORY,
1652a38012Sejakowatz 
17e1f3108aSStephan Aßmus 	/* System directories */
18317bd7ddSAxel Dörfler 	B_SYSTEM_DIRECTORY					= 1000,
19317bd7ddSAxel Dörfler 	B_SYSTEM_ADDONS_DIRECTORY			= 1002,
20317bd7ddSAxel Dörfler 	B_SYSTEM_BOOT_DIRECTORY,
21317bd7ddSAxel Dörfler 	B_SYSTEM_FONTS_DIRECTORY,
22317bd7ddSAxel Dörfler 	B_SYSTEM_LIB_DIRECTORY,
23317bd7ddSAxel Dörfler  	B_SYSTEM_SERVERS_DIRECTORY,
24317bd7ddSAxel Dörfler 	B_SYSTEM_APPS_DIRECTORY,
25317bd7ddSAxel Dörfler 	B_SYSTEM_BIN_DIRECTORY,
26492dd892SAxel Dörfler 	B_SYSTEM_DOCUMENTATION_DIRECTORY	= 1010,
27317bd7ddSAxel Dörfler 	B_SYSTEM_PREFERENCES_DIRECTORY,
28317bd7ddSAxel Dörfler 	B_SYSTEM_TRANSLATORS_DIRECTORY,
29317bd7ddSAxel Dörfler 	B_SYSTEM_MEDIA_NODES_DIRECTORY,
30317bd7ddSAxel Dörfler 	B_SYSTEM_SOUNDS_DIRECTORY,
31317bd7ddSAxel Dörfler 	B_SYSTEM_DATA_DIRECTORY,
323dfd9cb9SOliver Tappe 	B_SYSTEM_DEVELOP_DIRECTORY,
333dfd9cb9SOliver Tappe 	B_SYSTEM_PACKAGES_DIRECTORY,
343dfd9cb9SOliver Tappe 	B_SYSTEM_HEADERS_DIRECTORY,
3552a38012Sejakowatz 
3638fa81bfSIngo Weinhold 	B_SYSTEM_ETC_DIRECTORY				= 2008,
3738fa81bfSIngo Weinhold 	B_SYSTEM_SETTINGS_DIRECTORY			= 2010,
3838fa81bfSIngo Weinhold 	B_SYSTEM_LOG_DIRECTORY				= 2012,
394b7e2196SIngo Weinhold 	B_SYSTEM_SPOOL_DIRECTORY,
404b7e2196SIngo Weinhold 	B_SYSTEM_TEMP_DIRECTORY,
414b7e2196SIngo Weinhold 	B_SYSTEM_VAR_DIRECTORY,
4238fa81bfSIngo Weinhold 	B_SYSTEM_CACHE_DIRECTORY			= 2020,
434b7e2196SIngo Weinhold 
4438fa81bfSIngo Weinhold 	B_SYSTEM_NONPACKAGED_DIRECTORY		= 2023,
454b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
464b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY,
474b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY,
484b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
494b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_DATA_DIRECTORY,
504b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY,
514b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY,
524b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY,
534b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_LIB_DIRECTORY,
544b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY,
554b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY,
5652a38012Sejakowatz 
57e1f3108aSStephan Aßmus 	/* User directories. These are interpreted in the context
58e1f3108aSStephan Aßmus 	   of the user making the find_directory call. */
5952a38012Sejakowatz 	B_USER_DIRECTORY					= 3000,
6052a38012Sejakowatz 	B_USER_CONFIG_DIRECTORY,
6152a38012Sejakowatz 	B_USER_ADDONS_DIRECTORY,
6252a38012Sejakowatz 	B_USER_BOOT_DIRECTORY,
6352a38012Sejakowatz 	B_USER_FONTS_DIRECTORY,
6452a38012Sejakowatz 	B_USER_LIB_DIRECTORY,
6552a38012Sejakowatz 	B_USER_SETTINGS_DIRECTORY,
6652a38012Sejakowatz 	B_USER_DESKBAR_DIRECTORY,
6752a38012Sejakowatz 	B_USER_PRINTERS_DIRECTORY,
6852a38012Sejakowatz 	B_USER_TRANSLATORS_DIRECTORY,
6952a38012Sejakowatz 	B_USER_MEDIA_NODES_DIRECTORY,
7052a38012Sejakowatz 	B_USER_SOUNDS_DIRECTORY,
7163c96ae5SAxel Dörfler 	B_USER_DATA_DIRECTORY,
7263c96ae5SAxel Dörfler 	B_USER_CACHE_DIRECTORY,
733dfd9cb9SOliver Tappe 	B_USER_PACKAGES_DIRECTORY,
743dfd9cb9SOliver Tappe 	B_USER_HEADERS_DIRECTORY,
753dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_DIRECTORY,
763dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_ADDONS_DIRECTORY,
773dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY,
783dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY,
793dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_BIN_DIRECTORY,
803dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_DATA_DIRECTORY,
813dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_FONTS_DIRECTORY,
823dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_SOUNDS_DIRECTORY,
833dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY,
843dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_LIB_DIRECTORY,
853dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_HEADERS_DIRECTORY,
863f85cfc1SIngo Weinhold 	B_USER_NONPACKAGED_DEVELOP_DIRECTORY,
873f85cfc1SIngo Weinhold 	B_USER_DEVELOP_DIRECTORY,
883f85cfc1SIngo Weinhold 	B_USER_DOCUMENTATION_DIRECTORY,
89635d2ac4SIngo Weinhold  	B_USER_SERVERS_DIRECTORY,
90635d2ac4SIngo Weinhold 	B_USER_APPS_DIRECTORY,
91635d2ac4SIngo Weinhold 	B_USER_BIN_DIRECTORY,
92635d2ac4SIngo Weinhold 	B_USER_PREFERENCES_DIRECTORY,
93635d2ac4SIngo Weinhold 	B_USER_ETC_DIRECTORY,
94635d2ac4SIngo Weinhold 	B_USER_LOG_DIRECTORY,
95635d2ac4SIngo Weinhold 	B_USER_SPOOL_DIRECTORY,
96635d2ac4SIngo Weinhold 	B_USER_VAR_DIRECTORY,
9752a38012Sejakowatz 
98e1f3108aSStephan Aßmus 	/* Global directories. */
9952a38012Sejakowatz 	B_APPS_DIRECTORY					= 4000,
10052a38012Sejakowatz 	B_PREFERENCES_DIRECTORY,
101317bd7ddSAxel Dörfler 	B_UTILITIES_DIRECTORY,
1023dfd9cb9SOliver Tappe 	B_PACKAGE_LINKS_DIRECTORY,
10352a38012Sejakowatz 
104317bd7ddSAxel Dörfler 	/* Obsolete: Legacy BeOS definition to be phased out */
105317bd7ddSAxel Dörfler 	B_BEOS_DIRECTORY					= 1000,
106317bd7ddSAxel Dörfler 	B_BEOS_SYSTEM_DIRECTORY,
107317bd7ddSAxel Dörfler 	B_BEOS_ADDONS_DIRECTORY,
108317bd7ddSAxel Dörfler 	B_BEOS_BOOT_DIRECTORY,
109317bd7ddSAxel Dörfler 	B_BEOS_FONTS_DIRECTORY,
110317bd7ddSAxel Dörfler 	B_BEOS_LIB_DIRECTORY,
111317bd7ddSAxel Dörfler  	B_BEOS_SERVERS_DIRECTORY,
112317bd7ddSAxel Dörfler 	B_BEOS_APPS_DIRECTORY,
113317bd7ddSAxel Dörfler 	B_BEOS_BIN_DIRECTORY,
114317bd7ddSAxel Dörfler 	B_BEOS_ETC_DIRECTORY,
115317bd7ddSAxel Dörfler 	B_BEOS_DOCUMENTATION_DIRECTORY,
116317bd7ddSAxel Dörfler 	B_BEOS_PREFERENCES_DIRECTORY,
117317bd7ddSAxel Dörfler 	B_BEOS_TRANSLATORS_DIRECTORY,
118317bd7ddSAxel Dörfler 	B_BEOS_MEDIA_NODES_DIRECTORY,
119317bd7ddSAxel Dörfler 	B_BEOS_SOUNDS_DIRECTORY,
120317bd7ddSAxel Dörfler 	B_BEOS_DATA_DIRECTORY,
12152a38012Sejakowatz } directory_which;
12252a38012Sejakowatz 
123986e4abcSIngo Weinhold 
124986e4abcSIngo Weinhold /* find_path[s]() flags */
125986e4abcSIngo Weinhold enum {
126986e4abcSIngo Weinhold 	B_FIND_PATH_CREATE_DIRECTORY			= 0x0001,
127986e4abcSIngo Weinhold 	B_FIND_PATH_CREATE_PARENT_DIRECTORY		= 0x0002,
128986e4abcSIngo Weinhold 	B_FIND_PATH_EXISTING_ONLY				= 0x0004,
129986e4abcSIngo Weinhold };
130986e4abcSIngo Weinhold 
131986e4abcSIngo Weinhold 
132986e4abcSIngo Weinhold typedef enum path_base_directory {
133986e4abcSIngo Weinhold 	B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY,
134986e4abcSIngo Weinhold 	B_FIND_PATH_ADD_ONS_DIRECTORY,
135986e4abcSIngo Weinhold 	B_FIND_PATH_APPS_DIRECTORY,
136986e4abcSIngo Weinhold 	B_FIND_PATH_BIN_DIRECTORY,
137986e4abcSIngo Weinhold 	B_FIND_PATH_BOOT_DIRECTORY,
138986e4abcSIngo Weinhold 	B_FIND_PATH_CACHE_DIRECTORY,
139986e4abcSIngo Weinhold 	B_FIND_PATH_DATA_DIRECTORY,
140986e4abcSIngo Weinhold 	B_FIND_PATH_DEVELOP_DIRECTORY,
141986e4abcSIngo Weinhold 	B_FIND_PATH_DEVELOP_LIB_DIRECTORY,
142986e4abcSIngo Weinhold 	B_FIND_PATH_DOCUMENTATION_DIRECTORY,
143986e4abcSIngo Weinhold 	B_FIND_PATH_ETC_DIRECTORY,
144986e4abcSIngo Weinhold 	B_FIND_PATH_FONTS_DIRECTORY,
145986e4abcSIngo Weinhold 	B_FIND_PATH_HEADERS_DIRECTORY,
146986e4abcSIngo Weinhold 	B_FIND_PATH_LIB_DIRECTORY,
147986e4abcSIngo Weinhold 	B_FIND_PATH_LOG_DIRECTORY,
148986e4abcSIngo Weinhold 	B_FIND_PATH_MEDIA_NODES_DIRECTORY,
149986e4abcSIngo Weinhold 	B_FIND_PATH_PACKAGES_DIRECTORY,
150986e4abcSIngo Weinhold 	B_FIND_PATH_PREFERENCES_DIRECTORY,
151986e4abcSIngo Weinhold 	B_FIND_PATH_SERVERS_DIRECTORY,
152986e4abcSIngo Weinhold 	B_FIND_PATH_SETTINGS_DIRECTORY,
153986e4abcSIngo Weinhold 	B_FIND_PATH_SOUNDS_DIRECTORY,
154986e4abcSIngo Weinhold 	B_FIND_PATH_SPOOL_DIRECTORY,
155986e4abcSIngo Weinhold 	B_FIND_PATH_TRANSLATORS_DIRECTORY,
156986e4abcSIngo Weinhold 	B_FIND_PATH_VAR_DIRECTORY,
157986e4abcSIngo Weinhold 
158986e4abcSIngo Weinhold 	/* find_path() only */
159986e4abcSIngo Weinhold 	B_FIND_PATH_IMAGE_PATH			= 1000,
160986e4abcSIngo Weinhold 	B_FIND_PATH_IMAGE_PACKAGE_PATH,
161986e4abcSIngo Weinhold } path_base_directory;
162986e4abcSIngo Weinhold 
163986e4abcSIngo Weinhold 
16463c96ae5SAxel Dörfler #ifdef __cplusplus
16563c96ae5SAxel Dörfler extern "C" {
16663c96ae5SAxel Dörfler #endif
16763c96ae5SAxel Dörfler 
168e1f3108aSStephan Aßmus /* C interface */
16952a38012Sejakowatz 
17052a38012Sejakowatz status_t find_directory(directory_which which, dev_t volume, bool createIt,
17152a38012Sejakowatz 	char* pathString, int32 length);
17252a38012Sejakowatz 
173*60b39cd7SIngo Weinhold status_t find_path(const void* codePointer, path_base_directory baseDirectory,
174*60b39cd7SIngo Weinhold 	const char* subPath, char* pathBuffer, size_t bufferSize);
175986e4abcSIngo Weinhold 
176*60b39cd7SIngo Weinhold status_t find_path_etc(const void* codePointer, const char* dependency,
177*60b39cd7SIngo Weinhold 	const char* architecture, path_base_directory baseDirectory,
178*60b39cd7SIngo Weinhold 	const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize);
179*60b39cd7SIngo Weinhold 
180*60b39cd7SIngo Weinhold status_t find_path_for_path(const char* path, path_base_directory baseDirectory,
181*60b39cd7SIngo Weinhold 	const char* subPath, char* pathBuffer, size_t bufferSize);
182*60b39cd7SIngo Weinhold 
183*60b39cd7SIngo Weinhold status_t find_path_for_path_etc(const char* path, const char* dependency,
184*60b39cd7SIngo Weinhold 	const char* architecture, path_base_directory baseDirectory,
185*60b39cd7SIngo Weinhold 	const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize);
186986e4abcSIngo Weinhold 
187986e4abcSIngo Weinhold status_t find_paths(path_base_directory baseDirectory, const char* subPath,
188*60b39cd7SIngo Weinhold 	char*** _paths, size_t* _pathCount);
189*60b39cd7SIngo Weinhold 
190*60b39cd7SIngo Weinhold status_t find_paths_etc(const char* architecture,
191*60b39cd7SIngo Weinhold 	path_base_directory baseDirectory, const char* subPath, uint32 flags,
192*60b39cd7SIngo Weinhold 	char*** _paths, size_t* _pathCount);
193986e4abcSIngo Weinhold 
194986e4abcSIngo Weinhold 
19552a38012Sejakowatz #ifdef __cplusplus
19652a38012Sejakowatz }
19752a38012Sejakowatz 
198e1f3108aSStephan Aßmus /* C++ interface */
19952a38012Sejakowatz 
20052a38012Sejakowatz class BVolume;
20152a38012Sejakowatz class BPath;
20252a38012Sejakowatz 
203986e4abcSIngo Weinhold 
20452a38012Sejakowatz status_t find_directory(directory_which which, BPath* path,
20552a38012Sejakowatz 	bool createIt = false, BVolume* volume = NULL);
20652a38012Sejakowatz 
207986e4abcSIngo Weinhold 
208e1f3108aSStephan Aßmus #endif	/* __cplusplus */
20952a38012Sejakowatz 
210e1f3108aSStephan Aßmus #endif	/* _FIND_DIRECTORY_H */
211