Enumerations | Functions
FindDirectory.h File Reference

Provides the find_directory(), find_path(), find_paths() functions as well as the directory_which constants. More...

Enumerations

enum  {
  B_FIND_PATH_CREATE_DIRECTORY = 0x0001,
  B_FIND_PATH_CREATE_PARENT_DIRECTORY = 0x0002,
  B_FIND_PATH_EXISTING_ONLY = 0x0004
}
 
enum  directory_which {
  B_DESKTOP_DIRECTORY = 0,
  B_TRASH_DIRECTORY,
  B_SYSTEM_DIRECTORY = 1000,
  B_SYSTEM_ADDONS_DIRECTORY = 1002,
  B_SYSTEM_BOOT_DIRECTORY,
  B_SYSTEM_FONTS_DIRECTORY,
  B_SYSTEM_LIB_DIRECTORY,
  B_SYSTEM_SERVERS_DIRECTORY,
  B_SYSTEM_APPS_DIRECTORY,
  B_SYSTEM_BIN_DIRECTORY,
  B_SYSTEM_DOCUMENTATION_DIRECTORY = 1010,
  B_SYSTEM_PREFERENCES_DIRECTORY,
  B_SYSTEM_TRANSLATORS_DIRECTORY,
  B_SYSTEM_MEDIA_NODES_DIRECTORY,
  B_SYSTEM_SOUNDS_DIRECTORY,
  B_SYSTEM_DATA_DIRECTORY,
  B_SYSTEM_DEVELOP_DIRECTORY,
  B_SYSTEM_PACKAGES_DIRECTORY,
  B_SYSTEM_HEADERS_DIRECTORY,
  B_SYSTEM_ETC_DIRECTORY = 2008,
  B_SYSTEM_SETTINGS_DIRECTORY = 2010,
  B_SYSTEM_LOG_DIRECTORY = 2012,
  B_SYSTEM_SPOOL_DIRECTORY,
  B_SYSTEM_TEMP_DIRECTORY,
  B_SYSTEM_VAR_DIRECTORY,
  B_SYSTEM_CACHE_DIRECTORY = 2020,
  B_SYSTEM_NONPACKAGED_DIRECTORY = 2023,
  B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
  B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY,
  B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY,
  B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
  B_SYSTEM_NONPACKAGED_DATA_DIRECTORY,
  B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY,
  B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY,
  B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY,
  B_SYSTEM_NONPACKAGED_LIB_DIRECTORY,
  B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY,
  B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY,
  B_USER_DIRECTORY = 3000,
  B_USER_CONFIG_DIRECTORY,
  B_USER_ADDONS_DIRECTORY,
  B_USER_BOOT_DIRECTORY,
  B_USER_FONTS_DIRECTORY,
  B_USER_LIB_DIRECTORY,
  B_USER_SETTINGS_DIRECTORY,
  B_USER_DESKBAR_DIRECTORY,
  B_USER_PRINTERS_DIRECTORY,
  B_USER_TRANSLATORS_DIRECTORY,
  B_USER_MEDIA_NODES_DIRECTORY,
  B_USER_SOUNDS_DIRECTORY,
  B_USER_DATA_DIRECTORY,
  B_USER_CACHE_DIRECTORY,
  B_USER_PACKAGES_DIRECTORY,
  B_USER_HEADERS_DIRECTORY,
  B_USER_NONPACKAGED_DIRECTORY,
  B_USER_NONPACKAGED_ADDONS_DIRECTORY,
  B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY,
  B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY,
  B_USER_NONPACKAGED_BIN_DIRECTORY,
  B_USER_NONPACKAGED_DATA_DIRECTORY,
  B_USER_NONPACKAGED_FONTS_DIRECTORY,
  B_USER_NONPACKAGED_SOUNDS_DIRECTORY,
  B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY,
  B_USER_NONPACKAGED_LIB_DIRECTORY,
  B_USER_NONPACKAGED_HEADERS_DIRECTORY,
  B_USER_NONPACKAGED_DEVELOP_DIRECTORY,
  B_USER_DEVELOP_DIRECTORY,
  B_USER_DOCUMENTATION_DIRECTORY,
  B_USER_SERVERS_DIRECTORY,
  B_USER_APPS_DIRECTORY,
  B_USER_BIN_DIRECTORY,
  B_USER_PREFERENCES_DIRECTORY,
  B_USER_ETC_DIRECTORY,
  B_USER_LOG_DIRECTORY,
  B_USER_SPOOL_DIRECTORY,
  B_USER_VAR_DIRECTORY,
  B_APPS_DIRECTORY = 4000,
  B_PREFERENCES_DIRECTORY,
  B_UTILITIES_DIRECTORY,
  B_PACKAGE_LINKS_DIRECTORY,
  B_BEOS_DIRECTORY = 1000,
  B_BEOS_SYSTEM_DIRECTORY,
  B_BEOS_ADDONS_DIRECTORY,
  B_BEOS_BOOT_DIRECTORY,
  B_BEOS_FONTS_DIRECTORY,
  B_BEOS_LIB_DIRECTORY,
  B_BEOS_SERVERS_DIRECTORY,
  B_BEOS_APPS_DIRECTORY,
  B_BEOS_BIN_DIRECTORY,
  B_BEOS_ETC_DIRECTORY,
  B_BEOS_DOCUMENTATION_DIRECTORY,
  B_BEOS_PREFERENCES_DIRECTORY,
  B_BEOS_TRANSLATORS_DIRECTORY,
  B_BEOS_MEDIA_NODES_DIRECTORY,
  B_BEOS_SOUNDS_DIRECTORY
}
 Directory constants to use with find_directory(). More...
 
