HaikuPorts
  • Login
  • Preferences
  • Help/Guide
  • Wiki
  • Timeline
  • Roadmap
  • View Tickets
  • Search
  • Port Log
  • Blog

Context Navigation

  • ← Previous Change
  • Wiki History
  • Next Change →

Changes between Version 1 and Version 2 of SandBox


Ignore:
Timestamp:
11/27/09 13:59:20 (6 years ago)
Author:
mmadia
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SandBox

    v1 v2  
    1 = The Sandbox = 
     1= Finding a Directory's Path = 
     2When 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. 
    23 
    3 This is just a page to practice and learn WikiFormatting.  
     4== Terminal == 
     5{{{ 
     6export USER_SETTINGS_DIRECTORY=`/bin/finddir B_USER_SETTINGS_DIRECTORY` 
     7}}} 
     8To test this, try {{{ finddir B_USER_SETTINGS_DIRECTORY }}} 
    49 
    5 Go ahead, edit it freely. 
     10== Shell Script == 
     11{{{ 
     12APPS_DIR=`finddir B_APPS_DIRECTORY` 
     13echo ${APPS_DIR} 
     14}}} 
     15 
     16== Makefile == 
     17# Assuming the makefile sets  
     18{{{ 
     19APPS_DIR:=$(shell finddir B_APPS_DIRECTORY) 
     20}}} 
     21 
     22== C == 
     23{{{ 
     24#!rst 
     25diff -urN tuxpaint-0.9.21/src/fonts.c tuxpaint-0.9.21-haiku/src/fonts.c 
     26--- tuxpaint-0.9.21/src/fonts.c 2009-06-06 18:22:00.000000000 +0000 
     27+++ tuxpaint-0.9.21-haiku/src/fonts.c   2009-10-07 07:39:18.000000000 +0000 
     28@@ -67,6 +67,11 @@ 
     29 #include "win32_print.h" 
     30 #endif 
     31  
     32+#ifdef __HAIKU__ 
     33+#include <FindDirectory.h> 
     34+#include <fs_info.h> 
     35+#endif 
     36+ 
     37 #ifdef __APPLE__ 
     38 #include "wrapperdata.h" 
     39 extern WrapperData macosx; 
     40@@ -699,6 +704,14 @@ 
     41     loadfonts(screen, "/boot/home/config/font/ttffonts"); 
     42     loadfonts(screen, "/usr/share/fonts"); 
     43     loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); 
     44+#elif defined(__HAIKU__) 
     45+       dev_t volume = dev_for_path("/boot"); 
     46+       char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH]; 
     47+       status_t result; 
     48+    result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); 
     49+       loadfonts(screen, buffer); 
     50+    result = find_directory(B_COMMON_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); 
     51+       loadfonts(screen, buffer); 
     52 #elif defined(__APPLE__) 
     53     loadfonts(screen, "/System/Library/Fonts"); 
     54     loadfonts(screen, "/Library/Fonts"); 
     55}}} 
     56 
     57== C++ == 
     58{{{ 
     59#!cpp 
     60// Note: This is untested! 
     61 
     62#ifdef __HAIKU__ 
     63#include <FindDirectory.h> 
     64#include <fs_info.h> 
     65#endif 
     66         
     67// ... 
     68 
     69BPath dir; 
     70result = find_directory(B_SYSTEM_FONTS_DIRECTORY, &dir); 
     71loadfonts(screen, dir.Path()); 
     72result = find_directory(B_COMMON_FONTS_DIRECTORY, &dir); 
     73loadfonts(screen, dir.Path()); 
     74}}} 

Trac Powered

Powered by Trac 0.13dev-r10686
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/