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