xref: /haiku/headers/os/storage/FindDirectory.h (revision c237c4ce593ee823d9867fd997e51e4c447f5623)
163c96ae5SAxel Dörfler /*
2b7a87fd1SAxel Dörfler  * Copyright 2002-2015, 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,
35*c237c4ceSAlexander von Gluck 	B_SYSTEM_DESKBAR_DIRECTORY,
3652a38012Sejakowatz 
3738fa81bfSIngo Weinhold 	B_SYSTEM_ETC_DIRECTORY				= 2008,
3838fa81bfSIngo Weinhold 	B_SYSTEM_SETTINGS_DIRECTORY			= 2010,
3938fa81bfSIngo Weinhold 	B_SYSTEM_LOG_DIRECTORY				= 2012,
404b7e2196SIngo Weinhold 	B_SYSTEM_SPOOL_DIRECTORY,
414b7e2196SIngo Weinhold 	B_SYSTEM_TEMP_DIRECTORY,
424b7e2196SIngo Weinhold 	B_SYSTEM_VAR_DIRECTORY,
4338fa81bfSIngo Weinhold 	B_SYSTEM_CACHE_DIRECTORY			= 2020,
444b7e2196SIngo Weinhold 
4538fa81bfSIngo Weinhold 	B_SYSTEM_NONPACKAGED_DIRECTORY		= 2023,
464b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
474b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY,
484b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY,
494b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
504b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_DATA_DIRECTORY,
514b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY,
524b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY,
534b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY,
544b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_LIB_DIRECTORY,
554b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY,
564b7e2196SIngo Weinhold 	B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY,
5752a38012Sejakowatz 
58e1f3108aSStephan Aßmus 	/* User directories. These are interpreted in the context
59e1f3108aSStephan Aßmus 	   of the user making the find_directory call. */
6052a38012Sejakowatz 	B_USER_DIRECTORY					= 3000,
6152a38012Sejakowatz 	B_USER_CONFIG_DIRECTORY,
6252a38012Sejakowatz 	B_USER_ADDONS_DIRECTORY,
6352a38012Sejakowatz 	B_USER_BOOT_DIRECTORY,
6452a38012Sejakowatz 	B_USER_FONTS_DIRECTORY,
6552a38012Sejakowatz 	B_USER_LIB_DIRECTORY,
6652a38012Sejakowatz 	B_USER_SETTINGS_DIRECTORY,
6752a38012Sejakowatz 	B_USER_DESKBAR_DIRECTORY,
6852a38012Sejakowatz 	B_USER_PRINTERS_DIRECTORY,
6952a38012Sejakowatz 	B_USER_TRANSLATORS_DIRECTORY,
7052a38012Sejakowatz 	B_USER_MEDIA_NODES_DIRECTORY,
7152a38012Sejakowatz 	B_USER_SOUNDS_DIRECTORY,
7263c96ae5SAxel Dörfler 	B_USER_DATA_DIRECTORY,
7363c96ae5SAxel Dörfler 	B_USER_CACHE_DIRECTORY,
743dfd9cb9SOliver Tappe 	B_USER_PACKAGES_DIRECTORY,
753dfd9cb9SOliver Tappe 	B_USER_HEADERS_DIRECTORY,
763dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_DIRECTORY,
773dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_ADDONS_DIRECTORY,
783dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY,
793dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY,
803dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_BIN_DIRECTORY,
813dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_DATA_DIRECTORY,
823dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_FONTS_DIRECTORY,
833dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_SOUNDS_DIRECTORY,
843dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY,
853dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_LIB_DIRECTORY,
863dfd9cb9SOliver Tappe 	B_USER_NONPACKAGED_HEADERS_DIRECTORY,
873f85cfc1SIngo Weinhold 	B_USER_NONPACKAGED_DEVELOP_DIRECTORY,
883f85cfc1SIngo Weinhold 	B_USER_DEVELOP_DIRECTORY,
893f85cfc1SIngo Weinhold 	B_USER_DOCUMENTATION_DIRECTORY,
90635d2ac4SIngo Weinhold 	B_USER_SERVERS_DIRECTORY,
91635d2ac4SIngo Weinhold 	B_USER_APPS_DIRECTORY,
92635d2ac4SIngo Weinhold 	B_USER_BIN_DIRECTORY,
93635d2ac4SIngo Weinhold 	B_USER_PREFERENCES_DIRECTORY,
94635d2ac4SIngo Weinhold 	B_USER_ETC_DIRECTORY,
95635d2ac4SIngo Weinhold 	B_USER_LOG_DIRECTORY,
96635d2ac4SIngo Weinhold 	B_USER_SPOOL_DIRECTORY,
97635d2ac4SIngo Weinhold 	B_USER_VAR_DIRECTORY,
9852a38012Sejakowatz 
99e1f3108aSStephan Aßmus 	/* Global directories. */
10052a38012Sejakowatz 	B_APPS_DIRECTORY					= 4000,
10152a38012Sejakowatz 	B_PREFERENCES_DIRECTORY,
102317bd7ddSAxel Dörfler 	B_UTILITIES_DIRECTORY,
1033dfd9cb9SOliver Tappe 	B_PACKAGE_LINKS_DIRECTORY,
10452a38012Sejakowatz 
105317bd7ddSAxel Dörfler 	/* Obsolete: Legacy BeOS definition to be phased out */
106317bd7ddSAxel Dörfler 	B_BEOS_DIRECTORY					= 1000,
107317bd7ddSAxel Dörfler 	B_BEOS_SYSTEM_DIRECTORY,
108317bd7ddSAxel Dörfler 	B_BEOS_ADDONS_DIRECTORY,
109317bd7ddSAxel Dörfler 	B_BEOS_BOOT_DIRECTORY,
110317bd7ddSAxel Dörfler 	B_BEOS_FONTS_DIRECTORY,
111317bd7ddSAxel Dörfler 	B_BEOS_LIB_DIRECTORY,
112317bd7ddSAxel Dörfler 	B_BEOS_SERVERS_DIRECTORY,
113317bd7ddSAxel Dörfler 	B_BEOS_APPS_DIRECTORY,
114317bd7ddSAxel Dörfler 	B_BEOS_BIN_DIRECTORY,
115317bd7ddSAxel Dörfler 	B_BEOS_ETC_DIRECTORY,
116317bd7ddSAxel Dörfler 	B_BEOS_DOCUMENTATION_DIRECTORY,
117317bd7ddSAxel Dörfler 	B_BEOS_PREFERENCES_DIRECTORY,
118317bd7ddSAxel Dörfler 	B_BEOS_TRANSLATORS_DIRECTORY,
119317bd7ddSAxel Dörfler 	B_BEOS_MEDIA_NODES_DIRECTORY,
120317bd7ddSAxel Dörfler 	B_BEOS_SOUNDS_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,
129b7a87fd1SAxel Dörfler 
130b7a87fd1SAxel Dörfler 	B_FIND_PATHS_SYSTEM_ONLY				= 0x0010,
131b7a87fd1SAxel Dörfler 	B_FIND_PATHS_USER_ONLY					= 0x0020,
132986e4abcSIngo Weinhold };
133986e4abcSIngo Weinhold 
134986e4abcSIngo Weinhold 
135986e4abcSIngo Weinhold typedef enum path_base_directory {
136986e4abcSIngo Weinhold 	B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY,
137986e4abcSIngo Weinhold 	B_FIND_PATH_ADD_ONS_DIRECTORY,
138986e4abcSIngo Weinhold 	B_FIND_PATH_APPS_DIRECTORY,
139986e4abcSIngo Weinhold 	B_FIND_PATH_BIN_DIRECTORY,
140986e4abcSIngo Weinhold 	B_FIND_PATH_BOOT_DIRECTORY,
141986e4abcSIngo Weinhold 	B_FIND_PATH_CACHE_DIRECTORY,
142986e4abcSIngo Weinhold 	B_FIND_PATH_DATA_DIRECTORY,
143986e4abcSIngo Weinhold 	B_FIND_PATH_DEVELOP_DIRECTORY,
144986e4abcSIngo Weinhold 	B_FIND_PATH_DEVELOP_LIB_DIRECTORY,
145986e4abcSIngo Weinhold 	B_FIND_PATH_DOCUMENTATION_DIRECTORY,
146986e4abcSIngo Weinhold 	B_FIND_PATH_ETC_DIRECTORY,
147986e4abcSIngo Weinhold 	B_FIND_PATH_FONTS_DIRECTORY,
148986e4abcSIngo Weinhold 	B_FIND_PATH_HEADERS_DIRECTORY,
149986e4abcSIngo Weinhold 	B_FIND_PATH_LIB_DIRECTORY,
150986e4abcSIngo Weinhold 	B_FIND_PATH_LOG_DIRECTORY,
151986e4abcSIngo Weinhold 	B_FIND_PATH_MEDIA_NODES_DIRECTORY,
152986e4abcSIngo Weinhold 	B_FIND_PATH_PACKAGES_DIRECTORY,
153986e4abcSIngo Weinhold 	B_FIND_PATH_PREFERENCES_DIRECTORY,
154986e4abcSIngo Weinhold 	B_FIND_PATH_SERVERS_DIRECTORY,
155986e4abcSIngo Weinhold 	B_FIND_PATH_SETTINGS_DIRECTORY,
156986e4abcSIngo Weinhold 	B_FIND_PATH_SOUNDS_DIRECTORY,
157986e4abcSIngo Weinhold 	B_FIND_PATH_SPOOL_DIRECTORY,
158986e4abcSIngo Weinhold 	B_FIND_PATH_TRANSLATORS_DIRECTORY,
159986e4abcSIngo Weinhold 	B_FIND_PATH_VAR_DIRECTORY,
160986e4abcSIngo Weinhold 
161986e4abcSIngo Weinhold 	/* find_path() only */
162986e4abcSIngo Weinhold 	B_FIND_PATH_IMAGE_PATH			= 1000,
16322e92014SIngo Weinhold 	B_FIND_PATH_PACKAGE_PATH,
164986e4abcSIngo Weinhold } path_base_directory;
165986e4abcSIngo Weinhold 
166986e4abcSIngo Weinhold 
16763c96ae5SAxel Dörfler #ifdef __cplusplus
16863c96ae5SAxel Dörfler extern "C" {
16963c96ae5SAxel Dörfler #endif
17063c96ae5SAxel Dörfler 
171e1f3108aSStephan Aßmus /* C interface */
17252a38012Sejakowatz 
17352a38012Sejakowatz status_t find_directory(directory_which which, dev_t volume, bool createIt,
17452a38012Sejakowatz 	char* pathString, int32 length);
17552a38012Sejakowatz 
17660b39cd7SIngo Weinhold status_t find_path(const void* codePointer, path_base_directory baseDirectory,
17760b39cd7SIngo Weinhold 	const char* subPath, char* pathBuffer, size_t bufferSize);
178986e4abcSIngo Weinhold 
17960b39cd7SIngo Weinhold status_t find_path_etc(const void* codePointer, const char* dependency,
18060b39cd7SIngo Weinhold 	const char* architecture, path_base_directory baseDirectory,
18160b39cd7SIngo Weinhold 	const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize);
18260b39cd7SIngo Weinhold 
18360b39cd7SIngo Weinhold status_t find_path_for_path(const char* path, path_base_directory baseDirectory,
18460b39cd7SIngo Weinhold 	const char* subPath, char* pathBuffer, size_t bufferSize);
18560b39cd7SIngo Weinhold 
18660b39cd7SIngo Weinhold status_t find_path_for_path_etc(const char* path, const char* dependency,
18760b39cd7SIngo Weinhold 	const char* architecture, path_base_directory baseDirectory,
18860b39cd7SIngo Weinhold 	const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize);
189986e4abcSIngo Weinhold 
190986e4abcSIngo Weinhold status_t find_paths(path_base_directory baseDirectory, const char* subPath,
19160b39cd7SIngo Weinhold 	char*** _paths, size_t* _pathCount);
19260b39cd7SIngo Weinhold 
19360b39cd7SIngo Weinhold status_t find_paths_etc(const char* architecture,
19460b39cd7SIngo Weinhold 	path_base_directory baseDirectory, const char* subPath, uint32 flags,
19560b39cd7SIngo Weinhold 	char*** _paths, size_t* _pathCount);
196986e4abcSIngo Weinhold 
197986e4abcSIngo Weinhold 
19852a38012Sejakowatz #ifdef __cplusplus
19952a38012Sejakowatz }
20052a38012Sejakowatz 
201e1f3108aSStephan Aßmus /* C++ interface */
20252a38012Sejakowatz 
20352a38012Sejakowatz class BVolume;
20452a38012Sejakowatz class BPath;
20552a38012Sejakowatz 
206986e4abcSIngo Weinhold 
20752a38012Sejakowatz status_t find_directory(directory_which which, BPath* path,
20852a38012Sejakowatz 	bool createIt = false, BVolume* volume = NULL);
20952a38012Sejakowatz 
210986e4abcSIngo Weinhold 
211e1f3108aSStephan Aßmus #endif	/* __cplusplus */
21252a38012Sejakowatz 
213e1f3108aSStephan Aßmus #endif	/* _FIND_DIRECTORY_H */
214