enum  path_base_directory {
  B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY,
  B_FIND_PATH_ADD_ONS_DIRECTORY,
  B_FIND_PATH_APPS_DIRECTORY,
  B_FIND_PATH_BIN_DIRECTORY,
  B_FIND_PATH_BOOT_DIRECTORY,
  B_FIND_PATH_CACHE_DIRECTORY,
  B_FIND_PATH_DATA_DIRECTORY,
  B_FIND_PATH_DEVELOP_DIRECTORY,
  B_FIND_PATH_DEVELOP_LIB_DIRECTORY,
  B_FIND_PATH_DOCUMENTATION_DIRECTORY,
  B_FIND_PATH_ETC_DIRECTORY,
  B_FIND_PATH_FONTS_DIRECTORY,
  B_FIND_PATH_HEADERS_DIRECTORY,
  B_FIND_PATH_LIB_DIRECTORY,
  B_FIND_PATH_LOG_DIRECTORY,
  B_FIND_PATH_MEDIA_NODES_DIRECTORY,
  B_FIND_PATH_PACKAGES_DIRECTORY,
  B_FIND_PATH_PREFERENCES_DIRECTORY,
  B_FIND_PATH_SERVERS_DIRECTORY,
  B_FIND_PATH_SETTINGS_DIRECTORY,
  B_FIND_PATH_SOUNDS_DIRECTORY,
  B_FIND_PATH_SPOOL_DIRECTORY,
  B_FIND_PATH_TRANSLATORS_DIRECTORY,
  B_FIND_PATH_VAR_DIRECTORY,
  B_FIND_PATH_IMAGE_PATH = 1000,
  B_FIND_PATH_PACKAGE_PATH
}
 Path constants to use with find_path(), find_paths(), et al. More...
 

Functions

status_t find_directory (directory_which which, dev_t volume, bool createIt, char *pathString, int32 length)
 C interface to find_directory. More...
 
status_t find_directory (directory_which which, BPath *path, bool createIt=false, BVolume *volume=NULL)
 C++ interface to find_directory. More...
 
status_t find_path (const void *codePointer, path_base_directory baseDirectory, const char *subPath, char *pathBuffer, size_t bufferSize)
 Retrieves a path in the file system layout based on a loaded image file. More...
 
status_t find_path_etc (const void *codePointer, const char *dependency, const char *architecture, path_base_directory baseDirectory, const char *subPath, uint32 flags, char *pathBuffer, size_t bufferSize)
 Retrieves a path in the file system layout based on a loaded image file. More...
 
status_t find_path_for_path (const char *path, path_base_directory baseDirectory, const char *subPath, char *pathBuffer, size_t bufferSize)
 Retrieves a path in the file system layout based on a given path. More...
 
status_t find_path_for_path_etc (const char *path, const char *dependency, const char *architecture, path_base_directory baseDirectory, const char *subPath, uint32 flags, char *pathBuffer, size_t bufferSize)
 Retrieves a path in the file system layout based on a given path. More...
 
status_t find_paths (path_base_directory baseDirectory, const char *subPath, char ***_paths, size_t *_pathCount)
 Retrieves a list of paths in the file system layout. More...
 
status_t find_paths_etc (const char *architecture, path_base_directory baseDirectory, const char *subPath, uint32 flags, char ***_paths, size_t *_pathCount)
 Retrieves a list of paths in the file system layout. More...
 

Detailed Description

Provides the find_directory(), find_path(), find_paths() functions as well as the directory_which constants.

Haiku provides a set of directories for applications to use. These can be accessed using the functions find_directory(), find_path(), find_path_etc(), find_paths(), find_paths_etc(), find_path_for_path(), find_path_for_path_etc(). It is very important to use the functions at runtime and not hardcode the path, as it may change in future versions of Haiku, and already changed in past ones. Using these functions makes your application more future-proof, and makes sure everyone puts data in the same place, which makes the system cleaner and easier to manage.

