BRL-CAD
|
Routines for application setup and supplying information to user programs. More...
Files | |
file | app.h |
Enumerations | |
enum | bu_dir_t { BU_DIR_CURR =1 , BU_DIR_INIT , BU_DIR_BIN , BU_DIR_LIB , BU_DIR_LIBEXEC , BU_DIR_INCLUDE , BU_DIR_DATA , BU_DIR_DOC , BU_DIR_MAN , BU_DIR_TEMP , BU_DIR_HOME , BU_DIR_CACHE , BU_DIR_CONFIG , BU_DIR_EXT , BU_DIR_LIBEXT , BU_DIR_END } |
BRL-CAD specific path queries. More... | |
Functions | |
DEPRECATED const char * | bu_argv0_full_path (void) |
char * | bu_getcwd (char *buf, size_t size) |
char * | bu_getiwd (char *buf, size_t size) |
const char * | bu_getprogname (void) |
void | bu_setprogname (const char *path) |
const char * | bu_which (const char *cmd) |
const char * | bu_whereis (const char *cmd) |
FILE * | bu_temp_file (char *filepath, size_t len) |
Routine to open a temporary file. | |
const char * | bu_temp_file_name (char *filename, size_t len) |
int | bu_fchmod (int fd, unsigned long pmode) |
Wrapper around fchmod. | |
const char * | bu_dir (char *result, size_t len,...) |
void | bu_mkdir (const char *path) |
void | bu_dirclear (const char *d) |
Routines for application setup and supplying information to user programs.
Routines for inspecting and reporting characteristics of the current running application environment.
BRL-CAD specific path queries.
|
extern |
DEPRECATED: This routine is replaced by bu_getcwd(). Do not use.
returns the full path to argv0, regardless of how the application was invoked.
this routine will return "(BRL-CAD)" if argv[0] cannot be identified but should never return NULL. this routine is not thread-safe.
Routine for obtaining the current working directory.
Result is written into the provided buf, up to size chars, and returned. If buf is NULL, dynamically allocated memory will be returned and must be free'd via bu_free().
Routine for obtaining the initial working directory during application startup.
Result is written into the provided buf, up to size chars, and returned. If buf is NULL, dynamically allocated memory will be returned and must be free'd via bu_free().
Get the name of the running application. application codes should call bu_setprogname() first to ensure that the program name is stored appropriately on platforms that do not have an intrinsic method for tracking the program name automatically.
while this routine is thread-safe and reentrant, the static string returned is shared amongst all threads.
Set the name of the running application. This isn't strictly necessary on platforms that have an intrinsic method for tracking the program name automatically, but is still recommended for portability and is necessary on some strict modes of compilation.
while the implementation relies on a static string shared across all threads, this routine is thread-safe and reentrant.
returns the first USER path match to a given executable name.
Routine to provide BSD "which" functionality, locating binaries of specified programs from the user's PATH. This is useful to locate binaries and resources at run-time.
caller should not free the result, though it will not be preserved between calls either. the caller should strdup the result if they need to keep it around.
routine will return NULL if the executable command cannot be found.
returns the first SYSTEM path match to a given executable cmd name.
Routine to provide BSD "whereis" functionality, locating binaries of specified programs from the SYSTEM path. This is useful to locate binaries and resources at run-time.
caller should not free the result, though it will not be preserved between calls either. the caller should strdup the result if they need to keep it around.
routine will return NULL if the executable command cannot be found.
Routine to open a temporary file.
Create a temporary file. The first readable/writable directory will be used, searching TMPDIR/TEMP/TMP environment variable directories followed by default system temp directories and ultimately trying the current directory.
The name of the temporary file will be copied into a user-provided (filepath) buffer if it is a non-NULL pointer and of a sufficient (len) length to contain the filename.
This routine is guaranteed to return a new unique file or return NULL on failure. The file should be closed via fclose() when it is no longer needed. The temporary file will be automatically unlinked on application exit. It is the caller's responsibility to set file access settings, preserve file contents, or destroy file contents if the default behavior is non-optimal.
The temporary file may no longer exist after a call to fclose(), so do not close a handle until you are are done accessing it. Calling fileno()+dup()+fdopen() can obtain a second handle on an open file.
This routine is NOT thread-safe.
Typical Use:
Generate a temporary file name using a prefix (if supplied), the current process ID, and the current thread's ID
This function writes into buffer and returns a temporary file name that is unique to a process / thread pair. The caller can further distinguish the generated name using a specified filename prefix. When not supplied, the PACKAGE_NAME (BRL-CAD) is used as the prefix.
Note that the filename parameter doubles as both a prefix specifier as well as a return buffer.
filename | prefixes the name, doubles as return buffer if len is set |
len | total size of the available filename buffer |
Wrapper around fchmod.
Portable wrapper for setting a file descriptor's permissions ala fchmod().
Find a particular user, system, or runtime directory.
This function writes into buffer and returns, if found, the path to a given filesystm resource. The caller may specify paths to subdirectories and/or filenames as a NULL-terminated vararg list.
Paths returned will use the native directory separator. Callers may also manually concatenate subdirectory resources (e.g., "share/db/moss.g") using forward slashes and they will be converted to the native separator.
result | if non-NULL, buffer should have >= MAXPATHLEN chars |
len | is the size of the result buffer |
... | must be one of the above enumerations or a string/path |
Create a directory specified by the string "path". Default mode on platforms using mkdir will be "775"