Blender V4.3
BKE_appdir.hh File Reference
#include <stddef.h>
#include <optional>
#include <string>
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Macros

#define BLENDER_STARTUP_FILE   "startup.blend"
 
#define BLENDER_USERPREF_FILE   "userpref.blend"
 
#define BLENDER_QUIT_FILE   "quit.blend"
 
#define BLENDER_BOOKMARK_FILE   "bookmarks.txt"
 
#define BLENDER_HISTORY_FILE   "recent-files.txt"
 
#define BLENDER_RECENT_SEARCHES_FILE   "recent-searches.txt"
 
#define BLENDER_PLATFORM_SUPPORT_FILE   "platform_support.txt"
 

Enumerations

enum  {
  BLENDER_DATAFILES = 2 , BLENDER_USER_CONFIG = 31 , BLENDER_USER_DATAFILES = 32 , BLENDER_USER_SCRIPTS = 33 ,
  BLENDER_USER_EXTENSIONS = 34 , BLENDER_SYSTEM_DATAFILES = 52 , BLENDER_SYSTEM_SCRIPTS = 53 , BLENDER_SYSTEM_EXTENSIONS = 54 ,
  BLENDER_SYSTEM_PYTHON = 55
}
 
enum  { BLENDER_RESOURCE_PATH_USER = 0 , BLENDER_RESOURCE_PATH_LOCAL = 1 , BLENDER_RESOURCE_PATH_SYSTEM = 2 }
 

Functions

void BKE_appdir_init ()
 
void BKE_appdir_exit ()
 
const char * BKE_appdir_folder_default () ATTR_WARN_UNUSED_RESULT
 
const char * BKE_appdir_folder_root () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
const char * BKE_appdir_folder_default_or_root () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
const char * BKE_appdir_folder_home ()
 
bool BKE_appdir_folder_documents (char *dir) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
bool BKE_appdir_folder_caches (char *path, size_t path_maxncpy) ATTR_NONNULL(1)
 
bool BKE_appdir_folder_id_ex (int folder_id, const char *subfolder, char *path, size_t path_maxncpy)
 