Note that while the find_directory() function is still needed for some, it is deprecated for many other use cases, like:

Cases for which find_directory() is still useful:

Note that these functions can be accessed from C code (they are implemented in libroot), to make it easy to use also in ported applications. However, there are also a C++ version of find_directory() and the BPathFinder class (both implemented in libbe), which may be more convenient to use in C++ code.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
B_FIND_PATH_CREATE_DIRECTORY 

Specifies that if the resulting path doesn't exist, it shall be created a directory, including all missing ancestors.

Failure to create the path will cause the respective function to fail.

Flag for the find_path_etc(), find_path_for_path_etc(), find_paths_etc(), and BPathFinder API.

Since
Haiku R1
B_FIND_PATH_CREATE_PARENT_DIRECTORY 

Specifies that if the resulting path's parent doesn't exist, the parent shall be created as a directory, including all missing ancestors.

Failure to create the directory will cause the respective function to fail.

Flag for the find_path_etc(), find_path_for_path_etc(), find_paths_etc(), and BPathFinder API.

Since
Haiku R1
B_FIND_PATH_EXISTING_ONLY 

Specifies that if the resulting path doesn't exist, the respective function shall skip it.

In case multiple paths shall be retrieved and none of the paths exists, the function shall fail with B_ENTRY_NOT_FOUND.

Flag for the find_path_etc(), find_path_for_path_etc(), find_paths_etc(), and BPathFinder API.

Since
Haiku R1

◆ directory_which

Directory constants to use with find_directory().

There are four kind of directories. Volume-local directories exist on each volume, they may be at a different location in each of them. For example the location of the trash directory depends on the filesystem. System directories are system-wide, they live on only one volume. System is meant for internal system management and system-wide applications. User directories have a different value depending on the UID of the application calling the function. They are usually located in the user's home directory.

Use system directories for system-wide files such as drivers and use user directories are for application settings, since each user may want different settings.

Remarks
The B_COMMON_* constants have been intentionally removed in Haiku R1, use the B_SYSTEM_* constants instead.
Since
BeOS R3
Enumerator
B_DESKTOP_DIRECTORY 

The desktop directory for a given volume.

Since
BeOS R3
B_TRASH_DIRECTORY 

The trash directory for a given volume.

Since
BeOS R3
B_SYSTEM_DIRECTORY 

The system directory.

Since
Haiku R1
B_SYSTEM_ADDONS_DIRECTORY 

The system add-ons directory.

Since
Haiku R1
B_SYSTEM_BOOT_DIRECTORY 

The system boot directory.

Contains the minimal set of files required for booting Haiku.

Since
Haiku R1
B_SYSTEM_FONTS_DIRECTORY 

The system fonts directory.

Since
Haiku R1
B_SYSTEM_LIB_DIRECTORY 

The system lib directory.

Since
Haiku R1
B_SYSTEM_SERVERS_DIRECTORY 

The system servers directory.

Since
Haiku R1
B_SYSTEM_APPS_DIRECTORY 

The system applications directory.

Contains applications with graphical user interface.

Since
Haiku R1
B_SYSTEM_BIN_DIRECTORY 

The system bin directory.

Contains command-line applications runnable from Terminal.

Since
Haiku R1
B_SYSTEM_DOCUMENTATION_DIRECTORY 

The system documentation directory, contains e.g. man pages.

Since
Haiku R1
B_SYSTEM_PREFERENCES_DIRECTORY 

The system preferences directory.

Since
Haiku R1
B_SYSTEM_TRANSLATORS_DIRECTORY 

The system translator directory.

Since
Haiku R1
B_SYSTEM_MEDIA_NODES_DIRECTORY 

The system media nodes directory.

Since
Haiku R1
B_SYSTEM_SOUNDS_DIRECTORY 

The system sounds directory.

Since
Haiku R1
B_SYSTEM_DATA_DIRECTORY 

The system data directory.

Since
Haiku R1
B_SYSTEM_DEVELOP_DIRECTORY 

The system directory containing development related files.

Since
Haiku R1
B_SYSTEM_PACKAGES_DIRECTORY 

The system directory where activated packages live.

Since
Haiku R1
B_SYSTEM_HEADERS_DIRECTORY 

The system directory for development header files.

Since
Haiku R1
B_SYSTEM_ETC_DIRECTORY 

The system directory used for Unix-like installation location-wide settings (Unix "etc" directory).

Since
Haiku R1
B_SYSTEM_SETTINGS_DIRECTORY 

The system directory used for installation location-wide settings.

Since
Haiku R1
B_SYSTEM_LOG_DIRECTORY 

The system directory where log files are put.

Since
Haiku R1
B_SYSTEM_SPOOL_DIRECTORY 

