Use native path separators for run-time generated paths

This commit is contained in:
Campbell Barton 2023-04-29 11:39:25 +10:00
parent 1c026befca
commit cfe25e6efb
6 changed files with 23 additions and 11 deletions

@ -521,15 +521,26 @@ static void get_proxy_filepath(const MovieClip *clip,
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
}
else {
BLI_snprintf(dir, FILE_MAX, "%s/BL_proxy", clipdir);
BLI_snprintf(dir, sizeof(dir), "%s" SEP_STR "BL_proxy", clipdir);
}
if (undistorted) {
BLI_snprintf(
filepath, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, proxynr);
BLI_snprintf(filepath,
FILE_MAX,
"%s" SEP_STR "%s" SEP_STR "proxy_%d_undistorted" SEP_STR "%08d",
dir,
clipfile,
size,
proxynr);
}
else {
BLI_snprintf(filepath, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr);
BLI_snprintf(filepath,
FILE_MAX,
"%s" SEP_STR "%s" SEP_STR "proxy_%d" SEP_STR "%08d",
dir,
clipfile,
size,
proxynr);
}
BLI_path_abs(filepath, BKE_main_blendfile_path_from_global());

@ -640,7 +640,7 @@ static bool seq_sound_proxy_update_cb(Sequence *seq, void *user_data)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
/* don't know, if anybody used that this way, but just in case, upgrade to new way... */
if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) {
BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir);
BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s" SEP_STR "BL_proxy", seq->strip->dir);
}
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE

@ -3111,7 +3111,7 @@ static void filelist_readjob_list_lib_add_datablock(FileListReadJob *job_params,
{
FileListInternEntry *entry = MEM_cnew<FileListInternEntry>(__func__);
if (prefix_relpath_with_group_name) {
std::string datablock_path = StringRef(group_name) + "/" + datablock_info->name;
std::string datablock_path = StringRef(group_name) + SEP_STR + datablock_info->name;
entry->relpath = current_relpath_append(job_params, datablock_path.c_str());
}
else {
@ -3791,7 +3791,7 @@ static void filelist_readjob_main_assets_add_items(FileListReadJob *job_params,
const char *id_code_name = BKE_idtype_idcode_to_name(GS(id_iter->name));
entry = MEM_cnew<FileListInternEntry>(__func__);
std::string datablock_path = StringRef(id_code_name) + "/" + (id_iter->name + 2);
std::string datablock_path = StringRef(id_code_name) + SEP_STR + (id_iter->name + 2);
entry->relpath = current_relpath_append(job_params, datablock_path.c_str());
entry->name = id_iter->name + 2;
entry->free_name = false;

@ -27,7 +27,7 @@ void ensure_usd_plugin_path_registered()
if (blender_usd_datafiles) {
const std::string blender_usd_data_folder = blender_usd_datafiles;
/* The trailing slash indicates to the USD library that the path is a directory. */
pxr::PlugRegistry::GetInstance().RegisterPlugins(blender_usd_data_folder + "/");
pxr::PlugRegistry::GetInstance().RegisterPlugins(blender_usd_data_folder + SEP_STR);
}
#endif
}

@ -18,7 +18,7 @@ class obj_mtl_parser_test : public testing::Test {
BKE_tempdir_init(nullptr);
std::string tmp_dir = BKE_tempdir_base();
std::string tmp_file_name = "mtl_test.mtl";
std::string tmp_file_path = tmp_dir + "/" + tmp_file_name;
std::string tmp_file_path = tmp_dir + SEP_STR + tmp_file_name;
FILE *tmp_file = BLI_fopen(tmp_file_path.c_str(), "wb");
fputs(text, tmp_file);
fclose(tmp_file);
@ -29,7 +29,8 @@ class obj_mtl_parser_test : public testing::Test {
}
void check(const char *file, const MTLMaterial *expect, size_t expect_count)
{
std::string obj_dir = blender::tests::flags_test_asset_dir() + "/io_tests/obj/";
std::string obj_dir = blender::tests::flags_test_asset_dir() +
(SEP_STR "io_tests" SEP_STR "obj" SEP_STR);
check_impl(file, obj_dir, expect, expect_count);
}
void check_impl(StringRefNull mtl_file_path,

@ -168,7 +168,7 @@ static bool seq_proxy_get_fname(Scene *scene,
BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
}
else { /* Per strip default. */
BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir);
BLI_snprintf(dir, PROXY_MAXFILE, "%s" SEP_STR "BL_proxy", seq->strip->dir);
}
}