WIP: Vulkan: Workbench #107886

Closed
Jeroen Bakker wants to merge 88 commits from Jeroen-Bakker:vulkan-draw-manager-workbench into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
42 changed files with 287 additions and 271 deletions
Showing only changes of commit bd2ee6b1c1 - Show all commits

View File

@ -33,7 +33,7 @@ void AS_asset_libraries_exit(void);
*
* To get the in-memory-only "current file" asset library, pass an empty path.
*/
struct AssetLibrary *AS_asset_library_load(const char *name, const char *library_path);
struct AssetLibrary *AS_asset_library_load(const char *name, const char *library_dirpath);
/** Look up the asset's catalog and copy its simple name into #asset_data. */
void AS_asset_library_refresh_catalog_simplename(struct AssetLibrary *asset_library,

View File

@ -31,9 +31,10 @@ StringRefNull AssetIdentifier::library_relative_identifier() const
std::string AssetIdentifier::full_path() const
{
char path[FILE_MAX];
BLI_path_join(path, sizeof(path), library_root_path_->c_str(), relative_asset_path_.c_str());
return path;
char filepath[FILE_MAX];
BLI_path_join(
filepath, sizeof(filepath), library_root_path_->c_str(), relative_asset_path_.c_str());
return filepath;
}
std::string AssetIdentifier::full_library_path() const

View File

@ -45,18 +45,18 @@ asset_system::AssetLibrary *AS_asset_library_load(const Main *bmain,
return service->get_asset_library(bmain, library_reference);
}
::AssetLibrary *AS_asset_library_load(const char *name, const char *library_path)
::AssetLibrary *AS_asset_library_load(const char *name, const char *library_dirpath)
{
/* NOTE: Loading an asset library at this point only means loading the catalogs.
* Later on this should invoke reading of asset representations too. */
AssetLibraryService *service = AssetLibraryService::get();
asset_system::AssetLibrary *lib;
if (library_path == nullptr || library_path[0] == '\0') {
if (library_dirpath == nullptr || library_dirpath[0] == '\0') {
lib = service->get_asset_library_current_file();
}
else {
lib = service->get_asset_library_on_disk_custom(name, library_path);
lib = service->get_asset_library_on_disk_custom(name, library_dirpath);
}
return reinterpret_cast<::AssetLibrary *>(lib);
}
@ -79,7 +79,7 @@ std::string AS_asset_library_find_suitable_root_path_from_path(
if (bUserAssetLibrary *preferences_lib = BKE_preferences_asset_library_containing_path(
&U, input_path.c_str()))
{
return preferences_lib->path;
return preferences_lib->dirpath;
}
char buffer[FILE_MAXDIR];
@ -342,7 +342,7 @@ Vector<AssetLibraryReference> all_valid_asset_library_refs()
}
int i;
LISTBASE_FOREACH_INDEX (const bUserAssetLibrary *, asset_library, &U.asset_libraries, i) {
if (!BLI_is_dir(asset_library->path)) {
if (!BLI_is_dir(asset_library->dirpath)) {
continue;
}
AssetLibraryReference library_ref{};

View File

@ -95,7 +95,7 @@ AssetLibrary *AssetLibraryService::get_asset_library(
return nullptr;
}
std::string root_path = custom_library->path;
std::string root_path = custom_library->dirpath;
if (root_path.empty()) {
return nullptr;
}
@ -252,14 +252,14 @@ AssetLibrary *AssetLibraryService::find_loaded_on_disk_asset_library_from_name(
std::string AssetLibraryService::resolve_asset_weak_reference_to_library_path(
const AssetWeakReference &asset_reference)
{
StringRefNull library_path;
StringRefNull library_dirpath;
switch (eAssetLibraryType(asset_reference.asset_library_type)) {
case ASSET_LIBRARY_CUSTOM: {
bUserAssetLibrary *custom_lib = find_custom_preferences_asset_library_from_asset_weak_ref(
asset_reference);
if (custom_lib) {
library_path = custom_lib->path;
library_dirpath = custom_lib->dirpath;
break;
}
@ -271,19 +271,19 @@ std::string AssetLibraryService::resolve_asset_weak_reference_to_library_path(
return "";
}
library_path = *loaded_custom_lib->root_path_;
library_dirpath = *loaded_custom_lib->root_path_;
break;
}
case ASSET_LIBRARY_ESSENTIALS:
library_path = essentials_directory_path();
library_dirpath = essentials_directory_path();
break;
case ASSET_LIBRARY_LOCAL:
case ASSET_LIBRARY_ALL:
return "";
}
std::string normalized_library_path = utils::normalize_path(library_path);
return normalized_library_path;
std::string normalized_library_dirpath = utils::normalize_path(library_dirpath);
return normalized_library_dirpath;
}
int64_t AssetLibraryService::rfind_blendfile_extension(StringRef path)
@ -353,12 +353,12 @@ std::string AssetLibraryService::resolve_asset_weak_reference_to_full_path(
return "";
}
std::string library_path = resolve_asset_weak_reference_to_library_path(asset_reference);
if (library_path.empty()) {
std::string library_dirpath = resolve_asset_weak_reference_to_library_path(asset_reference);
if (library_dirpath.empty()) {
return "";
}
std::string normalized_full_path = utils::normalize_path(library_path + SEP_STR) +
std::string normalized_full_path = utils::normalize_path(library_dirpath + SEP_STR) +
normalize_asset_weak_reference_relative_asset_identifier(
asset_reference);
@ -443,11 +443,11 @@ std::string AssetLibraryService::root_path_from_library_ref(
bUserAssetLibrary *custom_library = find_custom_asset_library_from_library_ref(
library_reference);
if (!custom_library || !custom_library->path[0]) {
if (!custom_library || !custom_library->dirpath[0]) {
return "";
}
return custom_library->path;
return custom_library->dirpath;
}
void AssetLibraryService::allocate_service_instance()

View File

@ -43,8 +43,8 @@ TEST_F(AssetLibraryTest, AS_asset_library_load)
}
/* Load the asset library. */
const std::string library_path = test_files_dir + "/" + "asset_library";
::AssetLibrary *library_c_ptr = AS_asset_library_load(__func__, library_path.data());
const std::string library_dirpath = test_files_dir + "/" + "asset_library";
::AssetLibrary *library_c_ptr = AS_asset_library_load(__func__, library_dirpath.data());
ASSERT_NE(nullptr, library_c_ptr);
/* Check that it can be cast to the C++ type and has a Catalog Service. */
@ -70,9 +70,9 @@ TEST_F(AssetLibraryTest, load_nonexistent_directory)
}
/* Load the asset library. */
const std::string library_path = test_files_dir + "/" +
"asset_library/this/subdir/does/not/exist";
::AssetLibrary *library_c_ptr = AS_asset_library_load(__func__, library_path.data());
const std::string library_dirpath = test_files_dir + "/" +
"asset_library/this/subdir/does/not/exist";
::AssetLibrary *library_c_ptr = AS_asset_library_load(__func__, library_dirpath.data());
ASSERT_NE(nullptr, library_c_ptr);
/* Check that it can be cast to the C++ type and has a Catalog Service. */

View File

@ -22,7 +22,7 @@ struct bUserAssetLibrary;
struct bUserAssetLibrary *BKE_preferences_asset_library_add(struct UserDef *userdef,
const char *name,
const char *path) ATTR_NONNULL(1);
const char *dirpath) ATTR_NONNULL(1);
/**
* Unlink and free a library preference member.
* \note Free's \a library itself.

View File

@ -412,8 +412,8 @@ static bool get_path_local(char *targetpath,
bool BKE_appdir_app_is_portable_install(void)
{
/* Detect portable install by the existence of `config` folder. */
char path[FILE_MAX];
return get_path_local(path, sizeof(path), "config", NULL);
char dirpath[FILE_MAX];
return get_path_local(dirpath, sizeof(dirpath), "config", NULL);
}
/**

View File

@ -37,7 +37,7 @@
bUserAssetLibrary *BKE_preferences_asset_library_add(UserDef *userdef,
const char *name,
const char *path)
const char *dirpath)
{
bUserAssetLibrary *library = MEM_callocN(sizeof(*library), "bUserAssetLibrary");
memcpy(library, DNA_struct_default_get(bUserAssetLibrary), sizeof(*library));
@ -47,8 +47,8 @@ bUserAssetLibrary *BKE_preferences_asset_library_add(UserDef *userdef,
if (name) {
BKE_preferences_asset_library_name_set(userdef, library, name);
}
if (path) {
STRNCPY(library->path, path);
if (dirpath) {
STRNCPY(library->dirpath, dirpath);
}
return library;
@ -74,9 +74,9 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef,
void BKE_preferences_asset_library_path_set(bUserAssetLibrary *library, const char *path)
{
STRNCPY(library->path, path);
if (BLI_is_file(library->path)) {
BLI_path_parent_dir(library->path);
STRNCPY(library->dirpath, path);
if (BLI_is_file(library->dirpath)) {
BLI_path_parent_dir(library->dirpath);
}
}
@ -95,7 +95,7 @@ bUserAssetLibrary *BKE_preferences_asset_library_containing_path(const UserDef *
const char *path)
{
LISTBASE_FOREACH (bUserAssetLibrary *, asset_lib_pref, &userdef->asset_libraries) {
if (BLI_path_contains(asset_lib_pref->path, path)) {
if (BLI_path_contains(asset_lib_pref->dirpath, path)) {
return asset_lib_pref;
}
}
@ -121,7 +121,8 @@ void BKE_preferences_asset_library_default_add(UserDef *userdef)
userdef, DATA_(BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME), NULL);
/* Add new "Default" library under '[doc_path]/Blender/Assets'. */
BLI_path_join(library->path, sizeof(library->path), documents_path, N_("Blender"), N_("Assets"));
BLI_path_join(
library->dirpath, sizeof(library->dirpath), documents_path, N_("Blender"), N_("Assets"));
}
/** \} */

View File

@ -63,7 +63,7 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
library.custom_library_index = -1;
}
else {
const bool is_valid = (user_library->name[0] && user_library->path[0]);
const bool is_valid = (user_library->name[0] && user_library->dirpath[0]);
if (is_valid) {
library.custom_library_index = value - ASSET_LIBRARY_CUSTOM;
library.type = ASSET_LIBRARY_CUSTOM;
@ -108,7 +108,7 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
LISTBASE_FOREACH_INDEX (bUserAssetLibrary *, user_library, &U.asset_libraries, i) {
/* Note that the path itself isn't checked for validity here. If an invalid library path is
* used, the Asset Browser can give a nice hint on what's wrong. */
const bool is_valid = (user_library->name[0] && user_library->path[0]);
const bool is_valid = (user_library->name[0] && user_library->dirpath[0]);
if (!is_valid) {
continue;
}
@ -120,7 +120,7 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
const int enum_value = ED_asset_library_reference_to_enum_value(&library_reference);
/* Use library path as description, it's a nice hint for users. */
EnumPropertyItem tmp = {
enum_value, user_library->name, ICON_NONE, user_library->name, user_library->path};
enum_value, user_library->name, ICON_NONE, user_library->name, user_library->dirpath};
RNA_enum_item_add(&item, &totitem, &tmp);
}

View File

@ -155,11 +155,11 @@ void AssetList::setup()
const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing);
filelist_setindexer(files, use_asset_indexer ? &file_indexer_asset : &file_indexer_noop);
char path[FILE_MAX_LIBEXTRA] = "";
char dirpath[FILE_MAX_LIBEXTRA] = "";
if (!asset_lib_path.empty()) {
STRNCPY(path, asset_lib_path.c_str());
STRNCPY(dirpath, asset_lib_path.c_str());
}
filelist_setdir(files, path);
filelist_setdir(files, dirpath);
}
void AssetList::fetch(const bContext &C)