The system directory for spool data (e.g. pending printer jobs).

Since
Haiku R1
B_SYSTEM_TEMP_DIRECTORY 

The global directory for temporary files (Unix "tmp" directory).

Since
Haiku R1
B_SYSTEM_VAR_DIRECTORY 

The system directory for variable data (Unix "var" directory).

Since
Haiku R1
B_SYSTEM_CACHE_DIRECTORY 

The system directory used for cache files.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_DIRECTORY 

The system non-packaged installation location directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY 

The system non-packaged add-ons directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY 

The system non-packaged translator directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY 

The system non-packaged media nodes directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_BIN_DIRECTORY 

runnable from Terminal.

The system non-packaged bin directory. Contains command-line applications

Since
Haiku R1
B_SYSTEM_NONPACKAGED_DATA_DIRECTORY 

The system non-packaged data directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY 

The system non-packaged fonts directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY 

The system non-packaged sounds directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY 

The system non-packaged documentation directory. Contains e.g. man pages.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_LIB_DIRECTORY 

The system non-packaged lib directory.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY 

The system non-packaged directory for development header files.

Since
Haiku R1
B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY 

The system non-packaged directory containing development related files.

Since
Haiku R1
B_USER_DIRECTORY 

The user home directory.

Do NOT store application settings here as on unix, instead use B_USER_SETTINGS_DIRECTORY.

Since
BeOS R3
B_USER_CONFIG_DIRECTORY 

The user packaged installation location directory.

Since
BeOS R3
B_USER_ADDONS_DIRECTORY 

The user add-ons directory.

Since
BeOS R3
B_USER_BOOT_DIRECTORY 

The user directory containing booting related files.

Since
BeOS R3
B_USER_FONTS_DIRECTORY 

The user fonts directory.

Since
BeOS R3
B_USER_LIB_DIRECTORY 

The user lib directory.

Since
BeOS R3
B_USER_SETTINGS_DIRECTORY 

The user settings directory.

You may store your application settings here. Create a subdirectory for your application if you have multiple files to store, else, put a single file. The file or directory should have the same name as your application, so the user knows what it's used for.

Since
BeOS R3
B_USER_DESKBAR_DIRECTORY 

The user Deskbar directory.

You may add a link to your application here, so it shows up in the user's Deskbar leaf menu.

Since
BeOS R3
B_USER_PRINTERS_DIRECTORY 

The user directory for printer settings.

Since
Haiku R1
B_USER_TRANSLATORS_DIRECTORY 

The user translator directory.

Since
Haiku R1
B_USER_MEDIA_NODES_DIRECTORY 

The user media nodes directory.

Since
Haiku R1
B_USER_SOUNDS_DIRECTORY 

The user sounds directory.

Since
Haiku R1
B_USER_DATA_DIRECTORY 

The user data directory.

Since
Haiku R1
B_USER_CACHE_DIRECTORY 

The user directory used for cache files.

Since
Haiku R1
B_USER_PACKAGES_DIRECTORY 

The user directory where activated packages live.

Since
Haiku R1
B_USER_HEADERS_DIRECTORY 

The user directory for development header files.

Since
Haiku R1
B_USER_NONPACKAGED_DIRECTORY 

The user non-packaged installation location directory.

Since
Haiku R1
B_USER_NONPACKAGED_ADDONS_DIRECTORY 

The user non-packaged add-ons directory.

Since
Haiku R1
B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY 

The user non-packaged translator directory.

Since
Haiku R1
B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY 

The user non-packaged media nodes directory.

Since
Haiku R1
B_USER_NONPACKAGED_BIN_DIRECTORY 

The user non-packaged bin directory.

Contains command-line applications runnable from Terminal.

Since
Haiku R1
B_USER_NONPACKAGED_DATA_DIRECTORY 

The user non-packaged data directory.

Since
Haiku R1
B_USER_NONPACKAGED_FONTS_DIRECTORY 

The user non-packaged fonts directory.

Since
Haiku R1
B_USER_NONPACKAGED_SOUNDS_DIRECTORY 

The user non-packaged sounds directory.

Since
Haiku R1
B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY 

The user non-packaged documentation directory, contains e.g. man pages.

Since
Haiku R1
B_USER_NONPACKAGED_LIB_DIRECTORY 

The user non-packaged lib directory.

Since
Haiku R1
B_USER_NONPACKAGED_HEADERS_DIRECTORY 

The user non-packaged directory for development header files.

Since
Haiku R1
B_USER_NONPACKAGED_DEVELOP_DIRECTORY 

The user non-packaged directory containing development related files.

Since
Haiku R1
B_USER_DEVELOP_DIRECTORY 

The user directory containing development related files.

