= Finding a Directory's Path = When referencing paths, it is best to use Haiku's Find Directory functionality. The system defines numerous key directories in the [http://dev.haiku-os.org/browser/haiku/trunk/headers/os/storage/FindDirectory.h os/storage/FindDirectory.h] header. In addition to C/C++, a command line utility `finddir` can be used with the same variable names. == Terminal == {{{ export USER_SETTINGS_DIRECTORY=`/bin/finddir B_USER_SETTINGS_DIRECTORY` }}} To test this, try {{{ finddir B_USER_SETTINGS_DIRECTORY }}} == Shell Script == {{{ APPS_DIR=`finddir B_APPS_DIRECTORY` echo ${APPS_DIR} }}} == Makefile == # Assuming the makefile sets {{{ APPS_DIR:=$(shell finddir B_APPS_DIRECTORY) }}} == C == {{{ #!rst diff -urN tuxpaint-0.9.21/src/fonts.c tuxpaint-0.9.21-haiku/src/fonts.c --- tuxpaint-0.9.21/src/fonts.c 2009-06-06 18:22:00.000000000 +0000 +++ tuxpaint-0.9.21-haiku/src/fonts.c 2009-10-07 07:39:18.000000000 +0000 @@ -67,6 +67,11 @@ #include "win32_print.h" #endif +#ifdef __HAIKU__ +#include +#include +#endif + #ifdef __APPLE__ #include "wrapperdata.h" extern WrapperData macosx; @@ -699,6 +704,14 @@ loadfonts(screen, "/boot/home/config/font/ttffonts"); loadfonts(screen, "/usr/share/fonts"); loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); +#elif defined(__HAIKU__) + dev_t volume = dev_for_path("/boot"); + char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH]; + status_t result; + result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); + loadfonts(screen, buffer); + result = find_directory(B_COMMON_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); + loadfonts(screen, buffer); #elif defined(__APPLE__) loadfonts(screen, "/System/Library/Fonts"); loadfonts(screen, "/Library/Fonts"); }}} == C++ == {{{ #!cpp // Note: This is untested! #ifdef __HAIKU__ #include #include #endif // ... BPath dir; result = find_directory(B_SYSTEM_FONTS_DIRECTORY, &dir); loadfonts(screen, dir.Path()); result = find_directory(B_COMMON_FONTS_DIRECTORY, &dir); loadfonts(screen, dir.Path()); }}} == Python == {{{ #!python #!/bin/env python import commands # Creating a utility function def FindDirectory(aDir): result = commands.getoutput('finddir %s' % aDir) return result if __name__ == "__main__": # Using the utility function ... B_APPS_DIRECTORY = FindDirectory('B_APPS_DIRECTORY') print 'Using utility function:' print B_APPS_DIRECTORY # Set a baloney value, to display functionality B_APPS_DIRECTORY='Some Text to display the value being set properly' print 'After setting a baloney value:' print B_APPS_DIRECTORY # As a one liner ... B_APPS_DIRECTORY = commands.getoutput('finddir B_APPS_DIRECTORY') print 'Using a one liner:' print B_APPS_DIRECTORY }}}