View File

@ -854,7 +854,7 @@ static bool is_contained_in_selected_asset_library(wmOperator *op, const char *f
if (!lib) {
return false;
}
return BLI_path_contains(lib->path, filepath);
return BLI_path_contains(lib->dirpath, filepath);
}
/**
@ -876,7 +876,7 @@ static bool set_filepath_for_asset_lib(const Main *bmain, wmOperator *op)
}
char file_path[PATH_MAX];
BLI_path_join(file_path, sizeof(file_path), lib->path, blend_filename);
BLI_path_join(file_path, sizeof(file_path), lib->dirpath, blend_filename);
RNA_string_set(op->ptr, "filepath", file_path);
return true;

View File

@ -2420,7 +2420,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
Mesh *me = (ob) ? static_cast<Mesh *>(ob->data) : static_cast<Mesh *>(op->customdata);
char path[FILE_MAX];
char filepath[FILE_MAX];
const bool relative = RNA_boolean_get(op->ptr, "relative_path");
if (!me) {
@ -2431,13 +2431,13 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
RNA_string_get(op->ptr, "filepath", path);
RNA_string_get(op->ptr, "filepath", filepath);
if (relative) {
BLI_path_rel(path, BKE_main_blendfile_path(bmain));
BLI_path_rel(filepath, BKE_main_blendfile_path(bmain));
}
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, filepath);
CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH.lmask, me->totloop, 0);
return OPERATOR_FINISHED;
@ -2447,7 +2447,7 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv
{
Object *ob = ED_object_active_context(C);
Mesh *me = static_cast<Mesh *>(ob->data);
char path[FILE_MAX];
char filepath[FILE_MAX];
if (!edit_modifier_invoke_properties(C, op)) {
return OPERATOR_CANCELLED;
@ -2470,8 +2470,8 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv
op->customdata = me;
SNPRINTF(path, "//%s.btx", me->id.name + 2);
RNA_string_set(op->ptr, "filepath", path);
SNPRINTF(filepath, "//%s.btx", me->id.name + 2);
RNA_string_set(op->ptr, "filepath", filepath);
WM_event_add_fileselect(C, op);

View File

@ -135,7 +135,7 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
RigidBodyWorld *rbw = scene->rigidbody_world;
char path[FILE_MAX];
char filepath[FILE_MAX];
/* sanity checks */
if (ELEM(NULL, scene, rbw)) {
@ -148,9 +148,9 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
RNA_string_get(op->ptr, "filepath", path);
RNA_string_get(op->ptr, "filepath", filepath);
#ifdef WITH_BULLET
RB_dworld_export(rbw->shared->physics_world, path);
RB_dworld_export(rbw->shared->physics_world, filepath);
#endif
return OPERATOR_FINISHED;
}

View File