Since
Haiku R1
B_USER_DOCUMENTATION_DIRECTORY 

The user documentation directory, contains e.g. man pages.

Since
Haiku R1
B_USER_SERVERS_DIRECTORY 

The user servers directory.

Since
Haiku R1
B_USER_APPS_DIRECTORY 

The user applications directory.

Contains applications with graphical user interface.

Since
Haiku R1
B_USER_BIN_DIRECTORY 

The user bin directory.

Contains command-line applications runnable from Terminal.

Since
Haiku R1
B_USER_PREFERENCES_DIRECTORY 

The user preference applications directory.

Since
Haiku R1
B_USER_ETC_DIRECTORY 

The user directory used for Unix-like installation location-wide settings (Unix "etc" directory).

Since
Haiku R1
B_USER_LOG_DIRECTORY 

The user directory where log files are put.

Since
Haiku R1
B_USER_SPOOL_DIRECTORY 

The user directory for spool data, e.g. pending printer jobs.

Since
Haiku R1
B_USER_VAR_DIRECTORY 

The user directory for variable data (Unix "var" directory).

Since
Haiku R1
B_APPS_DIRECTORY 

The global applications directory.

Contains applications with graphical user interface.

Since
BeOS R3
B_PREFERENCES_DIRECTORY 

The global preference applications directory.

Since
BeOS R3
B_UTILITIES_DIRECTORY 

The global utility applications directory.

Since
Haiku R1
B_PACKAGE_LINKS_DIRECTORY 

The global package links directory.

This is where symlink directories for all activated packages are exposed.

Since
Haiku R1
B_BEOS_DIRECTORY 

The BeOS directory.

Since
BeOS R3
B_BEOS_SYSTEM_DIRECTORY 

The BeOS system directory.

Since
BeOS R3
B_BEOS_ADDONS_DIRECTORY 

The BeOS Add-ons directory.

Since
BeOS R3
B_BEOS_BOOT_DIRECTORY 

The BeOS boot directory.

Since
BeOS R3
B_BEOS_FONTS_DIRECTORY 

The BeOS fonts directory.

Since
BeOS R3
B_BEOS_LIB_DIRECTORY 

The BeOS lib directory.

Since
BeOS R3
B_BEOS_SERVERS_DIRECTORY 

The BeOS servers directory.

Since
BeOS R3
B_BEOS_APPS_DIRECTORY 

The BeOS apps directory.

Since
BeOS R3
B_BEOS_BIN_DIRECTORY 

The BeOS bin directory.

Since
BeOS R3
B_BEOS_ETC_DIRECTORY 

The BeOS etc directory used for Unix-like installation location-wide settings (Unix "etc" directory).

Since
BeOS R3
B_BEOS_DOCUMENTATION_DIRECTORY 

The BeOS documentation directory.

Since
BeOS R3
B_BEOS_PREFERENCES_DIRECTORY 

The BeOS preferences directory.

Since
BeOS R3
B_BEOS_TRANSLATORS_DIRECTORY 

The BeOS translators directory.

Since
BeOS R3
B_BEOS_MEDIA_NODES_DIRECTORY 

The BeOS media nodes directory.

Since
BeOS R3
B_BEOS_SOUNDS_DIRECTORY 

The BeOS sounds directory.

Since
BeOS R3

◆ path_base_directory

Path constants to use with find_path(), find_paths(), et al.

There are two kinds of constants. Those that are based off an installation location and those that based off an image or given path. The latter are not valid argument for all functions.

Since
Haiku R1
Enumerator
B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY 

The installation location base directory.

Since
Haiku R1
B_FIND_PATH_ADD_ONS_DIRECTORY 

The add-ons directory.

Since
Haiku R1
B_FIND_PATH_APPS_DIRECTORY 

The application directory.

Since
Haiku R1
B_FIND_PATH_BIN_DIRECTORY 

The command line application directory (Unix "bin" directory).

Since
Haiku R1
B_FIND_PATH_BOOT_DIRECTORY 

The directory containing booting related files.

Since
Haiku R1
B_FIND_PATH_CACHE_DIRECTORY 

The directory used for cache files.

Since
Haiku R1
B_FIND_PATH_DATA_DIRECTORY 

The base directory used for read-only data.

Since
Haiku R1
B_FIND_PATH_DEVELOP_DIRECTORY 

The directory containing development related files.

Since
Haiku R1
B_FIND_PATH_DEVELOP_LIB_DIRECTORY 

The the development library directory.

This is the directory where the linker finds libraries.

Since
Haiku R1
B_FIND_PATH_DOCUMENTATION_DIRECTORY 

The base directory used for documentation.

Since
Haiku R1
B_FIND_PATH_ETC_DIRECTORY 

The directory used for Unix-like installation location wide settings (Unix "etc" directory).

