Blender  V3.3
Macros | Enumerations | Functions
BKE_appdir.h File Reference
#include <stddef.h>
#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_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_AUTOSAVE = 34 , BLENDER_SYSTEM_DATAFILES = 52 , BLENDER_SYSTEM_SCRIPTS = 53 , BLENDER_SYSTEM_PYTHON = 54
}
 
enum  { BLENDER_RESOURCE_PATH_USER = 0 , BLENDER_RESOURCE_PATH_LOCAL = 1 , BLENDER_RESOURCE_PATH_SYSTEM = 2 }
 

Functions

void BKE_appdir_init (void)
 
void BKE_appdir_exit (void)
 
const char * BKE_appdir_folder_default (void) ATTR_WARN_UNUSED_RESULT
 
const char * BKE_appdir_folder_root (void) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
const char * BKE_appdir_folder_default_or_root (void) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
const char * BKE_appdir_folder_home (void)
 
bool BKE_appdir_folder_documents (char *dir)
 
bool BKE_appdir_folder_caches (char *r_path, size_t path_len)
 
bool BKE_appdir_folder_id_ex (int folder_id, const char *subfolder, char *path, size_t path_len)
 
const char * BKE_appdir_folder_id (int folder_id, const char *subfolder)
 
const char * BKE_appdir_folder_id_create (int folder_id, const char *subfolder)
 
const char * BKE_appdir_folder_id_user_notest (int folder_id, const char *subfolder)
 
const char * BKE_appdir_folder_id_version (int folder_id, int version, bool check_is_dir)
 
bool BKE_appdir_app_is_portable_install (void)
 
bool BKE_appdir_app_template_any (void)
 
bool BKE_appdir_app_template_id_search (const char *app_template, char *path, size_t path_len)
 
bool BKE_appdir_app_template_has_userpref (const char *app_template)
 
void BKE_appdir_app_templates (struct ListBase *templates)
 
void BKE_appdir_program_path_init (const char *argv0)
 
const char * BKE_appdir_program_path (void)
 
const char * BKE_appdir_program_dir (void)
 
bool BKE_appdir_font_folder_default (char *dir)
 
bool BKE_appdir_program_python_search (char *fullpath, size_t fullpath_len, int version_major, int version_minor)
 
void BKE_tempdir_init (const char *userdir)
 
const char * BKE_tempdir_base (void)
 
const char * BKE_tempdir_session (void)
 
void BKE_tempdir_session_purge (void)
 

Detailed Description

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

Definition in file BKE_appdir.h.

Macro Definition Documentation

◆ BLENDER_BOOKMARK_FILE

#define BLENDER_BOOKMARK_FILE   "bookmarks.txt"

Definition at line 178 of file BKE_appdir.h.

◆ BLENDER_HISTORY_FILE

#define BLENDER_HISTORY_FILE   "recent-files.txt"

Definition at line 179 of file BKE_appdir.h.

◆ BLENDER_PLATFORM_SUPPORT_FILE

#define BLENDER_PLATFORM_SUPPORT_FILE   "platform_support.txt"

Definition at line 180 of file BKE_appdir.h.

◆ BLENDER_QUIT_FILE

#define BLENDER_QUIT_FILE   "quit.blend"

Definition at line 177 of file BKE_appdir.h.

◆ BLENDER_STARTUP_FILE

#define BLENDER_STARTUP_FILE   "startup.blend"

Definition at line 175 of file BKE_appdir.h.

◆ BLENDER_USERPREF_FILE

#define BLENDER_USERPREF_FILE   "userpref.blend"

Definition at line 176 of file BKE_appdir.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BLENDER_DATAFILES 
BLENDER_USER_CONFIG 
BLENDER_USER_DATAFILES 
BLENDER_USER_SCRIPTS 
BLENDER_USER_AUTOSAVE 
BLENDER_SYSTEM_DATAFILES 
BLENDER_SYSTEM_SCRIPTS 
BLENDER_SYSTEM_PYTHON 

Definition at line 152 of file BKE_appdir.h.

◆ anonymous enum

anonymous enum
Enumerator
BLENDER_RESOURCE_PATH_USER 
BLENDER_RESOURCE_PATH_LOCAL 
BLENDER_RESOURCE_PATH_SYSTEM 

Definition at line 169 of file BKE_appdir.h.

Function Documentation

◆ BKE_appdir_app_is_portable_install()

bool BKE_appdir_app_is_portable_install ( void  )

Check if this is an install with user files kept together with the Blender executable and its installation files.

Definition at line 404 of file appdir.c.

References FILE_MAX, get_path_local(), and NULL.

Referenced by BKE_studiolight_init(), and get_path_user_ex().

◆ BKE_appdir_app_template_any()

