Blender V5.3
appdir.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <cstdio>
12#include <cstdlib>
13#include <cstring>
14
15#include "BLI_fileops.hh"
16#include "BLI_fileops_types.hh"
17#include "BLI_listbase.hh"
18#include "BLI_path_utils.hh"
19#include "BLI_string.hh"
20#include "BLI_string_utils.hh"
21#include "BLI_tempfile.hh"
22#include "BLI_utildefines.hh"
23#include "BLI_vector.hh"
24
25#include "BKE_appdir.hh" /* own include */
26#include "BKE_blender_version.h"
27
28#include "BLT_translation.hh"
29
30#include "GHOST_ISystemPaths.hh"
31
32#include "CLG_log.h"
33
34#ifdef WIN32
35# include "BLI_string_utf8.hh"
36# include "utf_winfunc.hh"
37# include "utfconv.hh"
38# include <io.h>
39# ifdef _WIN32_IE
40# undef _WIN32_IE
41# endif
42# define _WIN32_IE 0x0501
43# include "BLI_winstuff.hh"
44# include <shlobj.h>
45# include <windows.h>
46#else /* non windows */
47# ifdef WITH_BINRELOC
48# include "binreloc.h"
49# endif
50/* #mkdtemp on OSX (and probably all *BSD?), not worth making specific check for this OS. */
51# include <unistd.h>
52#endif /* !WIN32 */
53
54namespace blender {
55
56static const char _str_null[] = "(null)";
57#define STR_OR_FALLBACK(a) ((a) ? (a) : _str_null)
58
59/* -------------------------------------------------------------------- */
62
63/* local */
64static CLG_LogRef LOG = {"system.path"};
65
81
83
84/* -------------------------------------------------------------------- */
87
88#ifndef NDEBUG
89static bool is_appdir_init = false;
90# define ASSERT_IS_INIT() BLI_assert(is_appdir_init)
91#else
92# define ASSERT_IS_INIT() ((void)0)
93#endif /* NDEBUG */
94
96{
97#ifndef NDEBUG
98 BLI_assert(is_appdir_init == false);
99 is_appdir_init = true;
100#endif
101}
102
104{
105 /* System paths can be created on-demand by calls to this API. So they need to be properly
106 * disposed of here. Note that there may be several calls to this in `exit` process
107 * (e.g. `wm_init/wm_exit` will currently both call GHOST API directly,
108 * & `BKE_appdir_init/_exit`). */
110#ifndef NDEBUG
111 BLI_assert(is_appdir_init == true);
112 is_appdir_init = false;
113#endif
114}
115
117
118/* -------------------------------------------------------------------- */
121
125static char *blender_version_decimal(const int version)
126{
127 static char version_str[5];
128 BLI_assert(version < 1000);
129 SNPRINTF(version_str, "%d.%d", version / 100, version % 100);
130 return version_str;
131}
132
134
135/* -------------------------------------------------------------------- */
138
140{
141#ifndef WIN32
142 return BLI_dir_home();
143#else /* Windows */
144 static char documentfolder[FILE_MAXDIR];
145
146 if (BKE_appdir_folder_documents(documentfolder)) {
147 return documentfolder;
148 }
149
150 return nullptr;
151#endif /* WIN32 */
152}
153
155{
156#ifndef WIN32
157 return "/";
158#else
159 static char root[4];
161 return root;
162#endif
163}
164
166{
167 const char *path = BKE_appdir_folder_default();
168 if (path == nullptr) {
169 path = BKE_appdir_folder_root();
170 }
171 return path;
172}
173
175{
176 dir[0] = '\0';
177
178 const GHOST_ISystemPaths *ghost_system_paths = GHOST_ISystemPaths::get();
179 const std::optional<std::string> documents_path = ghost_system_paths->getUserSpecialDir(
181
182 /* Usual case: Ghost gave us the documents path. We're done here. */
183 if (documents_path && BLI_is_dir(documents_path->c_str())) {
184 BLI_strncpy(dir, documents_path->c_str(), FILE_MAXDIR);
185 return true;
186 }
187
188 /* Ghost couldn't give us a documents path, let's try if we can find it ourselves. */
189
190 const char *home_path = BLI_dir_home();
191 if (!home_path || !BLI_is_dir(home_path)) {
192 return false;
193 }
194
195 char try_documents_path[FILE_MAXDIR];
196 /* Own attempt at getting a valid Documents path. */
197 BLI_path_join(try_documents_path, sizeof(try_documents_path), home_path, N_("Documents"));
198 if (!BLI_is_dir(try_documents_path)) {
199 return false;
200 }
201
202 BLI_strncpy(dir, try_documents_path, FILE_MAXDIR);
203 return true;
204}
205
206void BKE_appdir_folder_caches(char *path, const size_t path_maxncpy)
207{
208 path[0] = '\0';
209
210 const GHOST_ISystemPaths *ghost_system_paths = GHOST_ISystemPaths::get();
211 std::optional<std::string> caches_root_path = ghost_system_paths->getUserSpecialDir(
213 if (!caches_root_path || caches_root_path->empty()) [[unlikely]] {
214 const char *tempdir = BKE_tempdir_session();
215 BLI_path_join(path, path_maxncpy, tempdir, ".cache", SEP_STR);
216 return;
217 }
218
219#ifdef WIN32
220 BLI_path_join(path,
221 path_maxncpy,
222 caches_root_path->c_str(),
223 "Blender Foundation",
224 "Blender",
225 "Cache",
226 SEP_STR);
227#elif defined(__APPLE__)
228 BLI_path_join(path, path_maxncpy, caches_root_path->c_str(), "Blender", SEP_STR);
229#else /* __linux__ */
230 BLI_path_join(path, path_maxncpy, caches_root_path->c_str(), "blender", SEP_STR);
231#endif
232}
233
234bool BKE_appdir_font_folder_default(char *dir, size_t dir_maxncpy)
235{
236 char test_dir[FILE_MAXDIR];
237 test_dir[0] = '\0';
238
239#ifdef WIN32
240 wchar_t wpath[MAX_PATH];
241 if (SHGetSpecialFolderPathW(0, wpath, CSIDL_FONTS, 0)) {
242 BLI_strncpy_wchar_as_utf8(test_dir, wpath, sizeof(test_dir));
243 }
244#elif defined(__APPLE__)
245 if (const char *home_dir = BLI_dir_home()) {
246 BLI_path_join(test_dir, sizeof(test_dir), home_dir, "Library/Fonts");
247 }
248#else
249 STRNCPY(test_dir, "/usr/share/fonts");
250#endif
251
252 if (test_dir[0] && BLI_exists(test_dir)) {
253 BLI_strncpy(dir, test_dir, dir_maxncpy);
254 return true;
255 }
256 return false;
257}
258
260
261/* -------------------------------------------------------------------- */
264
280static bool test_path(char *targetpath,
281 size_t targetpath_maxncpy,
282 const bool check_is_dir,
283 const char *path_base,
284 const char *folder_name,
285 const char *subfolder_name)
286{
288
289 /* Only the last argument should be nullptr. */
290 BLI_assert(!(folder_name == nullptr && (subfolder_name != nullptr)));
291 const char *path_array[] = {path_base, folder_name, subfolder_name};
292 const int path_array_num = (folder_name ? (subfolder_name ? 3 : 2) : 1);
293 BLI_path_join_array(targetpath, targetpath_maxncpy, path_array, path_array_num);
294 if (check_is_dir == false) {
295 CLOG_DEBUG(&LOG, "Using (without test): '%s'", targetpath);
296 return true;
297 }
298
299 if (BLI_is_dir(targetpath)) {
300 CLOG_DEBUG(&LOG, "Found '%s'", targetpath);
301 return true;
302 }
303
304 CLOG_DEBUG(&LOG, "Missing '%s'", targetpath);
305
306 /* Path not found, don't accidentally use it,
307 * otherwise call this function with `check_is_dir` set to false. */
308 targetpath[0] = '\0';
309 return false;
310}
311
320static bool test_env_path(char *path, const char *envvar, const bool check_is_dir)
321{
323
324 const char *env_path = envvar ? BLI_getenv(envvar) : nullptr;
325 if (!env_path) {
326 return false;
327 }
328
329 BLI_strncpy(path, env_path, FILE_MAX);
330
331 if (check_is_dir == false) {
332 CLOG_DEBUG(&LOG, "Using env '%s' (without test): '%s'", envvar, env_path);
333 return true;
334 }
335
336 if (BLI_is_dir(env_path)) {
337 CLOG_DEBUG(&LOG, "Env '%s' found: %s", envvar, env_path);
338 return true;
339 }
340
341 CLOG_DEBUG(&LOG, "Env '%s' missing: %s", envvar, env_path);
342
343 /* Path not found, don't accidentally use it,
344 * otherwise call this function with `check_is_dir` set to false. */
345 path[0] = '\0';
346 return false;
347}
348
361static bool get_path_local_ex(char *targetpath,
362 size_t targetpath_maxncpy,
363 const char *folder_name,
364 const char *subfolder_name,
365 const int version,
366 const bool check_is_dir)
367{
368 char relfolder[FILE_MAX];
369
371 "Get path local: folder='%s', subfolder='%s'",
372 STR_OR_FALLBACK(folder_name),
373 STR_OR_FALLBACK(subfolder_name));
374
375 if (folder_name) { /* `subfolder_name` may be nullptr. */
376 const char *path_array[] = {folder_name, subfolder_name};
377 const int path_array_num = subfolder_name ? 2 : 1;
378 BLI_path_join_array(relfolder, sizeof(relfolder), path_array, path_array_num);
379 }
380 else {
381 relfolder[0] = '\0';
382 }
383
384 /* Try `{g_app.program_dirname}/3.xx/{folder_name}` the default directory
385 * for a portable distribution. See `WITH_INSTALL_PORTABLE` build-option. */
386 const char *path_base = g_app.program_dirname;
387#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
388 /* Due new code-sign situation in OSX > 10.9.5
389 * we must move the blender_version dir with contents to Resources.
390 * Add 4 + 9 for the temporary `/../` path & `Resources`. */
391 char osx_resourses[FILE_MAX + 4 + 9];
392 BLI_path_join(osx_resourses, sizeof(osx_resourses), g_app.program_dirname, "..", "Resources");
393 /* Remove the '/../' added above. */
394 BLI_path_normalize_native(osx_resourses);
395 path_base = osx_resourses;
396#endif
397 return test_path(targetpath,
398 targetpath_maxncpy,
399 check_is_dir,
400 path_base,
401 (version) ? blender_version_decimal(version) : relfolder,
402 (version) ? relfolder : nullptr);
403}
404static bool get_path_local(char *targetpath,
405 size_t targetpath_maxncpy,
406 const char *folder_name,
407 const char *subfolder_name)
408{
409 const int version = BLENDER_VERSION;
410 const bool check_is_dir = true;
411 return get_path_local_ex(
412 targetpath, targetpath_maxncpy, folder_name, subfolder_name, version, check_is_dir);
413}
414
424static bool get_path_environment_ex(char *targetpath,
425 size_t targetpath_maxncpy,
426 const char *subfolder_name,
427 const char *envvar,
428 const bool check_is_dir)
429{
430 char user_path[FILE_MAX];
431
432 if (test_env_path(user_path, envvar, check_is_dir)) {
433 /* Note that `subfolder_name` may be nullptr, in this case we use `user_path` as-is. */
434 return test_path(
435 targetpath, targetpath_maxncpy, check_is_dir, user_path, subfolder_name, nullptr);
436 }
437 return false;
438}
439static bool get_path_environment(char *targetpath,
440 size_t targetpath_maxncpy,
441 const char *subfolder_name,
442 const char *envvar)
443{
444 const bool check_is_dir = true;
446 targetpath, targetpath_maxncpy, subfolder_name, envvar, check_is_dir);
447}
448
449static Vector<std::string> get_path_environment_multiple(const char *subfolder_name,
450 const char *envvar,
451 const bool check_is_dir)
452{
454 const char *env_path = envvar ? BLI_getenv(envvar) : nullptr;
455 if (!env_path) {
456 return paths;
457 }
458
459#ifdef _WIN32
460 const char separator = ';';
461#else
462 const char separator = ':';
463#endif
464
465 const char *char_begin = env_path;
466 const char *char_end = BLI_strchr_or_end(char_begin, separator);
467 while (char_begin[0]) {
468 const size_t base_path_len = char_end - char_begin;
469 if (base_path_len > 0 && base_path_len < PATH_MAX) {
470 char base_path[PATH_MAX];
471 memcpy(base_path, char_begin, base_path_len);
472 base_path[base_path_len] = '\0';
473
474 char path[PATH_MAX];
475 if (test_path(path, sizeof(path), check_is_dir, base_path, subfolder_name, nullptr)) {
476 paths.append(path);
477 }
478 }
479 char_begin = char_end[0] ? char_end + 1 : char_end;
480 char_end = BLI_strchr_or_end(char_begin, separator);
481 }
482
483 return paths;
484}
485
496static bool get_path_user_ex(char *targetpath,
497 size_t targetpath_maxncpy,
498 const char *folder_name,
499 const char *subfolder_name,
500 const int version,
501 const bool check_is_dir)
502{
503 char user_path[FILE_MAX];
504
505 /* Environment variable override. */
506 if (test_env_path(user_path, "BLENDER_USER_RESOURCES", check_is_dir)) {
507 /* Pass. */
508 }
509 /* Portable install, to store user files next to Blender executable. */
510 else if (get_path_local_ex(user_path, sizeof(user_path), "portable", nullptr, 0, true)) {
511 /* Pass. */
512 }
513 else {
514 user_path[0] = '\0';
515
516 const GHOST_ISystemPaths *ghost_system_paths = GHOST_ISystemPaths::get();
517 const char *user_base_path = ghost_system_paths->getUserDir(version,
518 blender_version_decimal(version));
519 if (user_base_path) {
520 STRNCPY(user_path, user_base_path);
521 }
522 }
523
524 if (!user_path[0]) {
525 return false;
526 }
527
529 "Get path user: '%s', folder='%s', subfolder='%s'",
530 user_path,
531 STR_OR_FALLBACK(folder_name),
532 STR_OR_FALLBACK(subfolder_name));
533
534 /* `subfolder_name` may be nullptr. */
535 return test_path(
536 targetpath, targetpath_maxncpy, check_is_dir, user_path, folder_name, subfolder_name);
537}
538static bool get_path_user(char *targetpath,
539 size_t targetpath_maxncpy,
540 const char *folder_name,
541 const char *subfolder_name)
542{
543 const int version = BLENDER_VERSION;
544 const bool check_is_dir = true;
545 return get_path_user_ex(
546 targetpath, targetpath_maxncpy, folder_name, subfolder_name, version, check_is_dir);
547}
548
559static bool get_path_system_ex(char *targetpath,
560 size_t targetpath_maxncpy,
561 const char *folder_name,
562 const char *subfolder_name,
563 const int version,
564 const bool check_is_dir)
565{
566 char system_path[FILE_MAX];
567
568 if (test_env_path(system_path, "BLENDER_SYSTEM_RESOURCES", check_is_dir)) {
569 /* Pass. */
570 }
571 else {
572 system_path[0] = '\0';
573 const GHOST_ISystemPaths *ghost_system_paths = GHOST_ISystemPaths::get();
574 const char *system_base_path = ghost_system_paths->getSystemDir(
575 version, blender_version_decimal(version));
576 if (system_base_path) {
577 STRNCPY(system_path, system_base_path);
578 }
579 }
580
581 if (!system_path[0]) {
582 return false;
583 }
584
586 "Get path system: '%s', folder='%s', subfolder='%s'",
587 system_path,
588 STR_OR_FALLBACK(folder_name),
589 STR_OR_FALLBACK(subfolder_name));
590
591 /* Try `$BLENDERPATH/folder_name/subfolder_name`, `subfolder_name` may be nullptr. */
592 return test_path(
593 targetpath, targetpath_maxncpy, check_is_dir, system_path, folder_name, subfolder_name);
594}
595
596static bool get_path_system(char *targetpath,
597 size_t targetpath_maxncpy,
598 const char *folder_name,
599 const char *subfolder_name)
600{
601 const int version = BLENDER_VERSION;
602 const bool check_is_dir = true;
603 return get_path_system_ex(
604 targetpath, targetpath_maxncpy, folder_name, subfolder_name, version, check_is_dir);
605}
606
612static bool get_path_system_libs_ex(char *targetpath,
613 size_t targetpath_maxncpy,
614 const char *folder_name,
615 const char *subfolder_name,
616 const int version,
617 const bool check_is_dir)
618{
619 char system_path[FILE_MAX] = "";
620
621 const GHOST_ISystemPaths *ghost_system_paths = GHOST_ISystemPaths::get();
622 const char *system_base_path = ghost_system_paths->getSystemLibsDir(
623 version, blender_version_decimal(version));
624 if (system_base_path) {
625 STRNCPY(system_path, system_base_path);
626 }
627
628 if (!system_path[0]) {
629 return false;
630 }
631
633 "Get path system libs: '%s', folder='%s', subfolder='%s'",
634 system_path,
635 STR_OR_FALLBACK(folder_name),
636 STR_OR_FALLBACK(subfolder_name));
637
638 /* Try `$LIBDIR/folder_name/subfolder_name`, `subfolder_name` may be nullptr. */
639 return test_path(
640 targetpath, targetpath_maxncpy, check_is_dir, system_path, folder_name, subfolder_name);
641}
642
644
645/* -------------------------------------------------------------------- */
648
649bool BKE_appdir_folder_id_ex(const int folder_id,
650 const char *subfolder,
651 char *path,
652 size_t path_maxncpy)
653{
654 switch (folder_id) {
655 case BLENDER_DATAFILES: /* general case */
656 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_USER_DATAFILES")) {
657 break;
658 }
659 if (get_path_user(path, path_maxncpy, "datafiles", subfolder)) {
660 break;
661 }
662 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_SYSTEM_DATAFILES")) {
663 break;
664 }
665 if (get_path_system(path, path_maxncpy, "datafiles", subfolder)) {
666 break;
667 }
668 if (get_path_local(path, path_maxncpy, "datafiles", subfolder)) {
669 break;
670 }
671 return false;
672
674 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_USER_DATAFILES")) {
675 break;
676 }
677 if (get_path_user(path, path_maxncpy, "datafiles", subfolder)) {
678 break;
679 }
680 return false;
681
683 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_SYSTEM_DATAFILES")) {
684 break;
685 }
686 if (get_path_system(path, path_maxncpy, "datafiles", subfolder)) {
687 break;
688 }
689 if (get_path_local(path, path_maxncpy, "datafiles", subfolder)) {
690 break;
691 }
692 return false;
693
695 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_USER_CONFIG")) {
696 break;
697 }
698 if (get_path_user(path, path_maxncpy, "config", subfolder)) {
699 break;
700 }
701 return false;
702
704 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_USER_SCRIPTS")) {
705 break;
706 }
707 if (get_path_user(path, path_maxncpy, "scripts", subfolder)) {
708 break;
709 }
710 return false;
711
713 if (get_path_system(path, path_maxncpy, "scripts", subfolder)) {
714 break;
715 }
716 if (get_path_local(path, path_maxncpy, "scripts", subfolder)) {
717 break;
718 }
719 return false;
720
722 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_USER_EXTENSIONS")) {
723 break;
724 }
725 if (get_path_user(path, path_maxncpy, "extensions", subfolder)) {
726 break;
727 }
728 return false;
729
731 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_SYSTEM_EXTENSIONS")) {
732 break;
733 }
734 if (get_path_system(path, path_maxncpy, "extensions", subfolder)) {
735 break;
736 }
737 if (get_path_local(path, path_maxncpy, "extensions", subfolder)) {
738 break;
739 }
740 return false;
741
743 if (get_path_environment(path, path_maxncpy, subfolder, "BLENDER_SYSTEM_PYTHON")) {
744 break;
745 }
746 if (get_path_system(path, path_maxncpy, "python", subfolder)) {
747 break;
748 }
749 if (get_path_local(path, path_maxncpy, "python", subfolder)) {
750 break;
751 }
752 return false;
753
754 default:
756 break;
757 }
758
759 return true;
760}
761
762std::optional<std::string> BKE_appdir_folder_id(const int folder_id, const char *subfolder)
763{
764 char path[FILE_MAX] = "";
765 if (BKE_appdir_folder_id_ex(folder_id, subfolder, path, sizeof(path))) {
766 return path;
767 }
768 return std::nullopt;
769}
770
771std::optional<std::string> BKE_appdir_folder_id_user_notest(const int folder_id,
772 const char *subfolder)
773{
774 const int version = BLENDER_VERSION;
775 char path[FILE_MAX] = "";
776 const bool check_is_dir = false;
777
778 switch (folder_id) {
781 path, sizeof(path), subfolder, "BLENDER_USER_DATAFILES", check_is_dir))
782 {
783 break;
784 }
785 get_path_user_ex(path, sizeof(path), "datafiles", subfolder, version, check_is_dir);
786 break;
789 path, sizeof(path), subfolder, "BLENDER_USER_CONFIG", check_is_dir))
790 {
791 break;
792 }
793 get_path_user_ex(path, sizeof(path), "config", subfolder, version, check_is_dir);
794 break;
797 path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS", check_is_dir))
798 {
799 break;
800 }
801 get_path_user_ex(path, sizeof(path), "scripts", subfolder, version, check_is_dir);
802 break;
805 path, sizeof(path), subfolder, "BLENDER_USER_EXTENSIONS", check_is_dir))
806 {
807 break;
808 }
809 get_path_user_ex(path, sizeof(path), "extensions", subfolder, version, check_is_dir);
810 break;
811 default:
813 break;
814 }
815
816 if ('\0' == path[0]) {
817 return std::nullopt;
818 }
819 return path;
820}
821
822std::optional<std::string> BKE_appdir_folder_id_create(const int folder_id, const char *subfolder)
823{
824 /* Only for user folders. */
825 if (!ELEM(folder_id,
830 {
832 return std::nullopt;
833 }
834
835 std::optional<std::string> path = BKE_appdir_folder_id(folder_id, subfolder);
836
837 if (!path.has_value()) {
838 path = BKE_appdir_folder_id_user_notest(folder_id, subfolder);
839 if (path.has_value()) {
840 BLI_dir_create_recursive(path->c_str());
841 }
842 }
843
844 return path;
845}
846
847std::optional<std::string> BKE_appdir_resource_path_id_with_version(const int folder_id,
848 const bool check_is_dir,
849 const int version)
850{
851 char path[FILE_MAX] = "";
852 bool ok;
853 switch (folder_id) {
855 ok = get_path_user_ex(path, sizeof(path), nullptr, nullptr, version, check_is_dir);
856 break;
858 ok = get_path_local_ex(path, sizeof(path), nullptr, nullptr, version, check_is_dir);
859 break;
861 ok = get_path_system_ex(path, sizeof(path), nullptr, nullptr, version, check_is_dir);
862 break;
864 ok = get_path_system_libs_ex(path, sizeof(path), nullptr, nullptr, version, check_is_dir);
865 break;
866 default:
867 path[0] = '\0'; /* in case check_is_dir is false */
868 ok = false;
869 BLI_assert_msg(0, "incorrect ID");
870 break;
871 }
872 if (!ok) {
873 return std::nullopt;
874 }
875 return path;
876}
877
878std::optional<std::string> BKE_appdir_resource_path_id(const int folder_id,
879 const bool check_is_dir)
880{
881 return BKE_appdir_resource_path_id_with_version(folder_id, check_is_dir, BLENDER_VERSION);
882}
883
885
886/* -------------------------------------------------------------------- */
891
892#ifndef WITH_PYTHON_MODULE
905static void where_am_i(char *program_filepath,
906 const size_t program_filepath_maxncpy,
907 const char *program_name)
908{
909# ifdef WITH_BINRELOC
910 /* Linux uses `binreloc` since `argv[0]` is not reliable, call `br_init(nullptr)` first. */
911 {
912 char *path = nullptr;
913 path = br_find_exe(nullptr);
914 if (path) {
915 BLI_strncpy(program_filepath, path, program_filepath_maxncpy);
916 free((void *)path);
917 return;
918 }
919 }
920# endif
921
922# ifdef _WIN32
923 {
924 wchar_t *fullname_16 = MEM_new_array_uninitialized<wchar_t>(program_filepath_maxncpy,
925 "ProgramPath");
926 if (GetModuleFileNameW(0, fullname_16, program_filepath_maxncpy)) {
927 conv_utf_16_to_8(fullname_16, program_filepath, program_filepath_maxncpy);
928 if (!BLI_exists(program_filepath)) {
930 "Program path can't be found: \"%.*s\"",
931 int(program_filepath_maxncpy),
932 program_filepath);
933 MessageBox(nullptr,
934 "path contains invalid characters or is too long (see console)",
935 "Error",
936 MB_OK);
937 }
938 MEM_delete(fullname_16);
939 return;
940 }
941
942 MEM_delete(fullname_16);
943 }
944# endif
945
946 /* Unix and non Linux. */
947 if (program_name && program_name[0]) {
948
949 BLI_strncpy(program_filepath, program_name, program_filepath_maxncpy);
950 if (program_name[0] == '.') {
951 BLI_path_abs_from_cwd(program_filepath, program_filepath_maxncpy);
952# ifdef _WIN32
953 BLI_path_program_extensions_add_win32(program_filepath, program_filepath_maxncpy);
954# endif
955 }
956 else if (BLI_path_slash_rfind(program_name)) {
957 /* Full path. */
958 BLI_strncpy(program_filepath, program_name, program_filepath_maxncpy);
959# ifdef _WIN32
960 BLI_path_program_extensions_add_win32(program_filepath, program_filepath_maxncpy);
961# endif
962 }
963 else {
964 BLI_path_program_search(program_filepath, program_filepath_maxncpy, program_name);
965 }
966 /* Remove "/./" and "/../" so string comparisons can be used on the path. */
967 BLI_path_normalize_native(program_filepath);
968
969# ifndef NDEBUG
970 if (!STREQ(program_name, program_filepath)) {
971 CLOG_DEBUG(&LOG, "Program path guessing '%s' == '%s'", program_name, program_filepath);
972 }
973# endif
974 }
975}
976#endif /* WITH_PYTHON_MODULE */
977
978void BKE_appdir_program_path_init(const char *argv0)
979{
980#ifdef WITH_PYTHON_MODULE
981 /* NOTE(@ideasman42): Always use `argv[0]` as is, when building as a Python module.
982 * Otherwise other methods of detecting the binary that override this argument
983 * which must point to the Python module for data-files to be detected. */
984 STRNCPY(g_app.program_filepath, argv0);
985 BLI_path_canonicalize_native(g_app.program_filepath, sizeof(g_app.program_filepath));
986
987 if (g_app.program_dirname[0] == '\0') {
988 /* First time initializing, the file binary path isn't valid from a Python module.
989 * Calling again must set the `filepath` and leave the directory as-is. */
991 g_app.program_filepath, g_app.program_dirname, sizeof(g_app.program_dirname));
992 g_app.program_filepath[0] = '\0';
993 }
994#else
995 where_am_i(g_app.program_filepath, sizeof(g_app.program_filepath), argv0);
997 g_app.program_filepath, g_app.program_dirname, sizeof(g_app.program_dirname));
998#endif
999}
1000
1002{
1003#ifndef WITH_PYTHON_MODULE /* Default's to empty when building as a Python module. */
1004 BLI_assert(g_app.program_filepath[0]);
1005#endif
1006 return g_app.program_filepath;
1007}
1008
1010{
1011 BLI_assert(g_app.program_dirname[0]);
1012 return g_app.program_dirname;
1013}
1014
1015bool BKE_appdir_program_python_search(char *program_filepath,
1016 const size_t program_filepath_maxncpy,
1017 const int version_major,
1018 const int version_minor)
1019{
1021
1022#ifdef PYTHON_EXECUTABLE_NAME
1023 /* Passed in from the build-systems 'PYTHON_EXECUTABLE'. */
1024 const char *python_build_def = STRINGIFY(PYTHON_EXECUTABLE_NAME);
1025#endif
1026 const char *basename = "python";
1027#if defined(WIN32) && !defined(NDEBUG)
1028 const char *basename_debug = "python_d";
1029#endif
1030 char python_version[16];
1031 /* Check both possible names. */
1032 const char *python_names[] = {
1033#ifdef PYTHON_EXECUTABLE_NAME
1034 python_build_def,
1035#endif
1036#if defined(WIN32) && !defined(NDEBUG)
1037 basename_debug,
1038#endif
1039 python_version,
1040 basename,
1041 };
1042 bool is_found = false;
1043
1044 SNPRINTF(python_version, "%s%d.%d", basename, version_major, version_minor);
1045
1046 {
1047 const std::optional<std::string> python_bin_dir = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON,
1048 "bin");
1049 if (python_bin_dir.has_value()) {
1050
1051 for (int i = 0; i < ARRAY_SIZE(python_names); i++) {
1053 program_filepath, program_filepath_maxncpy, python_bin_dir->c_str(), python_names[i]);
1054
1055 if (
1056#ifdef _WIN32
1057 BLI_path_program_extensions_add_win32(program_filepath, program_filepath_maxncpy)
1058#else
1059 BLI_exists(program_filepath)
1060#endif
1061 )
1062 {
1063 is_found = true;
1064 break;
1065 }
1066 }
1067 }
1068 }
1069
1070 if (is_found == false) {
1071 for (int i = 0; i < ARRAY_SIZE(python_names); i++) {
1072 if (BLI_path_program_search(program_filepath, program_filepath_maxncpy, python_names[i])) {
1073 is_found = true;
1074 break;
1075 }
1076 }
1077 }
1078
1079 if (is_found == false) {
1080 *program_filepath = '\0';
1081 }
1082
1083 return is_found;
1084}
1085
1087
1088/* -------------------------------------------------------------------- */
1091
1093{
1094 Vector<std::string> directories;
1095
1097 char temp_dir[FILE_MAX];
1099 "startup" SEP_STR "bl_app_templates_user",
1100 temp_dir,
1101 sizeof(temp_dir)))
1102 {
1103 directories.append(temp_dir);
1104 }
1105
1106 /* Environment variable. */
1108 "startup" SEP_STR "bl_app_templates_system", "BLENDER_SYSTEM_SCRIPTS", true));
1109
1110 /* Local or system directory. */
1112 "startup" SEP_STR "bl_app_templates_system",
1113 temp_dir,
1114 sizeof(temp_dir)))
1115 {
1116 directories.append(temp_dir);
1117 }
1118
1119 return directories;
1120}
1121
1126
1127bool BKE_appdir_app_template_id_search(const char *app_template, char *path, size_t path_maxncpy)
1128{
1130
1131 for (const std::string &directory : directories) {
1132 BLI_path_join(path, path_maxncpy, directory.c_str(), app_template);
1133 if (BLI_is_dir(path)) {
1134 return true;
1135 }
1136 }
1137
1138 return false;
1139}
1140
1141bool BKE_appdir_app_template_has_userpref(const char *app_template)
1142{
1143 /* Test if app template provides a `userpref.blend`.
1144 * If not, we will share user preferences with the rest of Blender. */
1145 if (app_template[0] == '\0') {
1146 return false;
1147 }
1148
1149 char app_template_path[FILE_MAX];
1151 app_template, app_template_path, sizeof(app_template_path)))
1152 {
1153 return false;
1154 }
1155
1156 char userpref_path[FILE_MAX];
1157 BLI_path_join(userpref_path, sizeof(userpref_path), app_template_path, BLENDER_USERPREF_FILE);
1158 return BLI_exists(userpref_path);
1159}
1160
1161void BKE_appdir_app_templates(ListBaseT<LinkData> *templates)
1162{
1163 templates->clear_no_delete();
1164
1166
1167 for (const std::string &subdir : directories) {
1168 direntry *dirs;
1169 const uint dir_num = BLI_filelist_dir_contents(subdir.c_str(), &dirs);
1170 for (int f = 0; f < dir_num; f++) {
1171 if (!FILENAME_IS_CURRPAR(dirs[f].relname) && S_ISDIR(dirs[f].type)) {
1172 char *app_template = BLI_strdup(dirs[f].relname);
1173 BLI_addtail(templates, BLI_genericNodeN(app_template));
1174 }
1175 }
1176
1177 BLI_filelist_free(dirs, dir_num);
1178 }
1179}
1180
1182
1183/* -------------------------------------------------------------------- */
1186
1199static bool where_is_temp(char *tempdir, const size_t tempdir_maxncpy, const char *userdir)
1200{
1201 if (userdir) {
1202 return BLI_temp_directory_path_copy_if_valid(tempdir, tempdir_maxncpy, userdir);
1203 }
1204 BLI_temp_directory_path_get(tempdir, tempdir_maxncpy);
1205 return true;
1206}
1207
1208static bool tempdir_session_create(char *tempdir_session,
1209 const size_t tempdir_session_maxncpy,
1210 const char *tempdir)
1211{
1212 tempdir_session[0] = '\0';
1213
1214 const int tempdir_len = strlen(tempdir);
1215 /* 'XXXXXX' is kind of tag to be replaced by `mktemp-family` by an UUID. */
1216 const char *session_name = "blender_XXXXXX";
1217 const int session_name_len = strlen(session_name);
1218
1219 /* +1 as a slash is added,
1220 * #_mktemp_s also requires the last null character is included. */
1221 const int tempdir_session_len_required = tempdir_len + session_name_len + 1;
1222
1223 if (tempdir_session_len_required <= tempdir_session_maxncpy) {
1224 /* No need to use path joining utility as we know the last character of #tempdir is a slash. */
1225 BLI_string_join(tempdir_session, tempdir_session_maxncpy, tempdir, session_name);
1226#ifdef WIN32
1227 const bool needs_create = (_mktemp_s(tempdir_session, tempdir_session_len_required) == 0);
1228#else
1229 const bool needs_create = (mkdtemp(tempdir_session) == nullptr);
1230#endif
1231 if (needs_create) {
1232 BLI_dir_create_recursive(tempdir_session);
1233 }
1234 if (BLI_is_dir(tempdir_session)) {
1235 BLI_path_slash_ensure(tempdir_session, tempdir_session_maxncpy);
1236 /* Success. */
1237 return true;
1238 }
1239 }
1240
1241 CLOG_WARN(&LOG, "Could not generate a temp file name for '%s'", tempdir_session);
1242 return false;
1243}
1244
1245void BKE_tempdir_init(const char *userdir)
1246{
1247 /* Sets #g_app.temp_dirname_base to `userdir` if specified and is a valid directory,
1248 * otherwise chooses a suitable OS-specific temporary directory.
1249 * Sets #g_app.temp_dirname_session to a #mkdtemp
1250 * generated sub-dir of #g_app.temp_dirname_base. */
1251
1252 /* Clear existing temp dir, if needed. */
1254
1255 g_app.temp_dirname_session_can_be_deleted = false;
1256
1257 /* Only do one pass if `userdir` is null. */
1258 int userdir_args_num = userdir ? 2 : 1;
1259 const char *userdir_args[2] = {userdir, nullptr};
1260
1261 for (int i = 0; i < userdir_args_num; i++) {
1262 if (where_is_temp(g_app.temp_dirname_base, sizeof(g_app.temp_dirname_base), userdir_args[i])) {
1263 if (tempdir_session_create(g_app.temp_dirname_session,
1264 sizeof(g_app.temp_dirname_session),
1265 g_app.temp_dirname_base))
1266 {
1267 g_app.temp_dirname_session_can_be_deleted = true;
1268 break;
1269 }
1270 }
1271 }
1272
1273 if (g_app.temp_dirname_session_can_be_deleted == false) [[unlikely]] {
1274 /* This should practically never happen as either the preferences or the systems
1275 * default temporary directory should be usable, if not, use the base directory and warn. */
1276 STRNCPY(g_app.temp_dirname_session, g_app.temp_dirname_base);
1277 CLOG_WARN(&LOG,
1278 "Could not generate a temp session subdirectory, falling back to '%s'",
1279 g_app.temp_dirname_base);
1280 }
1281}
1282
1284{
1285 return g_app.temp_dirname_session[0] ? g_app.temp_dirname_session : BKE_tempdir_base();
1286}
1287
1288const char *BKE_tempdir_base()
1289{
1290 return g_app.temp_dirname_base;
1291}
1292
1294{
1295 if (g_app.temp_dirname_session_can_be_deleted == false) {
1296 /* It's possible this path references an arbitrary location
1297 * in that case *never* recursively remove, see: #139585. */
1298 return;
1299 }
1300 if (g_app.temp_dirname_session[0] && BLI_is_dir(g_app.temp_dirname_session)) {
1301 BLI_delete(g_app.temp_dirname_session, true, true);
1302 }
1303}
1304
1306
1307} // namespace blender
#define BLENDER_USERPREF_FILE
#define BLENDER_VERSION
File and directory operations.
#define PATH_MAX
Some types for dealing with directories.
#define FILE_MAX
#define BLI_path_join(...)
#define FILENAME_IS_CURRPAR(_n)
#define FILE_MAXDIR
#define SNPRINTF(dst, format,...)
#define BLI_string_join(...)
Compatibility-like things for windows.
#define S_ISDIR(x)
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:188
#define CLOG_DEBUG(clg_ref,...)
Definition CLG_log.h:191
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
@ GHOST_kUserSpecialDirCaches
@ GHOST_kUserSpecialDirDocuments
#define ASSERT_IS_INIT()
Definition appdir.cc:90
#define STR_OR_FALLBACK(a)
Definition appdir.cc:57
#define BLI_assert_unreachable()
#define STRINGIFY(x)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
virtual const char * getSystemDir(int version, const char *versionstr) const =0
virtual const char * getSystemLibsDir(int, const char *) const
virtual const char * getUserDir(int version, const char *versionstr) const =0
static GHOST_TSuccess dispose()
static GHOST_ISystemPaths * get()
virtual std::optional< std::string > getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const =0
void append(const T &value)
void extend(Span< T > array)
void free(Subdiv *subdiv)
Definition subdiv.cc:192
BMesh Iterators.
const char * BKE_appdir_program_dir() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition appdir.cc:1009
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_appdir_app_templates(ListBaseT< LinkData > *templates) ATTR_NONNULL(1)
Definition appdir.cc:1161
void BKE_tempdir_session_purge()
Definition appdir.cc:1293
static bool is_appdir_init
Definition appdir.cc:89
char * STRNCPY(char(&dst)[N], const char *src)
static bool get_path_environment(char *targetpath, size_t targetpath_maxncpy, const char *subfolder_name, const char *envvar)
Definition appdir.cc:439
static bool get_path_system_ex(char *targetpath, size_t targetpath_maxncpy, const char *folder_name, const char *subfolder_name, const int version, const bool check_is_dir)
Definition appdir.cc:559
bool BKE_appdir_folder_id_ex(int folder_id, const char *subfolder, char *path, size_t path_maxncpy)
Definition appdir.cc:649
const char * BKE_appdir_folder_default_or_root() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition appdir.cc:165
static struct blender::@142352051006215376267360375200157117105334372324 g_app
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static bool tempdir_session_create(char *tempdir_session, const size_t tempdir_session_maxncpy, const char *tempdir)
Definition appdir.cc:1208
unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_filelist)
std::optional< std::string > BKE_appdir_folder_id_create(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:822
bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL()
Definition fileops_c.cc:416
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
static bool get_path_user_ex(char *targetpath, size_t targetpath_maxncpy, const char *folder_name, const char *subfolder_name, const int version, const bool check_is_dir)
Definition appdir.cc:496
static bool where_is_temp(char *tempdir, const size_t tempdir_maxncpy, const char *userdir)
Definition appdir.cc:1199
void BKE_appdir_init()
Definition appdir.cc:95
static bool get_path_local(char *targetpath, size_t targetpath_maxncpy, const char *folder_name, const char *subfolder_name)
Definition appdir.cc:404
bool BKE_appdir_app_template_any()
Definition appdir.cc:1122
static bool get_path_environment_ex(char *targetpath, size_t targetpath_maxncpy, const char *subfolder_name, const char *envvar, const bool check_is_dir)
Definition appdir.cc:424
@ BLENDER_RESOURCE_PATH_SYSTEM_LIBS
@ BLENDER_RESOURCE_PATH_SYSTEM
@ BLENDER_RESOURCE_PATH_USER
@ BLENDER_RESOURCE_PATH_LOCAL
static bool get_path_system(char *targetpath, size_t targetpath_maxncpy, const char *folder_name, const char *subfolder_name)
Definition appdir.cc:596
const char * BKE_tempdir_session() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition appdir.cc:1283
const char * BLI_dir_home()
Definition storage.cc:99
static bool get_path_user(char *targetpath, size_t targetpath_maxncpy, const char *folder_name, const char *subfolder_name)
Definition appdir.cc:538
static void where_am_i(char *program_filepath, const size_t program_filepath_maxncpy, const char *program_name)
Definition appdir.cc:905
std::optional< std::string > BKE_appdir_folder_id(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:762
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
static bool test_path(char *targetpath, size_t targetpath_maxncpy, const bool check_is_dir, const char *path_base, const char *folder_name, const char *subfolder_name)
Definition appdir.cc:280
const char * BKE_appdir_folder_root() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition appdir.cc:154
int BLI_path_canonicalize_native(char *path, int path_maxncpy)
static const char _str_null[]
Definition appdir.cc:56
bool void BLI_temp_directory_path_get(char *tempdir, const size_t tempdir_maxncpy) ATTR_NONNULL(1)
Definition tempfile.cc:59
bool BKE_appdir_app_template_id_search(const char *app_template, char *path, size_t path_maxncpy) ATTR_NONNULL(1)
Definition appdir.cc:1127
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
bool BLI_path_program_search(char *program_filepath, size_t program_filepath_maxncpy, const char *program_name) ATTR_NONNULL(1
bool BKE_appdir_app_template_has_userpref(const char *app_template) ATTR_NONNULL(1)
Definition appdir.cc:1141
bool BKE_appdir_program_python_search(char *program_filepath, size_t program_filepath_maxncpy, int version_major, int version_minor) ATTR_NONNULL(1)
Definition appdir.cc:1015
bool BLI_path_abs_from_cwd(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
LinkData * BLI_genericNodeN(void *data)
Definition listbase.cc:936
bool BKE_appdir_folder_documents(char *dir) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:174
const char * BKE_tempdir_base() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition appdir.cc:1288
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
std::optional< std::string > BKE_appdir_resource_path_id(int folder_id, bool check_is_dir)
Definition appdir.cc:878
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:457
std::optional< std::string > BKE_appdir_folder_id_user_notest(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:771
void BKE_appdir_program_path_init(const char *argv0) ATTR_NONNULL(1)
Definition appdir.cc:978
static char * blender_version_decimal(const int version)
Definition appdir.cc:125
static bool get_path_local_ex(char *targetpath, size_t targetpath_maxncpy, const char *folder_name, const char *subfolder_name, const int version, const bool check_is_dir)
Definition appdir.cc:361
void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries)
static bool test_env_path(char *path, const char *envvar, const bool check_is_dir)
Definition appdir.cc:320
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
void BKE_appdir_folder_caches(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
Definition appdir.cc:206
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
static bool get_path_system_libs_ex(char *targetpath, size_t targetpath_maxncpy, const char *folder_name, const char *subfolder_name, const int version, const bool check_is_dir)
Definition appdir.cc:612
std::optional< std::string > BKE_appdir_resource_path_id_with_version(int folder_id, bool check_is_dir, int version)
Definition appdir.cc:847
bool BKE_appdir_font_folder_default(char *dir, size_t dir_maxncpy)
Definition appdir.cc:234
static Vector< std::string > appdir_app_template_directories()
Definition appdir.cc:1092
static CLG_LogRef LOG
Definition logging.cpp:12
int BLI_path_normalize_native(char *path) ATTR_NONNULL(1)
bool BLI_temp_directory_path_copy_if_valid(char *tempdir, const size_t tempdir_maxncpy, const char *dirpath) ATTR_NONNULL(1
Definition tempfile.cc:17
const char * BKE_appdir_program_path() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition appdir.cc:1001
size_t BLI_path_join_array(char *__restrict dst, const size_t dst_maxncpy, const char *path_array[], const int path_array_num) ATTR_NONNULL(1
@ BLENDER_SYSTEM_EXTENSIONS
@ BLENDER_USER_EXTENSIONS
@ BLENDER_USER_CONFIG
@ BLENDER_SYSTEM_PYTHON
@ BLENDER_SYSTEM_DATAFILES
@ BLENDER_USER_DATAFILES
@ BLENDER_DATAFILES
@ BLENDER_SYSTEM_SCRIPTS
@ BLENDER_USER_SCRIPTS
void BKE_appdir_exit()
Definition appdir.cc:103
const char * BLI_path_slash_rfind(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void BKE_tempdir_init(const char *userdir)
Definition appdir.cc:1245
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
const char * BKE_appdir_folder_default() ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:139
char char size_t char const char * BLI_strchr_or_end(const char *str, char ch) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_windows_get_default_root_dir(char root_dir[4])
static Vector< std::string > get_path_environment_multiple(const char *subfolder_name, const char *envvar, const bool check_is_dir)
Definition appdir.cc:449
char temp_dirname_session[FILE_MAX]
char program_filepath[FILE_MAX]
bool temp_dirname_session_can_be_deleted
char program_dirname[FILE_MAX]
char temp_dirname_base[FILE_MAX]
#define SEP_STR
Definition unit.cc:41
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
Definition utfconv.cc:116
#define N_(msgid)