Since
Haiku R1
B_FIND_PATH_FONTS_DIRECTORY 

The fonts directory.

Since
Haiku R1
B_FIND_PATH_HEADERS_DIRECTORY 

The development header files directory.

Since
Haiku R1
B_FIND_PATH_LIB_DIRECTORY 

The runtime library directory.

This is where the runtime loader finds libraries.

Since
Haiku R1
B_FIND_PATH_LOG_DIRECTORY 

The directory where log files are put.

Since
Haiku R1
B_FIND_PATH_MEDIA_NODES_DIRECTORY 

The media node add-ons directory.

Since
Haiku R1
B_FIND_PATH_PACKAGES_DIRECTORY 

The directory where activated packages live.

Since
Haiku R1
B_FIND_PATH_PREFERENCES_DIRECTORY 

The preference application directory.

Since
Haiku R1
B_FIND_PATH_SERVERS_DIRECTORY 

The server and daemon program directory.

Since
Haiku R1
B_FIND_PATH_SETTINGS_DIRECTORY 

The directory used for installation location wide settings.

Note that for the user's home config installation location, this is not the same as the user's settings directory. Software installed in that installation location puts their global settings files here.

Since
Haiku R1
B_FIND_PATH_SOUNDS_DIRECTORY 

The directory for sound files.

Since
Haiku R1
B_FIND_PATH_SPOOL_DIRECTORY 

The directory for spool data, e.g. pending printer jobs.

Since
Haiku R1
B_FIND_PATH_TRANSLATORS_DIRECTORY 

The translator add-ons directory.

Since
Haiku R1
B_FIND_PATH_VAR_DIRECTORY 

The directory for variable data (Unix "var" directory).

Since
Haiku R1
B_FIND_PATH_IMAGE_PATH 

The path of the image file that was identified by a pointer argument passed to the respective function.

Since
Haiku R1
B_FIND_PATH_PACKAGE_PATH 

The path of the package the file referred to by the specified path belongs to.

Since
Haiku R1

Function Documentation

◆ find_directory() [1/2]

status_t find_directory ( directory_which  which,
dev_t  volume,
bool  createIt,
char *  pathString,
int32  length 
)

C interface to find_directory.

Fills up to length characters of pathString with the path to which on volume. Creates the directory if it doesn't exists if createIt is set.

Since
BeOS R3

◆ find_directory() [2/2]

status_t find_directory ( directory_which  which,
BPath path,
bool  createIt = false,
BVolume volume = NULL 
)

C++ interface to find_directory.

Set path to which on volume.

Since
BeOS R3

◆ find_path()

status_t find_path ( const void *  codePointer,
path_base_directory  baseDirectory,
const char *  subPath,
char *  pathBuffer,
size_t  bufferSize 
)

Retrieves a path in the file system layout based on a loaded image file.

The function determines the path of the image (i.e. executable, library, or add-on) file associated with codePointer, a pointer to a location in the code or static data of an image loaded in the caller's team. Based on that, path baseDirectory is evaluated. In most cases that means first determining the path of the installation location from the path, then appending the relative path corresponding to the given baseDirectory constant, and finally appending subPath, if given.

If baseDirectory specifies a path that is architecture dependent, the caller's architecture (as returned by get_architecture()) is used for constructing the path.

If B_FIND_PATH_IMAGE_PATH or B_FIND_PATH_PACKAGE_PATH are specified, subPath is ignored. In the former case the path of the image file is returned. In the latter case the path of the package containing the image file, if any.

Parameters
codePointerA pointer to code or static data belonging to the image based on which the path shall be computed. The special value B_APP_IMAGE_SYMBOL can be used to refer to the program image, and B_CURRENT_IMAGE_SYMBOL for the caller's image.
baseDirectoryConstant indicating which path to retrieve.
subPathRelative subpath that shall be appended. Can be NULL.
pathBufferPointer to a pre-allocated buffer the retrieved path shall be stored in.
bufferSizeSize of the pathBuffer buffer.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BUFFER_OVERFLOWThe provided pathBuffer wasn't large enough.
B_ENTRY_NOT_FOUNDA file system entry required for retrieving the path doesn't exist. E.g. B_FIND_PATH_PACKAGE_PATH was specified and the image file doesn't belong to a package.
Since
Haiku R1

◆ find_path_etc()

status_t find_path_etc ( const void *  codePointer,
const char *  dependency,
const char *  architecture,
path_base_directory  baseDirectory,
const char *  subPath,
uint32  flags,
char *  pathBuffer,
size_t  bufferSize 
)

Retrieves a path in the file system layout based on a loaded image file.