@ -112,10 +112,10 @@ static int screenshot_exec(bContext *C, wmOperator *op)
if (scd) {
if (scd->dumprect) {
ImBuf *ibuf;
char path[FILE_MAX];
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
BLI_path_abs(path, BKE_main_blendfile_path_from_global());
RNA_string_get(op->ptr, "filepath", filepath);
BLI_path_abs(filepath, BKE_main_blendfile_path_from_global());
/* operator ensures the extension */
ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
@ -133,7 +133,7 @@ static int screenshot_exec(bContext *C, wmOperator *op)
/* bw screenshot? - users will notice if it fails! */
IMB_color_to_bw(ibuf);
}
if (BKE_imbuf_write(ibuf, path, &scd->im_format)) {
if (BKE_imbuf_write(ibuf, filepath, &scd->im_format)) {
ok = true;
}
else {

View File

@ -73,14 +73,14 @@ static void sound_open_init(bContext *C, wmOperator *op)
#ifdef WITH_AUDASPACE
static int sound_open_exec(bContext *C, wmOperator *op)
{
char path[FILE_MAX];
char filepath[FILE_MAX];
bSound *sound;
PropertyPointerRNA *pprop;
PointerRNA idptr;
Main *bmain = CTX_data_main(C);
RNA_string_get(op->ptr, "filepath", path);
sound = BKE_sound_new_file(bmain, path);
RNA_string_get(op->ptr, "filepath", filepath);
sound = BKE_sound_new_file(bmain, filepath);
if (!op->customdata) {
sound_open_init(C, op);

View File

@ -184,8 +184,8 @@ static int file_browse_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
FileBrowseOp *fbo = op->customdata;
ID *id;
char *str;
int str_len;
char *path;
int path_len;
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" :
"filepath";
@ -193,41 +193,41 @@ static int file_browse_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0, &str_len);
path = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0, &path_len);
/* Add slash for directories, important for some properties. */
if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) {
char path[FILE_MAX];
char path_buf[FILE_MAX];
const bool is_relative = RNA_boolean_get(op->ptr, "relative_path");
id = fbo->ptr.owner_id;
STRNCPY(path, str);
BLI_path_abs(path, id ? ID_BLEND_PATH(bmain, id) : BKE_main_blendfile_path(bmain));
STRNCPY(path_buf, path);
BLI_path_abs(path_buf, id ? ID_BLEND_PATH(bmain, id) : BKE_main_blendfile_path(bmain));
if (BLI_is_dir(path)) {
if (BLI_is_dir(path_buf)) {
/* Do this first so '//' isn't converted to '//\' on windows. */
BLI_path_slash_ensure(path, sizeof(path));
BLI_path_slash_ensure(path_buf, sizeof(path_buf));
if (is_relative) {
BLI_path_rel(path, BKE_main_blendfile_path(bmain));
str_len = strlen(path);
str = MEM_reallocN(str, str_len + 1);
memcpy(str, path, str_len + 1);
BLI_path_rel(path_buf, BKE_main_blendfile_path(bmain));
path_len = strlen(path_buf);
path = MEM_reallocN(path, path_len + 1);
memcpy(path, path_buf, path_len + 1);
}
else {
str = MEM_reallocN(str, str_len + 1);
path = MEM_reallocN(path, path_len + 1);
}
}
else {
char *const lslash = (char *)BLI_path_slash_rfind(str);
char *const lslash = (char *)BLI_path_slash_rfind(path);
if (lslash) {
lslash[1] = '\0';
}
}
}
RNA_property_string_set(&fbo->ptr, fbo->prop, str);
RNA_property_string_set(&fbo->ptr, fbo->prop, path);
RNA_property_update(C, &fbo->ptr, fbo->prop);
MEM_freeN(str);
MEM_freeN(path);
if (fbo->is_undo) {
const char *undostr = RNA_property_identifier(fbo->prop);
@ -267,7 +267,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool is_undo;
bool is_userdef;
FileBrowseOp *fbo;
char *str;
char *path;
const SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile && sfile->op) {
@ -281,7 +281,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
path = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
/* Useful yet irritating feature, Shift+Click to open the file
* Alt+Click to browse a folder in the OS's browser. */
@ -290,18 +290,18 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
PointerRNA props_ptr;
if (event->modifier & KM_ALT) {
char *lslash = (char *)BLI_path_slash_rfind(str);
char *lslash = (char *)BLI_path_slash_rfind(path);
if (lslash) {
*lslash = '\0';
}
}
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "filepath", str);
RNA_string_set(&props_ptr, "filepath", path);
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr, NULL);
WM_operator_properties_free(&props_ptr);
MEM_freeN(str);
MEM_freeN(path);
return OPERATOR_CANCELLED;
}
@ -323,8 +323,8 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* While we want to follow the defaults,
* we better not switch existing paths relative/absolute state. */
if (str[0]) {
is_relative = BLI_path_is_rel(str);
if (path[0]) {
is_relative = BLI_path_is_rel(path);
}
if (UNLIKELY(ptr.data == &U || is_userdef)) {
@ -336,8 +336,8 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
RNA_string_set(op->ptr, path_prop, str);
MEM_freeN(str);
RNA_string_set(op->ptr, path_prop, path);
MEM_freeN(path);
PropertyRNA *prop_check_existing = RNA_struct_find_property(op->ptr, "check_existing");
if (!RNA_property_is_set(op->ptr, prop_check_existing)) {

View File

@ -156,9 +156,9 @@ static void sclip_zoom_set_factor_exec(bContext *C, const wmEvent *event, float
/** \name Open Clip Operator
* \{ */
static void clip_filesel(bContext *C, wmOperator *op, const char *path)
static void clip_filesel(bContext *C, wmOperator *op, const char *dirpath)
{
RNA_string_set(op->ptr, "directory", path);
RNA_string_set(op->ptr, "directory", dirpath);
WM_event_add_fileselect(C, op);
}
@ -261,7 +261,7 @@ static int open_exec(bContext *C, wmOperator *op)
static int open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
SpaceClip *sc = CTX_wm_space_clip(C);
char path[FILE_MAX];
char dirpath[FILE_MAX];
MovieClip *clip = nullptr;
if (sc) {
@ -269,13 +269,13 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
}
if (clip) {
STRNCPY(path, clip->filepath);
STRNCPY(dirpath, clip->filepath);
BLI_path_abs(path, CTX_data_main(C)->filepath);
BLI_path_parent_dir(path);
BLI_path_abs(dirpath, CTX_data_main(C)->filepath);
BLI_path_parent_dir(dirpath);
}
else {
STRNCPY(path, U.textudir);
STRNCPY(dirpath, U.textudir);
}
if (RNA_struct_property_is_set(op->ptr, "files")) {
@ -288,7 +288,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
open_init(C, op);
clip_filesel(C, op, path);
clip_filesel(C, op, dirpath);
return OPERATOR_RUNNING_MODAL;
}

View File

@ -2613,7 +2613,7 @@ static bool new_folder_path(const char *parent,
static int file_directory_new_exec(bContext *C, wmOperator *op)
{
char dirname[FILE_MAXFILE];
char path[FILE_MAX];
char dirpath[FILE_MAX];
bool generate_name = true;
wmWindowManager *wm = CTX_wm_manager(C);
@ -2626,19 +2626,19 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
path[0] = '\0';
dirpath[0] = '\0';
{
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "directory");
RNA_property_string_get(op->ptr, prop, path);
if (path[0] != '\0') {
RNA_property_string_get(op->ptr, prop, dirpath);
if (dirpath[0] != '\0') {
generate_name = false;
}
}
if (generate_name) {
/* create a new, non-existing folder name */
if (!new_folder_path(params->dir, path, dirname)) {
if (!new_folder_path(params->dir, dirpath, dirname)) {
BKE_report(op->reports, RPT_ERROR, "Could not create new folder name");
return OPERATOR_CANCELLED;
}
@ -2646,22 +2646,22 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
else { /* We assume we are able to generate a valid name! */
char org_path[FILE_MAX];
STRNCPY(org_path, path);
if (BLI_path_make_safe(path)) {
STRNCPY(org_path, dirpath);
if (BLI_path_make_safe(dirpath)) {
BKE_reportf(op->reports,
RPT_WARNING,
"'%s' given path is OS-invalid, creating '%s' path instead",
org_path,
path);
dirpath);
}
}
/* create the file */
errno = 0;
if (!BLI_dir_create_recursive(path) ||
if (!BLI_dir_create_recursive(dirpath) ||
/* Should no more be needed,
* now that BLI_dir_create_recursive returns a success state - but kept just in case. */
!BLI_exists(path))
!BLI_exists(dirpath))
{
BKE_reportf(op->reports,
RPT_ERROR,
@ -2688,7 +2688,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
ED_fileselect_clear(wm, sfile);
if (do_diropen) {
STRNCPY(params->dir, path);
STRNCPY(params->dir, dirpath);
ED_file_change_dir(C);
}
@ -2809,10 +2809,10 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
char *group, *name;
if (BLI_is_file(params->dir)) {
char path[sizeof(params->dir)];
STRNCPY(path, params->dir);
char dirpath[sizeof(params->dir)];
STRNCPY(dirpath, params->dir);
BLI_path_split_dir_file(
path, params->dir, sizeof(params->dir), params->file, sizeof(params->file));
dirpath, params->dir, sizeof(params->dir), params->file, sizeof(params->file));
}
else if (BKE_blendfile_library_path_explode(params->dir, tdir, &group, &name)) {
if (group) {

View File

@ -1146,16 +1146,16 @@ void filelist_free_icons(void)
void filelist_file_get_full_path(const FileList *filelist,
const FileDirEntry *file,
char r_path[/*FILE_MAX_LIBEXTRA*/])
char r_filepath[/*FILE_MAX_LIBEXTRA*/])
{
if (file->asset) {
const std::string asset_path = AS_asset_representation_full_path_get(file->asset);
BLI_strncpy(r_path, asset_path.c_str(), FILE_MAX_LIBEXTRA);
BLI_strncpy(r_filepath, asset_path.c_str(), FILE_MAX_LIBEXTRA);
return;
}
const char *root = filelist_dir(filelist);
BLI_path_join(r_path, FILE_MAX_LIBEXTRA, root, file->relpath);
BLI_path_join(r_filepath, FILE_MAX_LIBEXTRA, root, file->relpath);
}
static FileDirEntry *filelist_geticon_get_file(FileList *filelist, const int index)

View File

@ -74,7 +74,7 @@ void filelist_init_icons(void);
void filelist_free_icons(void);
void filelist_file_get_full_path(const struct FileList *filelist,
const FileDirEntry *file,
char r_path[/*FILE_MAX_LIBEXTRA*/]);
char r_filepath[/*FILE_MAX_LIBEXTRA*/]);
struct ImBuf *filelist_getimage(struct FileList *filelist, int index);
struct ImBuf *filelist_file_getimage(const FileDirEntry *file);
struct ImBuf *filelist_geticon_image_ex(const FileDirEntry *file);

View File

@ -446,7 +446,7 @@ static void fileselect_refresh_asset_params(FileAssetSelectParams *asset_params)
break;
case ASSET_LIBRARY_CUSTOM:
BLI_assert(user_library);
STRNCPY(base_params->dir, user_library->path);
STRNCPY(base_params->dir, user_library->dirpath);
base_params->type = FILE_ASSET_LIBRARY;
break;
}
@ -1232,14 +1232,14 @@ int autocomplete_directory(bContext *C, char *str, void * /*arg_v*/)
/* pass */
}
else {
char path[FILE_MAX];
char dirpath[FILE_MAX];
BLI_stat_t status;
BLI_path_join(path, sizeof(path), dirname, de->d_name);
BLI_path_join(dirpath, sizeof(dirpath), dirname, de->d_name);
if (BLI_stat(path, &status) == 0) {
if (BLI_stat(dirpath, &status) == 0) {
if (S_ISDIR(status.st_mode)) { /* is subdir */
UI_autocomplete_update_name(autocpl, path);
UI_autocomplete_update_name(autocpl, dirpath);
}
}
}

View File

@ -1087,24 +1087,24 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
Scene *scene = NULL;
int start, end;
char path[FILE_MAX];
char filepath[FILE_MAX];
/* Get editor data. */
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
RNA_string_get(op->ptr, "filepath", path);
RNA_string_get(op->ptr, "filepath", filepath);
if (!BLI_is_file(path)) {
BKE_reportf(op->reports, RPT_ERROR, "File not found '%s'", path);
if (!BLI_is_file(filepath)) {
BKE_reportf(op->reports, RPT_ERROR, "File not found '%s'", filepath);
return OPERATOR_CANCELLED;
}
scene = ac.scene; /* Current scene. */
/* Store necessary data for the baking steps. */
sbi.samples = AUD_readSoundBuffer(path,
sbi.samples = AUD_readSoundBuffer(filepath,
RNA_float_get(op->ptr, "low"),
RNA_float_get(op->ptr, "high"),
RNA_float_get(op->ptr, "attack"),

View File

@ -32,10 +32,10 @@
static int run_pyfile_exec(bContext *C, wmOperator *op)
{
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
#ifdef WITH_PYTHON
if (BPY_run_filepath(C, path, op->reports)) {
if (BPY_run_filepath(C, filepath, op->reports)) {
ARegion *region = CTX_wm_region(C);
if (region != NULL) {
ED_region_tag_redraw(region);

View File

@ -179,10 +179,10 @@ static void sequencer_generic_invoke_path__internal(bContext *C,
Sequence *last_seq = SEQ_select_active_get(scene);
if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
Main *bmain = CTX_data_main(C);
char path[FILE_MAX];
STRNCPY(path, last_seq->strip->dirpath);
BLI_path_abs(path, BKE_main_blendfile_path(bmain));
RNA_string_set(op->ptr, identifier, path);
char dirpath[FILE_MAX];
STRNCPY(dirpath, last_seq->strip->dirpath);
BLI_path_abs(dirpath, BKE_main_blendfile_path(bmain));
RNA_string_set(op->ptr, identifier, dirpath);
}
}
}

View File

@ -507,6 +507,10 @@ static bool generic_drop_draw_handling(wmDropBox *drop)
}
typedef struct DropJobData {
/**
* This is practically always a `filepath`, however that isn't a requirement
* for drag-and-drop, so keep the name generic.
*/
char path[FILE_MAX];
bool only_audio;
float scene_fps;

View File

@ -106,7 +106,7 @@ bool ABC_import(struct bContext *C,
bool as_background_job);
struct CacheArchiveHandle *ABC_create_handle(struct Main *bmain,
const char *filename,
const char *filepath,
const struct CacheFileLayer *layers,
struct ListBase *object_paths);

View File

@ -153,24 +153,24 @@ static bool gather_objects_paths(const IObject &object, ListBase *object_paths)
}
CacheArchiveHandle *ABC_create_handle(Main *bmain,
const char *filename,
const char *filepath,
const CacheFileLayer *layers,
ListBase *object_paths)
{
std::vector<const char *> filenames;
filenames.push_back(filename);
std::vector<const char *> filepaths;
filepaths.push_back(filepath);
while (layers) {
if ((layers->flag & CACHEFILE_LAYER_HIDDEN) == 0) {
filenames.push_back(layers->filepath);
filepaths.push_back(layers->filepath);
}
layers = layers->next;
}
/* We need to reverse the order as overriding archives should come first. */
std::reverse(filenames.begin(), filenames.end());
std::reverse(filepaths.begin(), filepaths.end());
ArchiveReader *archive = ArchiveReader::get(bmain, filenames);
ArchiveReader *archive = ArchiveReader::get(bmain, filepaths);
if (!archive || !archive->valid()) {
delete archive;
@ -426,7 +426,7 @@ struct ImportJobData {
ViewLayer *view_layer;
wmWindowManager *wm;
char filename[1024];
char filepath[1024];
ImportSettings settings;
ArchiveReader *archive;
@ -446,7 +446,7 @@ struct ImportJobData {
static void report_job_duration(const ImportJobData *data)
{
blender::timeit::Nanoseconds duration = blender::timeit::Clock::now() - data->start_time;
std::cout << "Alembic import of '" << data->filename << "' took ";
std::cout << "Alembic import of '" << data->filepath << "' took ";
blender::timeit::print_duration(duration);
std::cout << '\n';
}
@ -464,7 +464,7 @@ static void import_startjob(void *user_data, bool *stop, bool *do_update, float
WM_set_locked_interface(data->wm, true);
ArchiveReader *archive = ArchiveReader::get(data->bmain, {data->filename});
ArchiveReader *archive = ArchiveReader::get(data->bmain, {data->filepath});
if (!archive || !archive->valid()) {
data->error_code = ABC_ARCHIVE_FAIL;
@ -473,7 +473,7 @@ static void import_startjob(void *user_data, bool *stop, bool *do_update, float
}
CacheFile *cache_file = static_cast<CacheFile *>(
BKE_cachefile_add(data->bmain, BLI_path_basename(data->filename)));
BKE_cachefile_add(data->bmain, BLI_path_basename(data->filepath)));
/* Decrement the ID ref-count because it is going to be incremented for each
* modifier and constraint that it will be attached to, so since currently
@ -482,7 +482,7 @@ static void import_startjob(void *user_data, bool *stop, bool *do_update, float
cache_file->is_sequence = data->settings.is_sequence;
cache_file->scale = data->settings.scale;
STRNCPY(cache_file->filepath, data->filename);
STRNCPY(cache_file->filepath, data->filepath);
data->archive = archive;
data->settings.cache_file = cache_file;
@ -525,7 +525,7 @@ static void import_startjob(void *user_data, bool *stop, bool *do_update, float
max_time = std::max(max_time, reader->maxTime());
}
else {
std::cerr << "Object " << reader->name() << " in Alembic file " << data->filename
std::cerr << "Object " << reader->name() << " in Alembic file " << data->filepath
<< " is invalid.\n";
}
@ -686,7 +686,7 @@ bool ABC_import(bContext *C,
job->view_layer = CTX_data_view_layer(C);
job->wm = CTX_wm_manager(C);
job->import_ok = false;
STRNCPY(job->filename, filepath);
STRNCPY(job->filepath, filepath);
job->settings.scale = params->global_scale;
job->settings.is_sequence = params->is_sequence;

View File

@ -112,9 +112,9 @@ static void export_texture(bNode *node,
const bool allow_overwrite = false);
static bNode *find_bsdf_node(Material *material);
static void get_absolute_path(Image *ima, char *r_path);
static std::string get_tex_image_asset_path(bNode *node,
const pxr::UsdStageRefPtr stage,
const USDExportParams &export_params);
static std::string get_tex_image_asset_filepath(bNode *node,
const pxr::UsdStageRefPtr stage,
const USDExportParams &export_params);
static InputSpecMap &preview_surface_input_map();
static bNodeLink *traverse_channel(bNodeSocket *input, short target_type);
@ -582,7 +582,7 @@ static pxr::UsdShadeShader create_usd_preview_shader(const USDExporterContext &u
}
/* For texture image nodes we set the image path and color space. */
std::string imagePath = get_tex_image_asset_path(
std::string imagePath = get_tex_image_asset_filepath(
node, usd_export_context.stage, usd_export_context.export_params);
if (!imagePath.empty()) {
shader.CreateInput(usdtokens::file, pxr::SdfValueTypeNames->Asset)
@ -597,7 +597,7 @@ static pxr::UsdShadeShader create_usd_preview_shader(const USDExporterContext &u
return shader;
}
static std::string get_tex_image_asset_path(Image *ima)
static std::string get_tex_image_asset_filepath(Image *ima)
{
char filepath[FILE_MAX];
get_absolute_path(ima, filepath);
@ -612,9 +612,9 @@ static std::string get_tex_image_asset_path(Image *ima)
* generated based on the image name for in-memory textures when exporting textures.
* This function may return an empty string if the image does not have a filepath
* assigned and no asset path could be determined. */
static std::string get_tex_image_asset_path(bNode *node,
const pxr::UsdStageRefPtr stage,
const USDExportParams &export_params)
static std::string get_tex_image_asset_filepath(bNode *node,
const pxr::UsdStageRefPtr stage,
const USDExportParams &export_params)
{
Image *ima = reinterpret_cast<Image *>(node->id);
if (!ima) {
@ -625,7 +625,7 @@ static std::string get_tex_image_asset_path(bNode *node,
if (strlen(ima->filepath) > 0) {
/* Get absolute path. */
path = get_tex_image_asset_path(ima);
path = get_tex_image_asset_filepath(ima);
}
else if (export_params.export_textures) {
/* Image has no filepath, but since we are exporting textures,

View File

@ -150,18 +150,18 @@ static std::string get_image_filepath(const bNode *tex_node)
return filename;
}
char path[FILE_MAX];
STRNCPY(path, tex_image->filepath);
char filepath[FILE_MAX];
STRNCPY(filepath, tex_image->filepath);
if (tex_image->source == IMA_SRC_SEQUENCE) {
char head[FILE_MAX], tail[FILE_MAX];
ushort numlen;
int framenr = static_cast<NodeTexImage *>(tex_node->storage)->iuser.framenr;
BLI_path_sequence_decode(path, head, sizeof(head), tail, sizeof(tail), &numlen);
BLI_path_sequence_encode(path, sizeof(path), head, tail, numlen, framenr);
BLI_path_sequence_decode(filepath, head, sizeof(head), tail, sizeof(tail), &numlen);
BLI_path_sequence_encode(filepath, sizeof(filepath), head, tail, numlen, framenr);
}
return path;
return filepath;
}
/**

View File

@ -594,8 +594,8 @@ enum {
typedef struct bUserAssetLibrary {
struct bUserAssetLibrary *next, *prev;
char name[64]; /* MAX_NAME */
char path[1024]; /* FILE_MAX */
char name[64]; /* MAX_NAME */
char dirpath[1024]; /* FILE_MAX */
short import_method; /* eAssetImportMethod */
short flag; /* eAssetLibrary_Flag */

View File

@ -192,6 +192,7 @@ DNA_STRUCT_RENAME_ELEM(bTheme, tstatusbar, space_statusbar)
DNA_STRUCT_RENAME_ELEM(bTheme, ttopbar, space_topbar)
DNA_STRUCT_RENAME_ELEM(bTheme, tuserpref, space_preferences)
DNA_STRUCT_RENAME_ELEM(bTheme, tv3d, space_view3d)
DNA_STRUCT_RENAME_ELEM(bUserAssetLibrary, path, dirpath)
/* Write with a different name, old Blender versions crash loading files with non-NULL
* global_areas. See D9442. */
DNA_STRUCT_RENAME_ELEM(wmWindow, global_area_map, global_areas)

View File

@ -894,11 +894,11 @@ static void rna_DashGpencilModifierSegment_name_set(PointerRNA *ptr, const char
char name_esc[sizeof(ds->dmd->modifier.name) * 2];
BLI_str_escape(name_esc, ds->dmd->modifier.name, sizeof(name_esc));
char prefix[36 + sizeof(name_esc) + 1];
SNPRINTF(prefix, "grease_pencil_modifiers[\"%s\"].segments", name_esc);
char rna_path_prefix[36 + sizeof(name_esc) + 1];
SNPRINTF(rna_path_prefix, "grease_pencil_modifiers[\"%s\"].segments", name_esc);
/* Fix all the animation data which may link to this. */
BKE_animdata_fix_paths_rename_all(NULL, prefix, oldname, ds->name);
BKE_animdata_fix_paths_rename_all(NULL, rna_path_prefix, oldname, ds->name);
}
static void rna_TimeGpencilModifierSegment_name_set(PointerRNA *ptr, const char *value)
@ -917,11 +917,11 @@ static void rna_TimeGpencilModifierSegment_name_set(PointerRNA *ptr, const char
char name_esc[sizeof(ds->gpmd->modifier.name) * 2];
BLI_str_escape(name_esc, ds->gpmd->modifier.name, sizeof(name_esc));
char prefix[36 + sizeof(name_esc) + 1];
SNPRINTF(prefix, "grease_pencil_modifiers[\"%s\"].segments", name_esc);
char rna_path_prefix[36 + sizeof(name_esc) + 1];
SNPRINTF(rna_path_prefix, "grease_pencil_modifiers[\"%s\"].segments", name_esc);
/* Fix all the animation data which may link to this. */
BKE_animdata_fix_paths_rename_all(NULL, prefix, oldname, ds->name);
BKE_animdata_fix_paths_rename_all(NULL, rna_path_prefix, oldname, ds->name);
}
static int rna_ShrinkwrapGpencilModifier_face_cull_get(PointerRNA *ptr)

View File

@ -857,19 +857,19 @@ static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value)
static void rna_Sequence_filepath_get(PointerRNA *ptr, char *value)
{
Sequence *seq = (Sequence *)(ptr->data);
char path[FILE_MAX];
char filepath[FILE_MAX];
BLI_path_join(path, sizeof(path), seq->strip->dirpath, seq->strip->stripdata->filename);
strcpy(value, path);
BLI_path_join(filepath, sizeof(filepath), seq->strip->dirpath, seq->strip->stripdata->filename);
strcpy(value, filepath);
}
static int rna_Sequence_filepath_length(PointerRNA *ptr)
{
Sequence *seq = (Sequence *)(ptr->data);
char path[FILE_MAX];
char filepath[FILE_MAX];
BLI_path_join(path, sizeof(path), seq->strip->dirpath, seq->strip->stripdata->filename);
return strlen(path);
BLI_path_join(filepath, sizeof(filepath), seq->strip->dirpath, seq->strip->stripdata->filename);
return strlen(filepath);
}
static void rna_Sequence_proxy_filepath_set(PointerRNA *ptr, const char *value)
@ -886,19 +886,19 @@ static void rna_Sequence_proxy_filepath_set(PointerRNA *ptr, const char *value)
static void rna_Sequence_proxy_filepath_get(PointerRNA *ptr, char *value)
{
StripProxy *proxy = (StripProxy *)(ptr->data);
char path[FILE_MAX];
char filepath[FILE_MAX];
BLI_path_join(path, sizeof(path), proxy->dirpath, proxy->filename);
strcpy(value, path);
BLI_path_join(filepath, sizeof(filepath), proxy->dirpath, proxy->filename);
strcpy(value, filepath);
}
static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr)
{
StripProxy *proxy = (StripProxy *)(ptr->data);
char path[FILE_MAX];
char filepath[FILE_MAX];
BLI_path_join(path, sizeof(path), proxy->dirpath, proxy->filename);
return strlen(path);
BLI_path_join(filepath, sizeof(filepath), proxy->dirpath, proxy->filename);
return strlen(filepath);
}
static void rna_Sequence_audio_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@ -1135,11 +1135,11 @@ static char *rna_SequenceColorBalance_path(const PointerRNA *ptr)
BLI_str_escape(name_esc, seq->name + 2, sizeof(name_esc));
if (!smd) {
/* path to old filter color balance */
/* Path to old filter color balance. */
return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", name_esc);
}
else {
/* path to modifier */
/* Path to modifier. */
char name_esc_smd[sizeof(smd->name) * 2];
BLI_str_escape(name_esc_smd, smd->name, sizeof(name_esc_smd));
@ -1328,13 +1328,14 @@ static void rna_SequenceModifier_name_set(PointerRNA *ptr, const char *value)
/* fix all the animation data which may link to this */
adt = BKE_animdata_from_id(&scene->id);
if (adt) {
char path[1024];
char rna_path_prefix[1024];
char seq_name_esc[(sizeof(seq->name) - 2) * 2];
BLI_str_escape(seq_name_esc, seq->name + 2, sizeof(seq_name_esc));
SNPRINTF(path, "sequence_editor.sequences_all[\"%s\"].modifiers", seq_name_esc);
BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, path, oldname, smd->name, 0, 0, 1);
SNPRINTF(rna_path_prefix, "sequence_editor.sequences_all[\"%s\"].modifiers", seq_name_esc);
BKE_animdata_fix_paths_rename(
&scene->id, adt, NULL, rna_path_prefix, oldname, smd->name, 0, 0, 1);
}
}

View File

@ -273,9 +273,11 @@ static void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value)
/* Fix animation paths. */
AnimData *adt = BKE_animdata_from_id(&clip->id);
if (adt != NULL) {
char rna_path[MAX_NAME * 2 + 64];
BKE_tracking_get_rna_path_prefix_for_track(&clip->tracking, track, rna_path, sizeof(rna_path));
BKE_animdata_fix_paths_rename(&clip->id, adt, NULL, rna_path, old_name, track->name, 0, 0, 1);
char rna_path_prefix[MAX_NAME * 2 + 64];
BKE_tracking_get_rna_path_prefix_for_track(
&clip->tracking, track, rna_path_prefix, sizeof(rna_path_prefix));
BKE_animdata_fix_paths_rename(
&clip->id, adt, NULL, rna_path_prefix, old_name, track->name, 0, 0, 1);
}
}

View File

@ -6272,6 +6272,7 @@ static void rna_def_userdef_filepaths_asset_library(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "path", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "dirpath");
RNA_def_property_ui_text(
prop, "Path", "Path to a directory with .blend files to use as an asset library");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_userdef_asset_library_path_set");

View File

@ -28,7 +28,8 @@ typedef enum eSeqLoadFlags {
typedef struct SeqLoadData {
int start_frame;
int channel;
char name[64]; /* Strip name. */
char name[64]; /* Strip name. */
/** Typically a `filepath` but may reference any kind of path. */
char path[1024]; /* 1024 = FILE_MAX */
struct {
int len;

View File

@ -92,7 +92,7 @@ typedef struct SeqDiskCache {
typedef struct DiskCacheFile {
struct DiskCacheFile *next, *prev;
char path[FILE_MAX];
char filepath[FILE_MAX];
char dir[FILE_MAXDIR];
char file[FILE_MAX];
BLI_stat_t fstat;
@ -137,13 +137,14 @@ bool seq_disk_cache_is_enabled(Main *bmain)
bmain->filepath[0] != '\0');
}
static DiskCacheFile *seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, const char *path)
static DiskCacheFile *seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache,
const char *filepath)
{
DiskCacheFile *cache_file = MEM_callocN(sizeof(DiskCacheFile), "SeqDiskCacheFile");
char dir[FILE_MAXDIR], file[FILE_MAX];
BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file));
STRNCPY(cache_file->path, path);
BLI_path_split_dir_file(filepath, dir, sizeof(dir), file, sizeof(file));
STRNCPY(cache_file->filepath, filepath);
STRNCPY(cache_file->dir, dir);
STRNCPY(cache_file->file, file);
sscanf(file,
@ -159,13 +160,13 @@ static DiskCacheFile *seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache,
return cache_file;
}
static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *path)
static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *dirpath)
{
struct direntry *filelist, *fl;
uint i;
disk_cache->size_total = 0;
const int filelist_num = BLI_filelist_dir_contents(path, &filelist);
const int filelist_num = BLI_filelist_dir_contents(dirpath, &filelist);
i = filelist_num;
fl = filelist;
while (i--) {
@ -218,7 +219,7 @@ static DiskCacheFile *seq_disk_cache_get_oldest_file(SeqDiskCache *disk_cache)
static void seq_disk_cache_delete_file(SeqDiskCache *disk_cache, DiskCacheFile *file)
{
disk_cache->size_total -= file->fstat.st_size;
BLI_delete(file->path, false, false);
BLI_delete(file->filepath, false, false);
BLI_remlink(&disk_cache->files, file);
MEM_freeN(file);
}
@ -235,7 +236,7 @@ bool seq_disk_cache_enforce_limits(SeqDiskCache *disk_cache)
continue;
}
if (BLI_exists(oldest_file->path) == 0) {
if (BLI_exists(oldest_file->filepath) == 0) {
/* File may have been manually deleted during runtime, do re-scan. */
BLI_freelistN(&disk_cache->files);
seq_disk_cache_get_files(disk_cache, seq_disk_cache_base_dir());
@ -249,12 +250,13 @@ bool seq_disk_cache_enforce_limits(SeqDiskCache *disk_cache)
return true;
}
static DiskCacheFile *seq_disk_cache_get_file_entry_by_path(SeqDiskCache *disk_cache, char *path)
static DiskCacheFile *seq_disk_cache_get_file_entry_by_path(SeqDiskCache *disk_cache,
char *filepath)
{
DiskCacheFile *cache_file = disk_cache->files.first;
for (; cache_file; cache_file = cache_file->next) {
if (BLI_strcasecmp(cache_file->path, path) == 0) {
if (BLI_strcasecmp(cache_file->filepath, filepath) == 0) {
return cache_file;
}
}
@ -263,16 +265,16 @@ static DiskCacheFile *seq_disk_cache_get_file_entry_by_path(SeqDiskCache *disk_c
}
/* Update file size and timestamp. */
static void seq_disk_cache_update_file(SeqDiskCache *disk_cache, char *path)
static void seq_disk_cache_update_file(SeqDiskCache *disk_cache, char *filepath)
{
DiskCacheFile *cache_file;
int64_t size_before;
int64_t size_after;
cache_file = seq_disk_cache_get_file_entry_by_path(disk_cache, path);
cache_file = seq_disk_cache_get_file_entry_by_path(disk_cache, filepath);
size_before = cache_file->fstat.st_size;
if (BLI_stat(path, &cache_file->fstat) == -1) {
if (BLI_stat(filepath, &cache_file->fstat) == -1) {
BLI_assert(false);
memset(&cache_file->fstat, 0, sizeof(BLI_stat_t));
}
@ -285,7 +287,9 @@ static void seq_disk_cache_update_file(SeqDiskCache *disk_cache, char *path)
* <cache dir>/<project name>_seq_cache/<scene name>-<timestamp>/<seq name>/DCACHE_FNAME_FORMAT
*/
static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *path, size_t path_len)
static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache,
char *dirpath,
size_t dirpath_maxncpy)
{
char cache_dir[FILE_MAX];
BLI_path_split_file_part(
@ -294,11 +298,11 @@ static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *path,
const char *suffix = "_seq_cache";
strncat(cache_dir, suffix, sizeof(cache_dir) - strlen(cache_dir) - 1);
BLI_path_join(path, path_len, seq_disk_cache_base_dir(), cache_dir);
BLI_path_join(dirpath, dirpath_maxncpy, seq_disk_cache_base_dir(), cache_dir);
}
static void seq_disk_cache_get_dir(
SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, char *path, size_t path_len)
SeqDiskCache *disk_cache, Scene *scene, Sequence *seq, char *dirpath, size_t dirpath_maxncpy)
{
char scene_name[MAX_ID_NAME + 22]; /* + -%PRId64 */
char seq_name[SEQ_NAME_MAXSTR];
@ -310,15 +314,15 @@ static void seq_disk_cache_get_dir(
BLI_path_make_safe_filename(scene_name);
BLI_path_make_safe_filename(seq_name);
BLI_path_join(path, path_len, project_dir, scene_name, seq_name);
BLI_path_join(dirpath, dirpath_maxncpy, project_dir, scene_name, seq_name);
}
static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache,
SeqCacheKey *key,
char *path,
size_t path_len)
char *filepath,
size_t filepath_maxncpy)
{
seq_disk_cache_get_dir(disk_cache, key->context.scene, key->seq, path, path_len);
seq_disk_cache_get_dir(disk_cache, key->context.scene, key->seq, filepath, filepath_maxncpy);
int frameno = (int)key->frame_index / DCACHE_IMAGES_PER_FILE;
char cache_filename[FILE_MAXFILE];
SNPRINTF(cache_filename,
@ -330,7 +334,7 @@ static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache,
key->context.view_id,
frameno);
BLI_path_append(path, path_len, cache_filename);
BLI_path_append(filepath, filepath_maxncpy, cache_filename);
}
static void seq_disk_cache_create_version_file(char *filepath)
@ -346,14 +350,14 @@ static void seq_disk_cache_create_version_file(char *filepath)
static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache)
{
char filepath[FILE_MAX];
char dirpath[FILE_MAX];
char path_version_file[FILE_MAX];
int version = 0;
seq_disk_cache_get_project_dir(disk_cache, filepath, sizeof(filepath));
BLI_path_join(path_version_file, sizeof(path_version_file), filepath, "cache_version");
seq_disk_cache_get_project_dir(disk_cache, dirpath, sizeof(dirpath));
BLI_path_join(path_version_file, sizeof(path_version_file), dirpath, "cache_version");
if (BLI_exists(filepath) && BLI_is_dir(filepath)) {
if (BLI_exists(dirpath) && BLI_is_dir(dirpath)) {
FILE *file = BLI_fopen(path_version_file, "r");
if (file) {
@ -365,7 +369,7 @@ static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache)
}
if (version != DCACHE_CURRENT_VERSION) {
BLI_delete(filepath, false, true);
BLI_delete(dirpath, false, true);
seq_disk_cache_create_version_file(path_version_file);
}
}

View File

@ -3243,12 +3243,12 @@ void SEQ_effect_text_font_load(TextVars *data, const bool do_id_user)
data->text_blf_id = BLF_load_mem(name, pf->data, pf->size);
}
else {
char path[FILE_MAX];
STRNCPY(path, vfont->filepath);
char filepath[FILE_MAX];
STRNCPY(filepath, vfont->filepath);
BLI_assert(BLI_thread_is_main());
BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
data->text_blf_id = BLF_load(path);
data->text_blf_id = BLF_load(filepath);
}
}

View File

@ -342,25 +342,24 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq,
}
if ((seq->type == SEQ_TYPE_IMAGE) && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
char filepath[FILE_MAX];
if (view_id == 0) {
/* Clear on first use. */
prefix_vars->prefix[0] = '\0';
prefix_vars->ext = NULL;
char path[FILE_MAX];
BLI_path_join(path, sizeof(path), seq->strip->dirpath, seq->strip->stripdata->filename);
BLI_path_abs(path, BKE_main_blendfile_path_from_global());
BKE_scene_multiview_view_prefix_get(scene, path, prefix_vars->prefix, &prefix_vars->ext);
char filepath[FILE_MAX];
BLI_path_join(
filepath, sizeof(filepath), seq->strip->dirpath, seq->strip->stripdata->filename);
BLI_path_abs(filepath, BKE_main_blendfile_path_from_global());
BKE_scene_multiview_view_prefix_get(scene, filepath, prefix_vars->prefix, &prefix_vars->ext);
}
if (prefix_vars->prefix[0] == '\0') {
return view_id != 0;
}
char filepath[FILE_MAX];
seq_multiview_name(scene, view_id, prefix_vars->prefix, prefix_vars->ext, filepath, FILE_MAX);
if (BLI_access(filepath, R_OK) == 0) {
return false;
}

View File

@ -515,7 +515,6 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const bool lock_range)
{
char path[FILE_MAX];
int prev_startdisp = 0, prev_enddisp = 0;
/* NOTE: don't rename the strip, will break animation curves. */
@ -551,13 +550,15 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
break;
}
case SEQ_TYPE_MOVIE: {
char filepath[FILE_MAX];
StripAnim *sanim;
bool is_multiview_loaded = false;
const bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
(scene->r.scemode & R_MULTIVIEW) != 0;
BLI_path_join(path, sizeof(path), seq->strip->dirpath, seq->strip->stripdata->filename);
BLI_path_abs(path, BKE_main_blendfile_path_from_global());
BLI_path_join(
filepath, sizeof(filepath), seq->strip->dirpath, seq->strip->stripdata->filename);
BLI_path_abs(filepath, BKE_main_blendfile_path_from_global());
SEQ_relations_sequence_free_anim(seq);
@ -567,15 +568,15 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
const int totfiles = seq_num_files(scene, seq->views_format, true);
int i = 0;
BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
BKE_scene_multiview_view_prefix_get(scene, filepath, prefix, &ext);
if (prefix[0] != '\0') {
for (i = 0; i < totfiles; i++) {
struct anim *anim;
char filepath[FILE_MAX];
char filepath_view[FILE_MAX];
seq_multiview_name(scene, i, prefix, ext, filepath, sizeof(filepath));
anim = openanim(filepath,
seq_multiview_name(scene, i, prefix, ext, filepath_view, sizeof(filepath_view));
anim = openanim(filepath_view,
IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
seq->streamindex,
seq->strip->colorspace_settings.name);
@ -593,7 +594,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
if (is_multiview_loaded == false) {
struct anim *anim;
anim = openanim(path,
anim = openanim(filepath,
IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
seq->streamindex,
seq->strip->colorspace_settings.name);

View File

@ -104,10 +104,9 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
RNA_string_set(op->ptr, "filepath", G.lib);
}
else if (blendfile_path[0] != '\0') {
char path[FILE_MAX];
STRNCPY(path, blendfile_path);
BLI_path_parent_dir(path);
RNA_string_set(op->ptr, "filepath", path);
char dirpath[FILE_MAX];
BLI_path_split_dir_part(blendfile_path, dirpath, sizeof(dirpath));
RNA_string_set(op->ptr, "filepath", dirpath);
}
}
@ -164,7 +163,7 @@ static int wm_link_append_flag(wmOperator *op)
* \param reports: Optionally report an error when an item can't be appended/linked.
*/
static bool wm_link_append_item_poll(ReportList *reports,
const char *path,
const char *filepath,
const char *group,
const char *name,
const bool do_append)
@ -172,7 +171,7 @@ static bool wm_link_append_item_poll(ReportList *reports,
short idcode;
if (!group || !name) {
CLOG_WARN(&LOG, "Skipping %s", path);
CLOG_WARN(&LOG, "Skipping %s", filepath);
return false;
}
@ -210,26 +209,27 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
PropertyRNA *prop;
BlendfileLinkAppendContext *lapp_context;
char path[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX_LIBEXTRA], relname[FILE_MAX];
char filepath[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX_LIBEXTRA],
relname[FILE_MAX];
char *group, *name;
int totfiles = 0;
RNA_string_get(op->ptr, "filename", relname);
RNA_string_get(op->ptr, "directory", root);
BLI_path_join(path, sizeof(path), root, relname);
BLI_path_join(filepath, sizeof(filepath), root, relname);
/* test if we have a valid data */
if (!BKE_blendfile_library_path_explode(path, libname, &group, &name)) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': not a library", path);
if (!BKE_blendfile_library_path_explode(filepath, libname, &group, &name)) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': not a library", filepath);
return OPERATOR_CANCELLED;
}
if (!group) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", filepath);
return OPERATOR_CANCELLED;
}
if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", path);
BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", filepath);
return OPERATOR_CANCELLED;
}
@ -239,13 +239,13 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
totfiles = RNA_property_collection_length(op->ptr, prop);
if (totfiles == 0) {
if (!name) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", filepath);
return OPERATOR_CANCELLED;
}
}
}
else if (!name) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", filepath);
return OPERATOR_CANCELLED;
}
@ -291,10 +291,10 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
RNA_BEGIN (op->ptr, itemptr, "files") {
RNA_string_get(&itemptr, "name", relname);
BLI_path_join(path, sizeof(path), root, relname);
BLI_path_join(filepath, sizeof(filepath), root, relname);
if (BKE_blendfile_library_path_explode(path, libname, &group, &name)) {
if (!wm_link_append_item_poll(NULL, path, group, name, do_append)) {
if (BKE_blendfile_library_path_explode(filepath, libname, &group, &name)) {
if (!wm_link_append_item_poll(NULL, filepath, group, name, do_append)) {
continue;
}
@ -310,12 +310,12 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
RNA_BEGIN (op->ptr, itemptr, "files") {
RNA_string_get(&itemptr, "name", relname);
BLI_path_join(path, sizeof(path), root, relname);
BLI_path_join(filepath, sizeof(filepath), root, relname);
if (BKE_blendfile_library_path_explode(path, libname, &group, &name)) {
if (BKE_blendfile_library_path_explode(filepath, libname, &group, &name)) {
BlendfileLinkAppendContextItem *item;
if (!wm_link_append_item_poll(op->reports, path, group, name, do_append)) {
if (!wm_link_append_item_poll(op->reports, filepath, group, name, do_append)) {
continue;
}
@ -674,7 +674,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
PropertyRNA *prop;
BlendfileLinkAppendContext *lapp_context;
char path[FILE_MAX], root[FILE_MAXDIR], libname[FILE_MAX], relname[FILE_MAX];
char filepath[FILE_MAX], root[FILE_MAXDIR], libname[FILE_MAX], relname[FILE_MAX];
short flag = 0;
if (RNA_boolean_get(op->ptr, "relative_path")) {
@ -697,23 +697,23 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
return OPERATOR_CANCELLED;
}
BLI_path_join(path, sizeof(path), root, libname);
BLI_path_join(filepath, sizeof(filepath), root, libname);
if (!BLI_exists(path)) {
if (!BLI_exists(filepath)) {
BKE_reportf(op->reports,
RPT_ERROR_INVALID_INPUT,
"Trying to reload or relocate library '%s' to invalid path '%s'",
lib->id.name,
path);
filepath);
return OPERATOR_CANCELLED;
}
if (BLI_path_cmp(BKE_main_blendfile_path(bmain), path) == 0) {
if (BLI_path_cmp(BKE_main_blendfile_path(bmain), filepath) == 0) {
BKE_reportf(op->reports,
RPT_ERROR_INVALID_INPUT,
"Cannot relocate library '%s' to current blend file '%s'",
lib->id.name,
path);
filepath);
return OPERATOR_CANCELLED;
}
@ -721,13 +721,13 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
BLO_library_link_params_init_with_context(
&lapp_params, bmain, flag, 0, CTX_data_scene(C), CTX_data_view_layer(C), NULL);
if (BLI_path_cmp(lib->filepath_abs, path) == 0) {
if (BLI_path_cmp(lib->filepath_abs, filepath) == 0) {
CLOG_INFO(&LOG, 4, "We are supposed to reload '%s' lib (%d)", lib->filepath, lib->id.us);
do_reload = true;
lapp_context = BKE_blendfile_link_append_context_new(&lapp_params);
BKE_blendfile_link_append_context_library_add(lapp_context, path, NULL);
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
}
else {
int totfiles = 0;
@ -753,21 +753,21 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
RNA_BEGIN (op->ptr, itemptr, "files") {
RNA_string_get(&itemptr, "name", relname);
BLI_path_join(path, sizeof(path), root, relname);
BLI_path_join(filepath, sizeof(filepath), root, relname);
if (BLI_path_cmp(path, lib->filepath_abs) == 0 || !BKE_blendfile_extension_check(relname))
{
if (BLI_path_cmp(filepath, lib->filepath_abs) == 0 ||
!BKE_blendfile_extension_check(relname)) {
continue;
}
CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", path);
BKE_blendfile_link_append_context_library_add(lapp_context, path, NULL);
CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", filepath);
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
}
RNA_END;
}
else {
CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", path);
BKE_blendfile_link_append_context_library_add(lapp_context, path, NULL);
CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", filepath);
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
}
}

View File

@ -1291,15 +1291,15 @@ ID *WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
/* check input variables */
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
char path[FILE_MAX];
char filepath[FILE_MAX];
bool exists = false;
RNA_string_get(op->ptr, "filepath", path);
RNA_string_get(op->ptr, "filepath", filepath);
errno = 0;
if (idcode == ID_IM) {
id = (ID *)BKE_image_load_exists_ex(bmain, path, &exists);
id = (ID *)BKE_image_load_exists_ex(bmain, filepath, &exists);
}
else {
BLI_assert_unreachable();
@ -1310,7 +1310,7 @@ ID *WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
RPT_ERROR,
"Cannot read %s '%s': %s",
BKE_idtype_idcode_to_name(idcode),
path,
filepath,
errno ? strerror(errno) : TIP_("unsupported format"));
return NULL;
}