xref: /haiku/docs/user/storage/FindDirectory.dox (revision 4e3137c085bae361922078f123dceb92da700640)
1/*
2 * Copyright 2011-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Documentation by:
6 *		Adrien Destugues, pulkomandy@pulkomandy.ath.cx
7 *		John Scipione, jscipione@gmail.com
8 *		Ingo Weinhold, ingo_weinhold@gmx.de
9 *
10 * Corresponds to:
11 *		headers/os/storage/FindDirectory.h	 hrev47402
12 *		src/kits/storage/FindDirectory.cpp	 hrev47402
13 */
14
15
16/*!
17	\file FindDirectory.h
18	\ingroup storage
19	\ingroup libbe
20	\brief Provides the find_directory(), find_path(), find_paths() functions
21	       as well as the \c directory_which constants.
22
23	Haiku provides a set of directories for applications to use. These can be
24	accessed using the functions find_directory(), find_path(), find_path_etc(),
25	find_paths(), find_paths_etc(), find_path_for_path(),
26	find_path_for_path_etc(). It is very important to use the functions at
27	runtime and not hardcode the path, as it may change in future versions of
28	Haiku, and already changed in past ones. Using these functions makes your
29	application more future-proof, and makes sure everyone puts data in the same
30	place, which makes the system cleaner and easier to manage.
31
32	Note that while the find_directory() function is still needed for some, it
33	is deprecated for many other use cases, like:
34	- When collecting files from all installation locations, be it data files
35	  (like fonts) or add-ons your application/library supports, use
36	  find_paths(), find_paths_etc(), or BPathFinder::FindPaths() instead.
37	  Formerly you had to use find_directory() and iterate through all possible
38	  constants manually. Not only is this less convenient, it also doesn't
39	  account for the possibility of installation locations being added or
40	  removed in a later Haiku release.
41	- If your code needs to access another file that also belongs to your
42	  software (i.e. if packaged it is included in the same package), use
43	  find_path() or BPathFinder::FindPath() instead.
44	  Formerly this case could not really be handled properly. Either you had
45	  to hard-code the installation location by using the respective directory
46	  constant or you had to manually construct a path relative to your code's
47	  image file.
48
49	Cases for which find_directory() is still useful:
50	- Getting per-volume paths like for the trash directory.
51	- Getting specific paths like for the user's home directory or the user's
52	  settings directory.
53
54	Note that these functions can be accessed from C code (they are implemented
55	in libroot), to make it easy to use also in ported applications. However,
56	there are also a C++ version of find_directory() and the BPathFinder class
57	(both implemented in libbe), which may be more convenient to use in C++
58	code.
59*/
60
61
62/*!
63	\enum directory_which
64	\brief Directory constants to use with find_directory().
65
66	There are four kind of directories. Volume-local directories exist on each
67	volume, they may be at a different location in each of them. For example
68	the location of the trash directory depends on the filesystem. System
69	directories are system-wide, they live on only one volume. System is meant
70	for internal system management and system-wide applications. User
71	directories have a different value depending on the UID of the application
72	calling the function. They are usually located in the user's home
73	directory.
74
75	Use system directories for system-wide files such as drivers and use user
76	directories are for application settings, since each user may want
77	different settings.
78
79	\remark The \c B_COMMON_* constants have been intentionally removed in
80	        Haiku R1, use the \c B_SYSTEM_* constants instead.
81
82	\since BeOS R3
83*/
84
85
86/*!
87	\var directory_which B_DESKTOP_DIRECTORY
88	\brief The desktop directory for a given volume.
89
90	\since BeOS R3
91*/
92
93
94/*!
95	\var directory_which B_TRASH_DIRECTORY
96	\brief The trash directory for a given volume.
97
98	\since BeOS R3
99*/
100
101
102/*!
103	\var directory_which B_SYSTEM_DIRECTORY
104	\brief The system directory.
105
106	\since Haiku R1
107*/
108
109
110/*!
111	\var directory_which B_SYSTEM_ADDONS_DIRECTORY
112	\brief The system add-ons directory
113
114	\since Haiku R1
115*/
116
117
118/*!
119	\var directory_which B_SYSTEM_BOOT_DIRECTORY
120	\brief The system boot directory.
121
122	Contains the minimal set of files required for booting Haiku.
123
124	\since Haiku R1
125*/
126
127
128/*!
129	\var directory_which B_SYSTEM_FONTS_DIRECTORY
130	\brief The system fonts directory.
131
132	\since Haiku R1
133*/
134
135
136/*!
137	\var directory_which B_SYSTEM_LIB_DIRECTORY
138	\brief The system lib directory.
139
140	\since Haiku R1
141*/
142
143
144/*!
145	\var directory_which B_SYSTEM_SERVERS_DIRECTORY
146	\brief The system servers directory.
147
148	\since Haiku R1
149*/
150
151
152/*!
153	\var directory_which B_SYSTEM_APPS_DIRECTORY
154	\brief The system applications directory.
155
156	Contains applications with graphical user interface.
157
158	\since Haiku R1
159*/
160
161
162/*!
163	\var directory_which B_SYSTEM_BIN_DIRECTORY
164	\brief The system bin directory.
165
166	Contains command-line applications runnable from Terminal.
167
168	\since Haiku R1
169*/
170
171
172/*!
173	\var directory_which B_SYSTEM_DOCUMENTATION_DIRECTORY
174	\brief The system documentation directory, contains e.g. man pages.
175
176	\since Haiku R1
177*/
178
179
180/*!
181	\var directory_which B_SYSTEM_PREFERENCES_DIRECTORY
182	\brief The system preferences directory.
183
184	\since Haiku R1
185*/
186
187
188/*!
189	\var directory_which B_SYSTEM_TRANSLATORS_DIRECTORY
190	\brief The system translator directory.
191
192	\since Haiku R1
193*/
194
195
196/*!
197	\var directory_which B_SYSTEM_MEDIA_NODES_DIRECTORY
198	\brief The system media nodes directory.
199
200	\since Haiku R1
201*/
202
203
204/*!
205	\var directory_which B_SYSTEM_SOUNDS_DIRECTORY
206	\brief The system sounds directory.
207
208	\since Haiku R1
209*/
210
211
212/*!
213	\var directory_which B_SYSTEM_DATA_DIRECTORY
214	\brief The system data directory.
215
216	\since Haiku R1
217*/
218
219
220/*!
221	\var directory_which B_SYSTEM_DEVELOP_DIRECTORY
222	\brief The system directory containing development related files.
223
224	\since Haiku R1
225*/
226
227
228/*!
229	\var directory_which B_SYSTEM_PACKAGES_DIRECTORY
230	\brief The system directory where activated packages live.
231
232	\since Haiku R1
233*/
234
235
236/*!
237	\var directory_which B_SYSTEM_HEADERS_DIRECTORY
238	\brief The system directory for development header files.
239
240	\since Haiku R1
241*/
242
243
244/*!
245	\var directory_which B_SYSTEM_ETC_DIRECTORY
246	\brief The system directory used for Unix-like installation location-wide
247	       settings (Unix "etc" directory).
248
249	\since Haiku R1
250*/
251
252
253/*!
254	\var directory_which B_SYSTEM_SETTINGS_DIRECTORY
255	\brief The system directory used for installation location-wide settings.
256
257	\since Haiku R1
258*/
259
260
261/*!
262	\var directory_which B_SYSTEM_LOG_DIRECTORY
263	\brief The system directory where log files are put.
264
265	\since Haiku R1
266*/
267
268
269/*!
270	\var directory_which B_SYSTEM_SPOOL_DIRECTORY
271	\brief The system directory for spool data (e.g. pending printer jobs).
272
273	\since Haiku R1
274*/
275
276
277/*!
278	\var directory_which B_SYSTEM_TEMP_DIRECTORY
279	\brief The global directory for temporary files (Unix "tmp" directory).
280
281	\since Haiku R1
282*/
283
284
285/*!
286	\var directory_which B_SYSTEM_VAR_DIRECTORY
287	\brief The system directory for variable data (Unix "var" directory).
288
289	\since Haiku R1
290*/
291
292
293/*!
294	\var directory_which B_SYSTEM_CACHE_DIRECTORY
295	\brief The system directory used for cache files.
296
297	\since Haiku R1
298*/
299
300
301/*!
302	\var directory_which B_SYSTEM_NONPACKAGED_DIRECTORY
303	\brief The system non-packaged installation location directory.
304
305	\since Haiku R1
306*/
307
308
309/*!
310	\var directory_which B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY
311	\brief The system non-packaged add-ons directory
312
313	\since Haiku R1
314*/
315
316
317/*!
318	\var directory_which B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY
319	\brief The system non-packaged translator directory.
320
321	\since Haiku R1
322*/
323
324
325/*!
326	\var directory_which B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY
327	\brief The system non-packaged media nodes directory.
328
329	\since Haiku R1
330*/
331
332
333/*!
334	\var directory_which B_SYSTEM_NONPACKAGED_BIN_DIRECTORY
335	The system non-packaged bin directory. Contains command-line applications
336	\brief runnable from Terminal.
337
338	\since Haiku R1
339*/
340
341
342/*!
343	\var directory_which B_SYSTEM_NONPACKAGED_DATA_DIRECTORY
344	\brief The system non-packaged data directory.
345
346	\since Haiku R1
347*/
348
349
350/*!
351	\var directory_which B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY
352	\brief The system non-packaged fonts directory
353
354	\since Haiku R1
355*/
356
357
358/*!
359	\var directory_which B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY
360	\brief The system non-packaged sounds directory.
361
362	\since Haiku R1
363*/
364
365
366/*!
367	\var directory_which B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY
368	\brief The system non-packaged documentation directory. Contains e.g. man pages.
369
370	\since Haiku R1
371*/
372
373
374/*!
375	\var directory_which B_SYSTEM_NONPACKAGED_LIB_DIRECTORY
376	\brief The system non-packaged lib directory.
377
378	\since Haiku R1
379*/
380
381
382/*!
383	\var directory_which B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY
384	\brief The system non-packaged directory for development header files.
385
386	\since Haiku R1
387*/
388
389
390/*!
391	\var directory_which B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY
392	\brief The system non-packaged directory containing development related
393	       files.
394
395	\since Haiku R1
396*/
397
398
399/*!
400	\var directory_which B_USER_DIRECTORY
401	\brief The user home directory.
402
403	Do NOT store application settings here as on unix, instead use
404	\c B_USER_SETTINGS_DIRECTORY.
405
406	\since BeOS R3
407*/
408
409
410/*!
411	\var directory_which B_USER_CONFIG_DIRECTORY
412	\brief The user packaged installation location directory.
413
414	\since BeOS R3
415*/
416
417
418/*!
419	\var directory_which B_USER_ADDONS_DIRECTORY
420	\brief The user add-ons directory
421
422	\since BeOS R3
423*/
424
425
426/*!
427	\var directory_which B_USER_BOOT_DIRECTORY
428	\brief The user directory containing booting related files.
429
430	\since BeOS R3
431*/
432
433
434/*!
435	\var directory_which B_USER_FONTS_DIRECTORY
436	\brief The user fonts directory.
437
438	\since BeOS R3
439*/
440
441
442/*!
443	\var directory_which B_USER_LIB_DIRECTORY
444	\brief The user lib directory.
445
446	\since BeOS R3
447*/
448
449
450/*!
451	\var directory_which B_USER_SETTINGS_DIRECTORY
452	\brief The user settings directory.
453
454	You may store your application settings here. Create a subdirectory for
455	your application if you have multiple files to store, else, put a single
456	file. The file or directory should have the same name as your
457	application, so the user knows what it's used for.
458
459	\since BeOS R3
460*/
461
462
463/*!
464	\var directory_which B_USER_DESKBAR_DIRECTORY
465	\brief The user Deskbar directory.
466
467	You may add a link to your application here, so it shows up in the user's
468	Deskbar leaf menu.
469
470	\since BeOS R3
471*/
472
473
474/*!
475	\var directory_which B_USER_PRINTERS_DIRECTORY
476	\brief The user directory for printer settings.
477
478	\since Haiku R1
479*/
480
481
482/*!
483	\var directory_which B_USER_TRANSLATORS_DIRECTORY
484	\brief The user translator directory.
485
486	\since Haiku R1
487*/
488
489
490/*!
491	\var directory_which B_USER_MEDIA_NODES_DIRECTORY
492	\brief The user media nodes directory.
493
494	\since Haiku R1
495*/
496
497
498/*!
499	\var directory_which B_USER_SOUNDS_DIRECTORY
500	\brief The user sounds directory.
501
502	\since Haiku R1
503*/
504
505
506/*!
507	\var directory_which B_USER_DATA_DIRECTORY
508	\brief The user data directory.
509
510	\since Haiku R1
511*/
512
513
514/*!
515	\var directory_which B_USER_CACHE_DIRECTORY
516	\brief The user directory used for cache files.
517
518	\since Haiku R1
519*/
520
521
522/*!
523	\var directory_which B_USER_PACKAGES_DIRECTORY
524	\brief The user directory where activated packages live.
525
526	\since Haiku R1
527*/
528
529
530/*!
531	\var directory_which B_USER_HEADERS_DIRECTORY
532	\brief The user directory for development header files.
533
534	\since Haiku R1
535*/
536
537
538/*!
539	\var directory_which B_USER_DEVELOP_DIRECTORY
540	\brief The user directory containing development related files.
541
542	\since Haiku R1
543*/
544
545
546/*!
547	\var directory_which B_USER_DOCUMENTATION_DIRECTORY
548	\brief The user documentation directory, contains e.g. man pages.
549
550	\since Haiku R1
551*/
552
553
554/*!
555	\var directory_which B_USER_SERVERS_DIRECTORY
556	\brief The user servers directory.
557
558	\since Haiku R1
559*/
560
561
562/*!
563	\var directory_which B_USER_APPS_DIRECTORY
564	\brief The user applications directory.
565
566	Contains applications with graphical user interface.
567
568	\since Haiku R1
569*/
570
571
572/*!
573	\var directory_which B_USER_BIN_DIRECTORY
574	\brief The user bin directory.
575
576	Contains command-line applications runnable from Terminal.
577
578	\since Haiku R1
579*/
580
581
582/*!
583	\var directory_which B_USER_PREFERENCES_DIRECTORY
584	\brief The user preference applications directory.
585
586	\since Haiku R1
587*/
588
589
590/*!
591	\var directory_which B_USER_ETC_DIRECTORY
592	\brief The user directory used for Unix-like installation location-wide
593	       settings (Unix "etc" directory).
594
595	\since Haiku R1
596*/
597
598
599/*!
600	\var directory_which B_USER_LOG_DIRECTORY
601	\brief The user directory where log files are put.
602
603	\since Haiku R1
604*/
605
606
607/*!
608	\var directory_which B_USER_SPOOL_DIRECTORY
609	\brief The user directory for spool data, e.g. pending printer jobs.
610
611	\since Haiku R1
612*/
613
614
615/*!
616	\var directory_which B_USER_VAR_DIRECTORY
617	\brief The user directory for variable data (Unix "var" directory).
618
619	\since Haiku R1
620*/
621
622
623/*!
624	\var directory_which B_USER_NONPACKAGED_DIRECTORY
625	\brief The user non-packaged installation location directory.
626
627	\since Haiku R1
628*/
629
630
631/*!
632	\var directory_which B_USER_NONPACKAGED_ADDONS_DIRECTORY
633	\brief The user non-packaged add-ons directory
634
635	\since Haiku R1
636*/
637
638
639/*!
640	\var directory_which B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY
641	\brief The user non-packaged translator directory.
642
643	\since Haiku R1
644*/
645
646
647/*!
648	\var directory_which B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY
649	\brief The user non-packaged media nodes directory.
650
651	\since Haiku R1
652*/
653
654
655/*!
656	\var directory_which B_USER_NONPACKAGED_BIN_DIRECTORY
657	\brief The user non-packaged bin directory.
658
659	Contains command-line applications runnable from Terminal.
660
661	\since Haiku R1
662*/
663
664
665/*!
666	\var directory_which B_USER_NONPACKAGED_DATA_DIRECTORY
667	\brief The user non-packaged data directory.
668
669	\since Haiku R1
670*/
671
672
673/*!
674	\var directory_which B_USER_NONPACKAGED_FONTS_DIRECTORY
675	\brief The user non-packaged fonts directory
676
677	\since Haiku R1
678*/
679
680
681/*!
682	\var directory_which B_USER_NONPACKAGED_SOUNDS_DIRECTORY
683	\brief The user non-packaged sounds directory.
684
685	\since Haiku R1
686*/
687
688
689/*!
690	\var directory_which B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY
691	\brief The user non-packaged documentation directory, contains e.g. man
692	       pages.
693
694	\since Haiku R1
695*/
696
697
698/*!
699	\var directory_which B_USER_NONPACKAGED_LIB_DIRECTORY
700	\brief The user non-packaged lib directory.
701
702	\since Haiku R1
703*/
704
705
706/*!
707	\var directory_which B_USER_NONPACKAGED_HEADERS_DIRECTORY
708	\brief The user non-packaged directory for development header files.
709
710	\since Haiku R1
711*/
712
713
714/*!
715	\var directory_which B_USER_NONPACKAGED_DEVELOP_DIRECTORY
716	\brief The user non-packaged directory containing development related
717	       files.
718
719	\since Haiku R1
720*/
721
722
723/*!
724	\var directory_which B_APPS_DIRECTORY
725	\brief The global applications directory.
726
727	Contains applications with graphical user interface.
728
729	\since BeOS R3
730*/
731
732
733/*!
734	\var directory_which B_PREFERENCES_DIRECTORY
735	\brief The global preference applications directory.
736
737	\since BeOS R3
738*/
739
740
741/*!
742	\var directory_which B_UTILITIES_DIRECTORY
743	\brief The global utility applications directory.
744
745	\since Haiku R1
746*/
747
748
749/*!
750	\var directory_which B_PACKAGE_LINKS_DIRECTORY
751	\brief The global package links directory.
752
753	This is where symlink directories for all activated packages are exposed.
754
755	\since Haiku R1
756*/
757
758
759/*!
760	\var directory_which B_BEOS_DIRECTORY
761	\brief The BeOS directory.
762
763	\deprecated Legacy BeOS definition to be phased out, use
764	            \c B_SYSTEM_DIRECTORY instead.
765
766	\since BeOS R3
767*/
768
769
770/*!
771	\var directory_which B_BEOS_SYSTEM_DIRECTORY
772	\brief The BeOS system directory.
773
774	\deprecated Legacy BeOS definition to be phased out, use
775	            \c B_SYSTEM_DIRECTORY instead.
776
777	\since BeOS R3
778*/
779
780
781/*!
782	\var directory_which B_BEOS_ADDONS_DIRECTORY
783	\brief The BeOS Add-ons directory.
784
785	\deprecated Legacy BeOS definition to be phased out, use
786	            \c B_SYSTEM_ADDONS_DIRECTORY instead.
787
788	\since BeOS R3
789*/
790
791
792/*!
793	\var directory_which B_BEOS_BOOT_DIRECTORY
794	\brief The BeOS boot directory.
795
796	\deprecated Legacy BeOS definition to be phased out, use
797	            \c B_SYSTEM_BOOT_DIRECTORY instead.
798
799	\since BeOS R3
800*/
801
802
803/*!
804	\var directory_which B_BEOS_FONTS_DIRECTORY
805	\brief The BeOS fonts directory.
806
807	\deprecated Legacy BeOS definition to be phased out, use
808	            \c B_SYSTEM_FONTS_DIRECTORY instead.
809
810	\since BeOS R3
811*/
812
813
814/*!
815	\var directory_which B_BEOS_LIB_DIRECTORY
816	\brief The BeOS lib directory.
817
818	\deprecated Legacy BeOS definition to be phased out, use
819	            \c B_SYSTEM_LIB_DIRECTORY instead.
820
821	\since BeOS R3
822*/
823
824
825/*!
826	\var directory_which B_BEOS_SERVERS_DIRECTORY
827	\brief The BeOS servers directory.
828
829	\deprecated Legacy BeOS definition to be phased out, use
830	            \c B_SYSTEM_SERVERS_DIRECTORY instead.
831
832	\since BeOS R3
833*/
834
835
836/*!
837	\var directory_which B_BEOS_APPS_DIRECTORY
838	\brief The BeOS apps directory.
839
840	\deprecated Legacy BeOS definition to be phased out, use
841	            \c B_SYSTEM_APPS_DIRECTORY instead.
842
843	\since BeOS R3
844*/
845
846
847/*!
848	\var directory_which B_BEOS_BIN_DIRECTORY
849	\brief The BeOS bin directory.
850
851	\deprecated Legacy BeOS definition to be phased out, use
852	            \c B_SYSTEM_BIN_DIRECTORY instead.
853
854	\since BeOS R3
855*/
856
857
858/*!
859	\var directory_which B_BEOS_ETC_DIRECTORY
860	\brief The BeOS etc directory used for Unix-like installation location-wide
861	       settings (Unix "etc" directory).
862
863	\deprecated Legacy BeOS definition to be phased out, use
864	            \c B_SYSTEM_ETC_DIRECTORY instead.
865
866	\since BeOS R3
867*/
868
869
870/*!
871	\var directory_which B_BEOS_DOCUMENTATION_DIRECTORY
872	\brief The BeOS documentation directory.
873
874	\deprecated Legacy BeOS definition to be phased out, use
875	            \c B_SYSTEM_DOCUMENTATION_DIRECTORY instead.
876
877	\since BeOS R3
878*/
879
880
881/*!
882	\var directory_which B_BEOS_PREFERENCES_DIRECTORY
883	\brief The BeOS preferences directory.
884
885	\deprecated Legacy BeOS definition to be phased out, use
886	            \c B_SYSTEM_PREFERENCES_DIRECTORY instead.
887
888	\since BeOS R3
889*/
890
891
892/*!
893	\var directory_which B_BEOS_TRANSLATORS_DIRECTORY
894	\brief The BeOS translators directory.
895
896	\deprecated Legacy BeOS definition to be phased out, use
897	            \c B_SYSTEM_TRANSLATORS_DIRECTORY instead.
898
899	\since BeOS R3
900*/
901
902
903/*!
904	\var directory_which B_BEOS_MEDIA_NODES_DIRECTORY
905	\brief The BeOS media nodes directory.
906
907	\deprecated Legacy BeOS definition to be phased out, use
908	            \c B_SYSTEM_MEDIA_NODES_DIRECTORY instead.
909
910	\since BeOS R3
911*/
912
913
914/*!
915	\var directory_which B_BEOS_SOUNDS_DIRECTORY
916	\brief The BeOS sounds directory.
917
918	\deprecated Legacy BeOS definition to be phased out, use
919	            \c B_SYSTEM_SOUNDS_DIRECTORY instead.
920
921	\since BeOS R3
922*/
923
924
925/*!
926	\var directory_which B_BEOS_DATA_DIRECTORY
927	\brief The BeOS data directory.
928
929	\deprecated Legacy BeOS definition to be phased out, use
930	            \c B_SYSTEM_DATA_DIRECTORY instead.
931
932	\since BeOS R3
933*/
934
935
936//// find_path[s]() flags
937
938
939/*!
940	\var B_FIND_PATH_CREATE_DIRECTORY
941	\brief Specifies that if the resulting path doesn't exist, it shall be
942	       created a directory, including all missing ancestors.
943
944	Failure to create the path will cause the respective function to fail.
945
946	Flag for the find_path_etc(), find_path_for_path_etc(), find_paths_etc(),
947	and BPathFinder API.
948
949	\since Haiku R1
950*/
951
952
953/*!
954	\var B_FIND_PATH_CREATE_PARENT_DIRECTORY
955	\brief Specifies that if the resulting path's parent doesn't exist, the
956	       parent shall be created as a directory, including all missing
957	       ancestors.
958
959	Failure to create the directory will cause the respective function to fail.
960
961	Flag for the find_path_etc(), find_path_for_path_etc(), find_paths_etc(),
962	and BPathFinder API.
963
964	\since Haiku R1
965*/
966
967
968/*!
969	\var B_FIND_PATH_EXISTING_ONLY
970	\brief Specifies that if the resulting path doesn't exist, the respective
971	       function shall skip it.
972
973	In case multiple paths shall be retrieved and none of the paths exists,
974	the function shall fail with \c B_ENTRY_NOT_FOUND.
975
976	Flag for the find_path_etc(), find_path_for_path_etc(), find_paths_etc(),
977	and BPathFinder API.
978
979	\since Haiku R1
980*/
981
982
983/*!
984	\enum path_base_directory
985	\brief Path constants to use with find_path(), find_paths(), et al.
986
987	There are two kinds of constants. Those that are based off an installation
988	location and those that based off an image or given path. The latter are not
989	valid argument for all functions.
990
991	\since Haiku R1
992*/
993
994
995/*!
996	\var B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY
997	\brief The installation location base directory.
998
999	\since Haiku R1
1000*/
1001
1002
1003/*!
1004	\var B_FIND_PATH_ADD_ONS_DIRECTORY
1005	\brief The add-ons directory.
1006
1007	\since Haiku R1
1008*/
1009
1010
1011/*!
1012	\var B_FIND_PATH_APPS_DIRECTORY
1013	\brief The application directory.
1014
1015	\since Haiku R1
1016*/
1017
1018
1019/*!
1020	\var B_FIND_PATH_BIN_DIRECTORY
1021	\brief The command line application directory (Unix "bin" directory).
1022
1023	\since Haiku R1
1024*/
1025
1026
1027/*!
1028	\var B_FIND_PATH_BOOT_DIRECTORY
1029	\brief The directory containing booting related files.
1030
1031	\since Haiku R1
1032*/
1033
1034
1035/*!
1036	\var B_FIND_PATH_CACHE_DIRECTORY
1037	\brief The directory used for cache files.
1038
1039	\since Haiku R1
1040*/
1041
1042
1043/*!
1044	\var B_FIND_PATH_DATA_DIRECTORY
1045	\brief The base directory used for read-only data.
1046
1047	\since Haiku R1
1048*/
1049
1050
1051/*!
1052	\var B_FIND_PATH_DEVELOP_DIRECTORY
1053	\brief The directory containing development related files.
1054
1055	\since Haiku R1
1056*/
1057
1058
1059/*!
1060	\var B_FIND_PATH_DEVELOP_LIB_DIRECTORY
1061	\brief The the development library directory.
1062
1063	This is the directory where the linker finds libraries.
1064
1065	\since Haiku R1
1066*/
1067
1068
1069/*!
1070	\var B_FIND_PATH_DOCUMENTATION_DIRECTORY
1071	\brief The base directory used for documentation.
1072
1073	\since Haiku R1
1074*/
1075
1076
1077/*!
1078	\var B_FIND_PATH_ETC_DIRECTORY
1079	\brief The directory used for Unix-like installation location wide
1080	       settings (Unix "etc" directory).
1081
1082	\since Haiku R1
1083*/
1084
1085
1086/*!
1087	\var B_FIND_PATH_FONTS_DIRECTORY
1088	\brief The fonts directory.
1089
1090	\since Haiku R1
1091*/
1092
1093
1094/*!
1095	\var B_FIND_PATH_HEADERS_DIRECTORY
1096	\brief The development header files directory.
1097
1098	\since Haiku R1
1099*/
1100
1101
1102/*!
1103	\var B_FIND_PATH_LIB_DIRECTORY
1104	\brief The runtime library directory.
1105
1106	This is where the runtime loader finds libraries.
1107
1108	\since Haiku R1
1109*/
1110
1111
1112/*!
1113	\var B_FIND_PATH_LOG_DIRECTORY
1114	\brief The directory where log files are put.
1115
1116	\since Haiku R1
1117*/
1118
1119
1120/*!
1121	\var B_FIND_PATH_MEDIA_NODES_DIRECTORY
1122	\brief The media node add-ons directory.
1123
1124	\since Haiku R1
1125*/
1126
1127
1128/*!
1129	\var B_FIND_PATH_PACKAGES_DIRECTORY
1130	\brief The directory where activated packages live.
1131
1132	\since Haiku R1
1133*/
1134
1135
1136/*!
1137	\var B_FIND_PATH_PREFERENCES_DIRECTORY
1138	\brief The preference application directory.
1139
1140	\since Haiku R1
1141*/
1142
1143
1144/*!
1145	\var B_FIND_PATH_SERVERS_DIRECTORY
1146	\brief The server and daemon program directory.
1147
1148	\since Haiku R1
1149*/
1150
1151
1152/*!
1153	\var B_FIND_PATH_SETTINGS_DIRECTORY
1154	\brief The directory used for installation location wide settings.
1155
1156	Note that for the user's home config installation location, this is not
1157	the same as the user's settings directory. Software installed in that
1158	installation location puts their global settings files here.
1159
1160	\since Haiku R1
1161*/
1162
1163
1164/*!
1165	\var B_FIND_PATH_SOUNDS_DIRECTORY
1166	\brief The directory for sound files.
1167
1168	\since Haiku R1
1169*/
1170
1171
1172/*!
1173	\var B_FIND_PATH_SPOOL_DIRECTORY
1174	\brief The directory for spool data, e.g. pending printer jobs.
1175
1176	\since Haiku R1
1177*/
1178
1179
1180/*!
1181	\var B_FIND_PATH_TRANSLATORS_DIRECTORY
1182	\brief The translator add-ons directory.
1183
1184	\since Haiku R1
1185*/
1186
1187
1188/*!
1189	\var B_FIND_PATH_VAR_DIRECTORY
1190	\brief The directory for variable data (Unix "var" directory).
1191
1192	\since Haiku R1
1193*/
1194
1195
1196/*!
1197	\var B_FIND_PATH_IMAGE_PATH
1198	\brief The path of the image file that was identified by a pointer
1199	       argument passed to the respective function.
1200
1201	\since Haiku R1
1202*/
1203
1204
1205/*!
1206	\var B_FIND_PATH_PACKAGE_PATH
1207	\brief The path of the package the file referred to by the specified path
1208	       belongs to.
1209
1210	\since Haiku R1
1211*/
1212
1213
1214/*!
1215
1216
1217/*!
1218	\fn status_t find_directory(directory_which which, dev_t volume,
1219		bool createIt, char* pathString, int32 length)
1220	\brief C interface to find_directory
1221
1222	Fills up to \a length characters of \a pathString with the path to \a which
1223	on \a volume. Creates the directory if it doesn't exists if \a createIt is
1224	set.
1225
1226	\since BeOS R3
1227*/
1228
1229
1230/*!
1231	\fn status_t find_directory(directory_which which, BPath* path, bool createIt,
1232		BVolume* volume)
1233	\brief C++ interface to find_directory
1234
1235	Set \a path to \a which on \a volume.
1236
1237	\since BeOS R3
1238*/
1239
1240
1241/*!
1242	\fn status_t find_path(const void* codePointer,
1243		path_base_directory baseDirectory, const char* subPath,
1244		char* pathBuffer, size_t bufferSize)
1245	\brief Retrieves a path in the file system layout based on a loaded image
1246	       file.
1247
1248	The function determines the path of the image (i.e. executable, library, or
1249	add-on) file associated with \a codePointer, a pointer to a location in the
1250	code or static data of an image loaded in the caller's team. Based on that,
1251	path \a baseDirectory is evaluated. In most cases that means first
1252	determining the path of the installation location from the path, then
1253	appending the relative path corresponding to the given \a baseDirectory
1254	constant, and finally appending \a subPath, if given.
1255
1256	If \a baseDirectory specifies a path that is architecture dependent, the
1257	caller's architecture (as returned by get_architecture()) is used for
1258	constructing the path.
1259
1260	If \c B_FIND_PATH_IMAGE_PATH or \c B_FIND_PATH_PACKAGE_PATH are
1261	specified, \a subPath is ignored. In the former case the path of the image
1262	file is returned. In the latter case the path of the package containing the
1263	image file, if any.
1264
1265	\param codePointer A pointer to code or static data belonging to the image
1266	       based on which the path shall be computed. The special value
1267	       \c B_APP_IMAGE_SYMBOL can be used to refer to the program image, and
1268	       \c B_CURRENT_IMAGE_SYMBOL for the caller's image.
1269	\param baseDirectory Constant indicating which path to retrieve.
1270	\param subPath Relative subpath that shall be appended. Can be \c NULL.
1271	\param pathBuffer Pointer to a pre-allocated buffer the retrieved path
1272	       shall be stored in.
1273	\param bufferSize Size of the \a pathBuffer buffer.
1274	\return A status code.
1275	\retval B_OK Everything went fine.
1276	\retval B_BUFFER_OVERFLOW The provided \a pathBuffer wasn't large enough.
1277	\retval B_ENTRY_NOT_FOUND A file system entry required for retrieving the
1278	        path doesn't exist. E.g. \c B_FIND_PATH_PACKAGE_PATH was specified
1279	        and the image file doesn't belong to a package.
1280
1281	\since Haiku R1
1282*/
1283
1284
1285/*!
1286	\fn status_t find_path_etc(const void* codePointer, const char* dependency,
1287		const char* architecture, path_base_directory baseDirectory,
1288		const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize)
1289	\brief Retrieves a path in the file system layout based on a loaded image
1290	       file.
1291
1292	The function determines the path of the image (i.e. executable, library, or
1293	add-on) file associated with \a codePointer, a pointer to a location in the
1294	code or static data of an image loaded in the caller's team. Based on that,
1295	path \a baseDirectory is evaluated. In most cases that means first
1296	determining the path of the installation location from the path, then
1297	appending the relative path corresponding to the given \a baseDirectory
1298	constant, and finally appending \a subPath, if given.
1299
1300	If \a dependency is specified, instead of determining the installation
1301	location path from the image path, the installation location path of the
1302	dependency \a dependency of the package containing the image file is used.
1303
1304	If \a baseDirectory specifies a path that is architecture dependent,
1305	\a architecture is used for constructing the path. If \a architecture is
1306	\c NULL, the caller's architecture (as returned by get_architecture()) is
1307	used.
1308
1309	If \c B_FIND_PATH_IMAGE_PATH or \c B_FIND_PATH_PACKAGE_PATH are
1310	specified, \a dependency and \a subPath are ignored. In the former case the
1311	path of the image file is returned. In the latter case the path of the
1312	package containing the image file, if any.
1313
1314	\param codePointer A pointer to code or static data belonging to the image
1315	       based on which the path shall be computed. The special value
1316	       \c B_APP_IMAGE_SYMBOL can be used to refer to the program image, and
1317	       \c B_CURRENT_IMAGE_SYMBOL for the caller's image.
1318	\param dependency The name of the package's "requires" entry to be used for
1319	       resolving the installation location. Can be \c NULL.
1320	\param architecture The name of the architecture to be used for resolving
1321	       architecture dependent paths. Can be \c NULL, in which case the
1322	       caller's architecture is used.
1323	\param baseDirectory Constant indicating which path to retrieve.
1324	\param subPath Relative subpath that shall be appended. Can be \c NULL.
1325	\param flags Bitwise OR of any of the following flags:
1326	       - \c B_FIND_PATH_CREATE_DIRECTORY: If the resulting path doesn't
1327	         exist, create it as a directory (including all missing ancestors).
1328	       - \c B_FIND_PATH_CREATE_PARENT_DIRECTORY: If the resulting path's
1329	         parent doesn't exist, create the parent directory (including all
1330	         missing ancestors).
1331	       - \c B_FIND_PATH_EXISTING_ONLY: If the resulting path doesn't exist,
1332	         fail with \c B_ENTRY_NOT_FOUND.
1333	\param pathBuffer Pointer to a pre-allocated buffer the retrieved path
1334	       shall be stored in.
1335	\param bufferSize Size of the \a pathBuffer buffer.
1336	\return A status code.
1337	\retval B_OK Everything went fine.
1338	\retval B_BUFFER_OVERFLOW The provided \a pathBuffer wasn't large enough.
1339	\retval B_ENTRY_NOT_FOUND A file system entry required for retrieving the
1340	        path doesn't exist. E.g. \c B_FIND_PATH_PACKAGE_PATH was specified
1341	        and the image file doesn't belong to a package, or \c dependency
1342	        was specified, but isn't a "requires" entry of the package, or
1343	        \c B_FIND_PATH_EXISTING_ONLY was specified and the resulting path
1344	        doesn't exist.
1345
1346	\since Haiku R1
1347*/
1348
1349
1350/*!
1351	\fn status_t find_path_for_path(const char* path,
1352		path_base_directory baseDirectory, const char* subPath,
1353		char* pathBuffer, size_t bufferSize)
1354	\brief Retrieves a path in the file system layout based on a given path.
1355
1356	Based on the given path \a path the function evaluates \a baseDirectory. In
1357	most cases that means first determining the path of the installation
1358	location from the given path, then appending the relative path corresponding
1359	to the given \a baseDirectory constant, and finally appending \a subPath, if
1360	given.
1361
1362	If \a baseDirectory specifies a path that is architecture dependent, the
1363	architecture associated with the given path (as returned by
1364	guess_architecture_for_path()) is used for constructing the path.
1365
1366	If \c B_FIND_PATH_PACKAGE_PATH is specified, \a subPath is ignored. In
1367	this case the path of the package containing the file referred to by \a path
1368	is returned. \c B_FIND_PATH_IMAGE_PATH is not a valid argument for this
1369	function.
1370
1371	\param path A path based on which the path shall be computed.
1372	\param baseDirectory Constant indicating which path to retrieve.
1373	\param subPath Relative subpath that shall be appended. Can be \c NULL.
1374	\param pathBuffer Pointer to a pre-allocated buffer the retrieved path
1375	       shall be stored in.
1376	\param bufferSize Size of the \a pathBuffer buffer.
1377	\return A status code.
1378	\retval B_OK Everything went fine.
1379	\retval B_BUFFER_OVERFLOW The provided \a pathBuffer wasn't large enough.
1380	\retval B_ENTRY_NOT_FOUND A file system entry required for retrieving the
1381	        path doesn't exist. E.g. \c B_FIND_PATH_PACKAGE_PATH was specified
1382	        and \a path does refer to a file that belongs to a package.
1383
1384	\since Haiku R1
1385*/
1386
1387
1388/*!
1389	\fn status_t find_path_for_path_etc(const char* path,
1390		const char* dependency, const char* architecture,
1391		path_base_directory baseDirectory, const char* subPath, uint32 flags,
1392		char* pathBuffer, size_t bufferSize)
1393	\brief Retrieves a path in the file system layout based on a given path.
1394
1395	Based on the given path \a path the function evaluates \a baseDirectory. In
1396	most cases that means first determining the path of the installation
1397	location from the given path, then appending the relative path corresponding
1398	to the given \a baseDirectory constant, and finally appending \a subPath, if
1399	given.
1400
1401	If \a dependency is specified, instead of determining the installation
1402	location path from the given path, the installation location path of the
1403	dependency \a dependency of the package containing the file referred to by
1404	\a path is used.
1405
1406	If \a baseDirectory specifies a path that is architecture dependent,
1407	\a architecture is used for constructing the path. If \a architecture is
1408	\c NULL, the architecture associated with the given path (as returned by
1409	guess_architecture_for_path()) is used.
1410
1411	If \c B_FIND_PATH_PACKAGE_PATH is specified, \a dependency and
1412	\a subPath are ignored. In this case the path of the package containing the
1413	file referred to by \a path is returned. \c B_FIND_PATH_IMAGE_PATH is not
1414	a valid argument for this function.
1415
1416	\param path A path based on which the path shall be computed.
1417	\param dependency The name of the package's "requires" entry to be used for
1418	       resolving the installation location. Can be \c NULL.
1419	\param architecture The name of the architecture to be used for resolving
1420	       architecture dependent paths. Can be \c NULL, in which case the
1421	       architecture associated with \a path is used.
1422	\param baseDirectory Constant indicating which path to retrieve.
1423	\param subPath Relative subpath that shall be appended. Can be \c NULL.
1424	\param flags Bitwise OR of any of the following flags:
1425	       - \c B_FIND_PATH_CREATE_DIRECTORY: If the resulting path doesn't
1426	         exist, create it as a directory (including all missing ancestors).
1427	       - \c B_FIND_PATH_CREATE_PARENT_DIRECTORY: If the resulting path's
1428	         parent doesn't exist, create the parent directory (including all
1429	         missing ancestors).
1430	       - \c B_FIND_PATH_EXISTING_ONLY: If the resulting path doesn't exist,
1431	         fail with \c B_ENTRY_NOT_FOUND.
1432	\param pathBuffer Pointer to a pre-allocated buffer the retrieved path
1433	       shall be stored in.
1434	\param bufferSize Size of the \a pathBuffer buffer.
1435	\return A status code.
1436	\retval B_OK Everything went fine.
1437	\retval B_BUFFER_OVERFLOW The provided \a pathBuffer wasn't large enough.
1438	\retval B_ENTRY_NOT_FOUND A file system entry required for retrieving the
1439	        path doesn't exist. E.g. \c B_FIND_PATH_PACKAGE_PATH was specified
1440	        and \a path does refer to a file that belongs to a package, or
1441	        \c dependency was specified, but isn't a "requires" entry of the
1442	        package, or \c B_FIND_PATH_EXISTING_ONLY was specified and the
1443	        resulting path doesn't exist.
1444
1445	\since Haiku R1
1446*/
1447
1448
1449/*!
1450	\fn status_t find_paths(path_base_directory baseDirectory,
1451		const char* subPath, char*** _paths, size_t* _pathCount)
1452	\brief Retrieves a list of paths in the file system layout.
1453
1454	For each installation location -- in the order most specific to most
1455	generic, non-packaged before packaged -- the function evaluates
1456	\a baseDirectory to a path and appends \a subPath, if given.
1457
1458	If \a baseDirectory specifies a path that is architecture dependent,
1459	the caller's architecture (as returned by get_architecture()) is used for
1460	constructing each path.
1461
1462	\c B_FIND_PATH_PACKAGE_PATH and \c B_FIND_PATH_IMAGE_PATH are not
1463	valid arguments for this function.
1464
1465	The array of paths retrieved is allocated on the heap and returned via
1466	\a _paths. The caller is responsible for calling free() for the returned
1467	pointer.
1468
1469	\param baseDirectory Constant indicating which paths to retrieve.
1470	\param subPath Relative subpath that shall be appended. Can be \c NULL.
1471	\param _paths Pointer to a pre-allocated variable where the pointer to the
1472	       allocated path array shall be stored on success.
1473	\param _pathCount Pointer to a pre-allocated variable where the number of
1474	       paths in the path array shall be stored on success.
1475
1476	\return A status code.
1477	\retval B_OK Everything went fine.
1478	\retval B_ENTRY_NOT_FOUND A file system entry required for retrieving the
1479	        paths doesn't exist.
1480
1481	\since Haiku R1
1482*/
1483
1484
1485/*!
1486	\fn status_t find_paths_etc(const char* architecture,
1487		path_base_directory baseDirectory, const char* subPath, uint32 flags,
1488		char*** _paths, size_t* _pathCount)
1489	\brief Retrieves a list of paths in the file system layout.
1490
1491	For each installation location -- in the order most specific to most
1492	generic, non-packaged before packaged -- the function evaluates
1493	\a baseDirectory to a path and appends \a subPath, if given.
1494
1495	If \a baseDirectory specifies a path that is architecture dependent,
1496	\a architecture is used for constructing each path. If \a architecture is
1497	\c NULL, the caller's architecture (as returned by get_architecture()) is
1498	used.
1499
1500	\c B_FIND_PATH_PACKAGE_PATH and \c B_FIND_PATH_IMAGE_PATH are not
1501	valid arguments for this function.
1502
1503	The array of paths retrieved is allocated on the heap and returned via
1504	\a _paths. The caller is responsible for calling free() for the returned
1505	pointer.
1506
1507	\param architecture The name of the architecture to be used for resolving
1508	       architecture dependent paths. Can be \c NULL, in which case the
1509	       caller's architecture is used.
1510	\param baseDirectory Constant indicating which paths to retrieve.
1511	\param subPath Relative subpath that shall be appended. Can be \c NULL.
1512	\param flags Bitwise OR of any of the following flags:
1513	       - \c B_FIND_PATH_CREATE_DIRECTORY: If the resulting path doesn't
1514	         exist, create it as a directory (including all missing ancestors).
1515	       - \c B_FIND_PATH_CREATE_PARENT_DIRECTORY: If the resulting path's
1516	         parent doesn't exist, create the parent directory (including all
1517	         missing ancestors).
1518	       - \c B_FIND_PATH_EXISTING_ONLY: If the resulting path doesn't exist,
1519	         fail with \c B_ENTRY_NOT_FOUND.
1520	\param _paths Pointer to a pre-allocated variable where the pointer to the
1521	       allocated path array shall be stored on success.
1522	\param _pathCount Pointer to a pre-allocated variable where the number of
1523	       paths in the path array shall be stored on success.
1524	\return A status code.
1525	\retval B_OK Everything went fine.
1526	\retval B_ENTRY_NOT_FOUND A file system entry required for retrieving the
1527	        paths doesn't exist. E.g. \c B_FIND_PATH_EXISTING_ONLY was
1528	        specified and none of the resulting paths do exist.
1529
1530	\since Haiku R1
1531*/
1532