The function determines the path of the image (i.e. executable, library, or add-on) file associated with codePointer, a pointer to a location in the code or static data of an image loaded in the caller's team. Based on that, path baseDirectory is evaluated. In most cases that means first determining the path of the installation location from the path, then appending the relative path corresponding to the given baseDirectory constant, and finally appending subPath, if given.

If dependency is specified, instead of determining the installation location path from the image path, the installation location path of the dependency dependency of the package containing the image file is used.

If baseDirectory specifies a path that is architecture dependent, architecture is used for constructing the path. If architecture is NULL, the caller's architecture (as returned by get_architecture()) is used.

If B_FIND_PATH_IMAGE_PATH or B_FIND_PATH_PACKAGE_PATH are specified, dependency and subPath are ignored. In the former case the path of the image file is returned. In the latter case the path of the package containing the image file, if any.

Parameters
codePointerA pointer to code or static data belonging to the image based on which the path shall be computed. The special value B_APP_IMAGE_SYMBOL can be used to refer to the program image, and B_CURRENT_IMAGE_SYMBOL for the caller's image.
dependencyThe name of the package's "requires" entry to be used for resolving the installation location. Can be NULL.
architectureThe name of the architecture to be used for resolving architecture dependent paths. Can be NULL, in which case the caller's architecture is used.
baseDirectoryConstant indicating which path to retrieve.
subPathRelative subpath that shall be appended. Can be NULL.
flagsBitwise OR of any of the following flags:
  • B_FIND_PATH_CREATE_DIRECTORY: If the resulting path doesn't exist, create it as a directory (including all missing ancestors).
  • B_FIND_PATH_CREATE_PARENT_DIRECTORY: If the resulting path's parent doesn't exist, create the parent directory (including all missing ancestors).
  • B_FIND_PATH_EXISTING_ONLY: If the resulting path doesn't exist, fail with B_ENTRY_NOT_FOUND.
pathBufferPointer to a pre-allocated buffer the retrieved path shall be stored in.
bufferSizeSize of the pathBuffer buffer.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BUFFER_OVERFLOWThe provided pathBuffer wasn't large enough.
B_ENTRY_NOT_FOUNDA file system entry required for retrieving the path doesn't exist. E.g. B_FIND_PATH_PACKAGE_PATH was specified and the image file doesn't belong to a package, or dependency was specified, but isn't a "requires" entry of the package, or B_FIND_PATH_EXISTING_ONLY was specified and the resulting path doesn't exist.
Since
Haiku R1

◆ find_path_for_path()

status_t find_path_for_path ( const char *  path,
path_base_directory  baseDirectory,
const char *  subPath,
char *  pathBuffer,
size_t  bufferSize 
)

Retrieves a path in the file system layout based on a given path.

Based on the given path path the function evaluates baseDirectory. In most cases that means first determining the path of the installation location from the given path, then appending the relative path corresponding to the given baseDirectory constant, and finally appending subPath, if given.

If baseDirectory specifies a path that is architecture dependent, the architecture associated with the given path (as returned by guess_architecture_for_path()) is used for constructing the path.

If B_FIND_PATH_PACKAGE_PATH is specified, subPath is ignored. In this case the path of the package containing the file referred to by path is returned. B_FIND_PATH_IMAGE_PATH is not a valid argument for this function.

Parameters
pathA path based on which the path shall be computed.
baseDirectoryConstant indicating which path to retrieve.
subPathRelative subpath that shall be appended. Can be NULL.
pathBufferPointer to a pre-allocated buffer the retrieved path shall be stored in.
bufferSizeSize of the pathBuffer buffer.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BUFFER_OVERFLOWThe provided pathBuffer wasn't large enough.
B_ENTRY_NOT_FOUNDA file system entry required for retrieving the path doesn't exist. E.g. B_FIND_PATH_PACKAGE_PATH was specified and path does refer to a file that belongs to a package.
Since
Haiku R1

◆ find_path_for_path_etc()

status_t find_path_for_path_etc ( const char *  path,
const char *  dependency,
const char *  architecture,
path_base_directory  baseDirectory,
const char *  subPath,
uint32  flags,
char *  pathBuffer,
size_t  bufferSize 
)

Retrieves a path in the file system layout based on a given path.

Based on the given path path the function evaluates baseDirectory. In most cases that means first determining the path of the installation location from the given path, then appending the relative path corresponding to the given baseDirectory constant, and finally appending subPath, if given.

If dependency is specified, instead of determining the installation location path from the given path, the installation location path of the dependency dependency of the package containing the file referred to by path is used.

If baseDirectory specifies a path that is architecture dependent, architecture is used for constructing the path. If architecture is NULL, the architecture associated with the given path (as returned by guess_architecture_for_path()) is used.

If B_FIND_PATH_PACKAGE_PATH is specified, dependency and subPath are ignored. In this case the path of the package containing the file referred to by path is returned. B_FIND_PATH_IMAGE_PATH is not a valid argument for this function.

