Provides the find_directory(), find_path(), find_paths() functions as well as the directory_which
constants.
More...
Functions | |
status_t | find_directory (directory_which which, BPath *path, bool createIt=false, BVolume *volume=NULL) |
C++ interface to find_directory. More... | |
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_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... | |
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.
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.
|
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.
|
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 Flag for the find_path_etc(), find_path_for_path_etc(), find_paths_etc(), and BPathFinder API.
|
enum 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.
B_COMMON_*
constants have been intentionally removed in Haiku R1, use the B_SYSTEM_*
constants instead.enum 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.