bool BKE_appdir_app_template_any ( void  )

Return true if templates exist

Definition at line 966 of file appdir.c.

References app_template_directory_id, app_template_directory_search, ARRAY_SIZE, BKE_appdir_folder_id_ex(), and FILE_MAX.

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_len 
)

◆ BKE_appdir_app_templates()

void BKE_appdir_app_templates ( struct ListBase templates)

◆ BKE_appdir_exit()

void BKE_appdir_exit ( void  )

◆ BKE_appdir_folder_caches()

bool BKE_appdir_folder_caches ( char *  r_path,
size_t  path_len 
)

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 203 of file appdir.c.

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

Referenced by blender::ed::asset::index::AssetLibraryIndex::init_indices_base_path().

◆ BKE_appdir_folder_default()

const char* BKE_appdir_folder_default ( void  )

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 127 of file appdir.c.

References BKE_appdir_folder_documents(), BLI_getenv(), MAXPATHLEN, and NULL.

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 ( void  )

Definition at line 153 of file appdir.c.

References BKE_appdir_folder_default(), BKE_appdir_folder_root(), and NULL.

Referenced by 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 173 of file appdir.c.

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

Referenced by BKE_appdir_folder_default(), and BKE_preferences_asset_library_default_add().

◆ BKE_appdir_folder_home()

const char* BKE_appdir_folder_home ( void  )

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

  • Unix: $HOME
  • Windows: userprofile%

Definition at line 162 of file appdir.c.

References BLI_expand_tilde(), and BLI_getenv().

Referenced by BKE_appdir_folder_documents().

◆ BKE_appdir_folder_id()

const char* BKE_appdir_folder_id ( int  folder_id,
const char *  subfolder 
)

◆ BKE_appdir_folder_id_create()

const char* BKE_appdir_folder_id_create ( int  folder_id,
const char *  subfolder 
)

◆ BKE_appdir_folder_id_ex()

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

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 568 of file appdir.c.

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

Referenced by BKE_appdir_app_template_any(), BKE_appdir_app_template_id_search(), BKE_appdir_app_templates(), and BKE_appdir_folder_id().

◆ BKE_appdir_folder_id_user_notest()

const char* BKE_appdir_folder_id_user_notest ( int  folder_id,
const char *  subfolder 
)

Returns the path to a folder in the user area without checking that it actually exists first.

Definition at line 681 of file appdir.c.

References BLENDER_USER_AUTOSAVE, BLENDER_USER_CONFIG, BLENDER_USER_DATAFILES, BLENDER_USER_SCRIPTS, BLENDER_VERSION, BLI_assert_unreachable, FILE_MAX, get_path_environment_ex(), get_path_user_ex(), and NULL.

Referenced by BKE_appdir_folder_id_create(), and bpy_user_resource().

◆ BKE_appdir_folder_id_version()

const char* BKE_appdir_folder_id_version ( int  folder_id,
int  version,
bool  check_is_dir 
)

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 752 of file appdir.c.

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(), get_path_user_ex(), and NULL.

Referenced by bpy_resource_path().

◆ BKE_appdir_folder_root()

const char* BKE_appdir_folder_root ( void  )

Definition at line 142 of file appdir.c.

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)

Gets a good default directory for fonts.

Definition at line 227 of file appdir.c.

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

Referenced by BKE_blendfile_userdef_from_defaults().

◆ BKE_appdir_init()

void BKE_appdir_init ( void  )

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 88 of file appdir.c.

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(), and blender::bke::tests::TEST().

◆ BKE_appdir_program_dir()

const char* BKE_appdir_program_dir ( void  )

Path to directory of executable

Definition at line 873 of file appdir.c.

References BLI_assert, and g_app.

◆ BKE_appdir_program_path()

const char* BKE_appdir_program_path ( void  )

Path to executable

Definition at line 867 of file appdir.c.

References BLI_assert, and g_app.

Referenced by BPY_python_start(), and make_app_info().

◆ BKE_appdir_program_path_init()

void BKE_appdir_program_path_init ( const char *  argv0)

Initialize path to program executable.

Definition at line 861 of file appdir.c.

References BLI_split_dir_part(), g_app, and where_am_i().

Referenced by main().

◆ BKE_appdir_program_python_search()

bool BKE_appdir_program_python_search ( char *  fullpath,
size_t  fullpath_len,
int  version_major,
int  version_minor 
)

◆ BKE_tempdir_base()

const char* BKE_tempdir_base ( void  )

◆ BKE_tempdir_init()

void BKE_tempdir_init ( const char *  userdir)

◆ BKE_tempdir_session()

const char* BKE_tempdir_session ( void  )

◆ BKE_tempdir_session_purge()

void BKE_tempdir_session_purge ( void  )