Loading...
Searching...
No Matches
Files | Functions
(libroot.so)

Implements the C and POSIX standard libraries. More...

Files

file  parsedate.h
 Date parsing functions.
 
file  syslog.h
 System logging capabilities.
 

Functions

status_t find_directory (directory_which which, dev_t volume, bool createIt, char *pathString, int32 length)
 C interface to find_directory.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 

Detailed Description

Implements the C and POSIX standard libraries.

Function Documentation

◆ find_directory()

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_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