Parameters
pathA path based on which the path shall be computed.
dependencyThe name of the package's "requires" entry to be used for resolving the installation location. Can be NULL.
architectureThe name of the architecture to be used for resolving architecture dependent paths. Can be NULL, in which case the architecture associated with path is used.
baseDirectoryConstant indicating which path to retrieve.
subPathRelative subpath that shall be appended. Can be NULL.
flagsBitwise OR of any of the following flags:
  • B_FIND_PATH_CREATE_DIRECTORY: If the resulting path doesn't exist, create it as a directory (including all missing ancestors).
  • B_FIND_PATH_CREATE_PARENT_DIRECTORY: If the resulting path's parent doesn't exist, create the parent directory (including all missing ancestors).
  • B_FIND_PATH_EXISTING_ONLY: If the resulting path doesn't exist, fail with B_ENTRY_NOT_FOUND.
pathBufferPointer to a pre-allocated buffer the retrieved path shall be stored in.
bufferSizeSize of the pathBuffer buffer.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BUFFER_OVERFLOWThe provided pathBuffer wasn't large enough.
B_ENTRY_NOT_FOUNDA file system entry required for retrieving the path doesn't exist. E.g. B_FIND_PATH_PACKAGE_PATH was specified and path does refer to a file that belongs to a package, or dependency was specified, but isn't a "requires" entry of the package, or B_FIND_PATH_EXISTING_ONLY was specified and the resulting path doesn't exist.
Since
Haiku R1

◆ find_paths()

status_t find_paths ( path_base_directory  baseDirectory,
const char *  subPath,
char ***  _paths,
size_t *  _pathCount 
)

Retrieves a list of paths in the file system layout.

For each installation location – in the order most specific to most generic, non-packaged before packaged – the function evaluates baseDirectory to a path and appends subPath, if given.

If baseDirectory specifies a path that is architecture dependent, the caller's architecture (as returned by get_architecture()) is used for constructing each path.

B_FIND_PATH_PACKAGE_PATH and B_FIND_PATH_IMAGE_PATH are not valid arguments for this function.

The array of paths retrieved is allocated on the heap and returned via _paths. The caller is responsible for calling free() for the returned pointer.

Parameters
baseDirectoryConstant indicating which paths to retrieve.
subPathRelative subpath that shall be appended. Can be NULL.
_pathsPointer to a pre-allocated variable where the pointer to the allocated path array shall be stored on success.
_pathCountPointer to a pre-allocated variable where the number of paths in the path array shall be stored on success.
Returns
A status code.
Return values
B_OKEverything went fine.
B_ENTRY_NOT_FOUNDA file system entry required for retrieving the paths doesn't exist.
Since
Haiku R1

◆ find_paths_etc()

status_t find_paths_etc ( const char *  architecture,
path_base_directory  baseDirectory,
const char *  subPath,
uint32  flags,
char ***  _paths,
size_t *  _pathCount 
)

Retrieves a list of paths in the file system layout.

For each installation location – in the order most specific to most generic, non-packaged before packaged – the function evaluates baseDirectory to a path and appends subPath, if given.

If baseDirectory specifies a path that is architecture dependent, architecture is used for constructing each path. If architecture is NULL, the caller's architecture (as returned by get_architecture()) is used.

B_FIND_PATH_PACKAGE_PATH and B_FIND_PATH_IMAGE_PATH are not valid arguments for this function.

The array of paths retrieved is allocated on the heap and returned via _paths. The caller is responsible for calling free() for the returned pointer.

Parameters
architectureThe name of the architecture to be used for resolving architecture dependent paths. Can be NULL, in which case the caller's architecture is used.
baseDirectoryConstant indicating which paths to retrieve.
subPathRelative subpath that shall be appended. Can be NULL.
flagsBitwise OR of any of the following flags:
  • B_FIND_PATH_CREATE_DIRECTORY: If the resulting path doesn't exist, create it as a directory (including all missing ancestors).
  • B_FIND_PATH_CREATE_PARENT_DIRECTORY: If the resulting path's parent doesn't exist, create the parent directory (including all missing ancestors).
  • B_FIND_PATH_EXISTING_ONLY: If the resulting path doesn't exist, fail with B_ENTRY_NOT_FOUND.
_pathsPointer to a pre-allocated variable where the pointer to the allocated path array shall be stored on success.
_pathCountPointer to a pre-allocated variable where the number of paths in the path array shall be stored on success.
Returns
A status code.
Return values
B_OKEverything went fine.
B_ENTRY_NOT_FOUNDA file system entry required for retrieving the paths doesn't exist. E.g. B_FIND_PATH_EXISTING_ONLY was specified and none of the resulting paths do exist.
Since
Haiku R1