std::optional< std::string > BKE_appdir_folder_id (int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
 
std::optional< std::string > BKE_appdir_folder_id_create (int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
 
std::optional< std::string > BKE_appdir_folder_id_user_notest (int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
 
std::optional< std::string > BKE_appdir_resource_path_id_with_version (int folder_id, bool check_is_dir, int version)
 
std::optional< std::string > BKE_appdir_resource_path_id (int folder_id, bool check_is_dir)
 
bool BKE_appdir_app_template_any ()
 
bool BKE_appdir_app_template_id_search (const char *app_template, char *path, size_t path_maxncpy) ATTR_NONNULL(1)
 
bool BKE_appdir_app_template_has_userpref (const char *app_template) ATTR_NONNULL(1)
 
void BKE_appdir_app_templates (ListBase *templates) ATTR_NONNULL(1)
 
void BKE_appdir_program_path_init (const char *argv0) ATTR_NONNULL(1)
 
const char * BKE_appdir_program_path () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
const char * BKE_appdir_program_dir () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
bool BKE_appdir_font_folder_default (char *dir, size_t dir_maxncpy)
 
bool BKE_appdir_program_python_search (char *program_filepath, size_t program_filepath_maxncpy, int version_major, int version_minor) ATTR_NONNULL(1)
 
void BKE_tempdir_init (const char *userdir)
 
const char * BKE_tempdir_base () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
const char * BKE_tempdir_session () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
void BKE_tempdir_session_purge ()
 

Detailed Description

Note
on naming: typical _get() suffix is omitted here, since its the main purpose of the API.

Definition in file BKE_appdir.hh.

Macro Definition Documentation

◆ BLENDER_BOOKMARK_FILE

#define BLENDER_BOOKMARK_FILE   "bookmarks.txt"

◆ BLENDER_HISTORY_FILE

#define BLENDER_HISTORY_FILE   "recent-files.txt"

Definition at line 190 of file BKE_appdir.hh.

Referenced by wm_history_file_read(), and wm_history_file_write().

◆ BLENDER_PLATFORM_SUPPORT_FILE

#define BLENDER_PLATFORM_SUPPORT_FILE   "platform_support.txt"

Definition at line 192 of file BKE_appdir.hh.

Referenced by wm_platform_support_check_approval().

◆ BLENDER_QUIT_FILE

#define BLENDER_QUIT_FILE   "quit.blend"

◆ BLENDER_RECENT_SEARCHES_FILE

#define BLENDER_RECENT_SEARCHES_FILE   "recent-searches.txt"

◆ BLENDER_STARTUP_FILE

#define BLENDER_STARTUP_FILE   "startup.blend"

◆ BLENDER_USERPREF_FILE

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

The folder_id for BKE_appdir_folder_id and related functions.

Run-time only so existing values may change.

Enumerator
BLENDER_DATAFILES 
BLENDER_USER_CONFIG 
BLENDER_USER_DATAFILES 
BLENDER_USER_SCRIPTS 
BLENDER_USER_EXTENSIONS 
BLENDER_SYSTEM_DATAFILES 
BLENDER_SYSTEM_SCRIPTS 
BLENDER_SYSTEM_EXTENSIONS 
BLENDER_SYSTEM_PYTHON 

Definition at line 162 of file BKE_appdir.hh.

◆ anonymous enum

anonymous enum

For #BKE_appdir_folder_id_version only.

Enumerator
BLENDER_RESOURCE_PATH_USER 
BLENDER_RESOURCE_PATH_LOCAL 
BLENDER_RESOURCE_PATH_SYSTEM 

Definition at line 180 of file BKE_appdir.hh.

Function Documentation

◆ BKE_appdir_app_template_any()

bool BKE_appdir_app_template_any ( )

Return true if templates exist

Definition at line 1066 of file appdir.cc.

References appdir_app_template_directories(), and blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty().

Referenced by wm_file_read_post().

◆ BKE_appdir_app_template_has_userpref()

bool BKE_appdir_app_template_has_userpref ( const char * app_template)

◆ BKE_appdir_app_template_id_search()

bool BKE_appdir_app_template_id_search ( const char * app_template,
char * path,
size_t path_maxncpy )

◆ BKE_appdir_app_templates()

◆ BKE_appdir_exit()

◆ BKE_appdir_folder_caches()

bool BKE_appdir_folder_caches ( char * path,
size_t path_maxncpy )

Get the user's cache directory, i.e.

  • Linux: $HOME/.cache/blender/
  • Windows: USERPROFILE%\AppData\Local\Blender Foundation\Blender\
  • MacOS: /Library/Caches/Blender
Returns
True if the path is valid. It doesn't create or checks format if the blender folder exists. It does check if the parent of the path exists.

Definition at line 226 of file appdir.cc.

References BKE_tempdir_base(), BLI_is_dir(), BLI_path_join, GHOST_getUserSpecialDir(), GHOST_kUserSpecialDirCaches, and SEP_STR.

Referenced by blender::gpu::cache_dir_get(), and blender::ed::asset::index::AssetLibraryIndex::init_indices_base_path().

◆ BKE_appdir_folder_default()

const char * BKE_appdir_folder_default ( )

Get the folder that's the "natural" starting point for browsing files on an OS.

  • Unix: $HOME
  • Windows: userprofile%/Documents
Note
On Windows Users/{MyUserName}/Documents is used as it's the default location to save documents.

Definition at line 137 of file appdir.cc.

References BKE_appdir_folder_documents(), BKE_appdir_folder_home(), and FILE_MAXDIR.

Referenced by BKE_appdir_folder_default_or_root(), blo_update_defaults_screen(), and fileselect_initialize_params_common().

◆ BKE_appdir_folder_default_or_root()

const char * BKE_appdir_folder_default_or_root ( )

Definition at line 163 of file appdir.cc.

References BKE_appdir_folder_default(), and BKE_appdir_folder_root().

Referenced by file_browse_invoke(), and file_expand_directory().

◆ BKE_appdir_folder_documents()

bool BKE_appdir_folder_documents ( char * dir)

Get the user's document directory, i.e.

  • Linux: $HOME/Documents
  • Windows: userprofile%/Documents

If this can't be found using OS queries (via Ghost), try manually finding it.

Returns
True if the path is valid and points to an existing directory.

Definition at line 196 of file appdir.cc.

References BKE_appdir_folder_home(), BLI_is_dir(), BLI_path_join, BLI_strncpy(), FILE_MAXDIR, GHOST_getUserSpecialDir(), GHOST_kUserSpecialDirDocuments, and N_.

Referenced by BKE_appdir_folder_default(), and BKE_preferences_asset_library_default_add().

◆ BKE_appdir_folder_home()

const char * BKE_appdir_folder_home ( )

Get the user's home directory, i.e.

  • Unix: $HOME
  • Windows: userprofile%

Definition at line 172 of file appdir.cc.

References BLI_expand_tilde(), and BLI_getenv().

Referenced by BKE_appdir_folder_default(), BKE_appdir_folder_documents(), and file_expand_directory().

◆ BKE_appdir_folder_id()

◆ BKE_appdir_folder_id_create()

◆ BKE_appdir_folder_id_ex()

bool BKE_appdir_folder_id_ex ( int folder_id,
const char * subfolder,
char * path,
size_t path_maxncpy )

Get a folder out of the folder_id presets for paths.

Parameters
subfolderThe name of a directory to check for, this may contain path separators but must resolve to a directory, checked with BLI_is_dir.
Returns
The path if found, NULL string if not.

Definition at line 591 of file appdir.cc.

References BLENDER_DATAFILES, BLENDER_SYSTEM_DATAFILES, BLENDER_SYSTEM_EXTENSIONS, BLENDER_SYSTEM_PYTHON, BLENDER_SYSTEM_SCRIPTS, BLENDER_USER_CONFIG, BLENDER_USER_DATAFILES, BLENDER_USER_EXTENSIONS, BLENDER_USER_SCRIPTS, BLI_assert_unreachable, get_path_environment(), get_path_local(), get_path_system(), and get_path_user().

Referenced by appdir_app_template_directories(), and BKE_appdir_folder_id().

◆ BKE_appdir_folder_id_user_notest()

std::optional< std::string > BKE_appdir_folder_id_user_notest ( int folder_id,
const char * subfolder )

◆ BKE_appdir_folder_root()

const char * BKE_appdir_folder_root ( )

Definition at line 152 of file appdir.cc.

References BLI_windows_get_default_root_dir().

Referenced by BKE_appdir_folder_default_or_root().

◆ BKE_appdir_font_folder_default()

bool BKE_appdir_font_folder_default ( char * dir,
size_t dir_maxncpy )

Gets a good default directory for fonts.

Definition at line 250 of file appdir.cc.

References BLI_exists(), BLI_expand_tilde(), BLI_strncpy(), BLI_strncpy_wchar_as_utf8(), FILE_MAXDIR, and STRNCPY.

Referenced by BKE_blendfile_userdef_from_defaults(), and file_browse_invoke().

◆ BKE_appdir_init()

void BKE_appdir_init ( )

Sanity check to ensure correct API use in debug mode.

Run this once the first level of arguments has been passed so we can be sure --env-system-datafiles, and other --env-* arguments has been passed.

Without this any callers to this module that run early on, will miss out on changes from parsing arguments.

Definition at line 93 of file appdir.cc.

References BLI_assert, and is_appdir_init.

Referenced by blender::bke::tests::Context< TestData >::Context(), main(), blender::bke::image::partial_update::ImagePartialUpdateTest::SetUp(), BlendfileLoadingBaseTest::SetUpTestCase(), blender::bke::tests::TEST(), and blender::bke::tests::TEST().

◆ BKE_appdir_program_dir()

const char * BKE_appdir_program_dir ( )

Path to directory of executable

Definition at line 948 of file appdir.cc.

References BLI_assert, and g_app.

Referenced by Freestyle::Config::Path::Path().

◆ BKE_appdir_program_path()

const char * BKE_appdir_program_path ( )

Path to executable

Definition at line 940 of file appdir.cc.

References BLI_assert, and g_app.

Referenced by bpy_app_binary_path_get(), and BPY_python_start().

◆ BKE_appdir_program_path_init()

void BKE_appdir_program_path_init ( const char * argv0)

Initialize path to program executable.

Definition at line 917 of file appdir.cc.

References BLI_path_canonicalize_native(), BLI_path_split_dir_part(), g_app, STRNCPY, and where_am_i().

Referenced by bpy_app_binary_path_set(), and main().

◆ BKE_appdir_program_python_search()

bool BKE_appdir_program_python_search ( char * program_filepath,
size_t program_filepath_maxncpy,
int version_major,
int version_minor )

◆ BKE_appdir_resource_path_id()

std::optional< std::string > BKE_appdir_resource_path_id ( int folder_id,
bool check_is_dir )

Definition at line 817 of file appdir.cc.

References BKE_appdir_resource_path_id_with_version(), and BLENDER_VERSION.

◆ BKE_appdir_resource_path_id_with_version()

std::optional< std::string > BKE_appdir_resource_path_id_with_version ( int folder_id,
bool check_is_dir,
int version )

Returns the path of the top-level version-specific local, user or system directory. If check_is_dir, then the result will be NULL if the directory doesn't exist.

Definition at line 789 of file appdir.cc.

References BLENDER_RESOURCE_PATH_LOCAL, BLENDER_RESOURCE_PATH_SYSTEM, BLENDER_RESOURCE_PATH_USER, BLI_assert_msg, FILE_MAX, get_path_local_ex(), get_path_system_ex(), and get_path_user_ex().

Referenced by BKE_appdir_resource_path_id(), and bpy_resource_path().

◆ BKE_tempdir_base()

◆ BKE_tempdir_init()

◆ BKE_tempdir_session()

◆ BKE_tempdir_session_purge()