Cleanup: use "filepath" term for Main, BlendFileData & FileGlobal
Use "filepath" which is the current convention for naming full paths. - Main use "name" which isn't obviously a file path. - BlendFileData & FileGlobal used "filename" which is often used for the name component of a path (without the directory).
This commit is contained in:
parent
27231afce5
commit
8ad2642c47
|
@ -50,12 +50,12 @@ typedef struct Global {
|
|||
/** Last used location for library link/append. */
|
||||
char lib[1024];
|
||||
|
||||
/** When set: `G_MAIN->name` contains valid relative base path. */
|
||||
/** When set: `G_MAIN->filepath` contains valid relative base path. */
|
||||
bool relbase_valid;
|
||||
/**
|
||||
* When set:
|
||||
* - Saving writes to `G_MAIN->name` without prompting for a file-path.
|
||||
* - The title-bar displays `G_MAIN->name`.
|
||||
* - Saving writes to `G_MAIN->filepath` without prompting for a file-path.
|
||||
* - The title-bar displays `G_MAIN->filepath`.
|
||||
*/
|
||||
bool save_over;
|
||||
|
||||
|
|
|
@ -116,12 +116,13 @@ enum {
|
|||
|
||||
typedef struct Main {
|
||||
struct Main *next, *prev;
|
||||
char name[1024]; /* 1024 = FILE_MAX */
|
||||
char filepath[1024]; /* 1024 = FILE_MAX */
|
||||
short versionfile, subversionfile; /* see BLENDER_FILE_VERSION, BLENDER_FILE_SUBVERSION */
|
||||
short minversionfile, minsubversionfile;
|
||||
uint64_t build_commit_timestamp; /* commit's timestamp from buildinfo */
|
||||
char build_hash[16]; /* hash from buildinfo */
|
||||
char recovered; /* indicate the main->name (file) is the recovered one */
|
||||
/** Indicate the #Main.filepath (file) is the recovered one. */
|
||||
char recovered;
|
||||
/** All current ID's exist in the last memfile undo step. */
|
||||
char is_memfile_undo_written;
|
||||
/**
|
||||
|
|
|
@ -71,7 +71,7 @@ bool BKE_asset_library_find_suitable_root_path_from_path(const char *input_path,
|
|||
|
||||
bool BKE_asset_library_find_suitable_root_path_from_main(const Main *bmain, char *r_library_path)
|
||||
{
|
||||
return BKE_asset_library_find_suitable_root_path_from_path(bmain->name, r_library_path);
|
||||
return BKE_asset_library_find_suitable_root_path_from_path(bmain->filepath, r_library_path);
|
||||
}
|
||||
|
||||
blender::bke::AssetCatalogService *BKE_asset_library_get_catalog_service(
|
||||
|
@ -168,7 +168,7 @@ void AssetLibrary::on_blend_save_post(struct Main *main,
|
|||
}
|
||||
|
||||
if (save_catalogs_when_file_is_saved) {
|
||||
this->catalog_service->write_to_disk(main->name);
|
||||
this->catalog_service->write_to_disk(main->filepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
|
|||
bContext *C)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
char mainstr[sizeof(bmain->name)];
|
||||
char mainstr[sizeof(bmain->filepath)];
|
||||
int success = 0, fileflags;
|
||||
|
||||
BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
|
||||
|
@ -101,7 +101,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
|
|||
|
||||
/* Restore, bmain has been re-allocated. */
|
||||
bmain = CTX_data_main(C);
|
||||
BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name));
|
||||
STRNCPY(bmain->filepath, mainstr);
|
||||
G.fileflags = fileflags;
|
||||
|
||||
if (success) {
|
||||
|
|
|
@ -360,12 +360,12 @@ static void setup_app_data(bContext *C,
|
|||
|
||||
/* startup.blend or recovered startup */
|
||||
if (is_startup) {
|
||||
bmain->name[0] = '\0';
|
||||
bmain->filepath[0] = '\0';
|
||||
}
|
||||
else if (recover) {
|
||||
/* In case of autosave or quit.blend, use original filename instead. */
|
||||
/* In case of autosave or quit.blend, use original filepath instead. */
|
||||
bmain->recovered = 1;
|
||||
BLI_strncpy(bmain->name, bfd->filename, FILE_MAX);
|
||||
STRNCPY(bmain->filepath, bfd->filepath);
|
||||
}
|
||||
|
||||
/* baseflags, groups, make depsgraph, etc */
|
||||
|
@ -858,8 +858,8 @@ bool BKE_blendfile_write_partial(Main *bmain_src,
|
|||
BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE);
|
||||
|
||||
/* This is needed to be able to load that file as a real one later
|
||||
* (otherwise main->name will not be set at read time). */
|
||||
BLI_strncpy(bmain_dst->name, bmain_src->name, sizeof(bmain_dst->name));
|
||||
* (otherwise `main->filepath` will not be set at read time). */
|
||||
STRNCPY(bmain_dst->filepath, bmain_src->filepath);
|
||||
|
||||
BLO_main_expander(blendfile_write_partial_cb);
|
||||
BLO_expand_main(NULL, bmain_src);
|
||||
|
|
|
@ -76,7 +76,7 @@ class BPathTest : public testing::Test {
|
|||
void SetUp() override
|
||||
{
|
||||
bmain = BKE_main_new();
|
||||
BLI_strncpy(bmain->name, BLENDFILE_PATH, sizeof(bmain->name));
|
||||
STRNCPY(bmain->filepath, BLENDFILE_PATH);
|
||||
|
||||
BKE_id_new(bmain, ID_TXT, nullptr);
|
||||
BKE_id_new(bmain, ID_MC, nullptr);
|
||||
|
|
|
@ -908,7 +908,7 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist
|
|||
char str[FILE_MAX], strtest[FILE_MAX];
|
||||
|
||||
STRNCPY(str, filepath);
|
||||
BLI_path_abs(str, bmain->name);
|
||||
BLI_path_abs(str, bmain->filepath);
|
||||
|
||||
/* first search an identical filepath */
|
||||
for (ima = bmain->images.first; ima; ima = ima->id.next) {
|
||||
|
|
|
@ -560,7 +560,7 @@ void BKE_main_thumbnail_create(struct Main *bmain)
|
|||
|
||||
const char *BKE_main_blendfile_path(const Main *bmain)
|
||||
{
|
||||
return bmain->name;
|
||||
return bmain->filepath;
|
||||
}
|
||||
|
||||
const char *BKE_main_blendfile_path_from_global(void)
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef struct BlendFileData {
|
|||
|
||||
int fileflags;
|
||||
int globalf;
|
||||
char filename[1024]; /* 1024 = FILE_MAX */
|
||||
char filepath[1024]; /* 1024 = FILE_MAX */
|
||||
|
||||
struct bScreen *curscreen; /* TODO: think this isn't needed anymore? */
|
||||
struct Scene *curscene;
|
||||
|
|
|
@ -631,7 +631,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
|
|||
// printf("blo_find_main: converted to %s\n", name1);
|
||||
|
||||
for (m = mainlist->first; m; m = m->next) {
|
||||
const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->name;
|
||||
const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->filepath;
|
||||
|
||||
if (BLI_path_cmp(name1, libname) == 0) {
|
||||
if (G.debug & G_DEBUG) {
|
||||
|
@ -2848,7 +2848,7 @@ static void lib_link_library(BlendLibReader *UNUSED(reader), Library *UNUSED(lib
|
|||
* in relation to the blend file. */
|
||||
static void fix_relpaths_library(const char *basepath, Main *main)
|
||||
{
|
||||
/* BLO_read_from_memory uses a blank filename */
|
||||
/* #BLO_read_from_memory uses a blank file-path. */
|
||||
if (basepath == NULL || basepath[0] == '\0') {
|
||||
LISTBASE_FOREACH (Library *, lib, &main->libraries) {
|
||||
/* when loading a linked lib into a file which has not been saved,
|
||||
|
@ -3502,25 +3502,25 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
|
|||
|
||||
bfd->fileflags = fg->fileflags;
|
||||
bfd->globalf = fg->globalf;
|
||||
BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename));
|
||||
STRNCPY(bfd->filepath, fg->filepath);
|
||||
|
||||
/* Error in 2.65 and older: main->name was not set if you save from startup
|
||||
/* Error in 2.65 and older: `main->filepath` was not set if you save from startup
|
||||
* (not after loading file). */
|
||||
if (bfd->filename[0] == 0) {
|
||||
if (bfd->filepath[0] == 0) {
|
||||
if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1)) {
|
||||
if ((G.fileflags & G_FILE_RECOVER_READ) == 0) {
|
||||
BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
|
||||
STRNCPY(bfd->filepath, BKE_main_blendfile_path(bfd->main));
|
||||
}
|
||||
}
|
||||
|
||||
/* early 2.50 version patch - filename not in FileGlobal struct at all */
|
||||
/* early 2.50 version patch - filepath not in FileGlobal struct at all */
|
||||
if (fd->fileversion <= 250) {
|
||||
BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
|
||||
STRNCPY(bfd->filepath, BKE_main_blendfile_path(bfd->main));
|
||||
}
|
||||
}
|
||||
|
||||
if (G.fileflags & G_FILE_RECOVER_READ) {
|
||||
BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase));
|
||||
BLI_strncpy(fd->relabase, fg->filepath, sizeof(fd->relabase));
|
||||
}
|
||||
|
||||
bfd->curscreen = fg->curscreen;
|
||||
|
@ -3616,7 +3616,7 @@ static void do_versions_after_linking(Main *main, ReportList *reports)
|
|||
CLOG_INFO(&LOG,
|
||||
2,
|
||||
"Processing %s (%s), %d.%d",
|
||||
main->curlib ? main->curlib->filepath : main->name,
|
||||
main->curlib ? main->curlib->filepath : main->filepath,
|
||||
main->curlib ? "LIB" : "MAIN",
|
||||
main->versionfile,
|
||||
main->subversionfile);
|
||||
|
@ -3854,7 +3854,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
|
|||
if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) {
|
||||
BLI_addtail(&mainlist, bfd->main);
|
||||
fd->mainlist = &mainlist;
|
||||
BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name));
|
||||
STRNCPY(bfd->main->filepath, filepath);
|
||||
}
|
||||
|
||||
if (G.background) {
|
||||
|
@ -4511,7 +4511,7 @@ static void split_main_newid(Main *mainptr, Main *main_newid)
|
|||
/* We only copy the necessary subset of data in this temp main. */
|
||||
main_newid->versionfile = mainptr->versionfile;
|
||||
main_newid->subversionfile = mainptr->subversionfile;
|
||||
BLI_strncpy(main_newid->name, mainptr->name, sizeof(main_newid->name));
|
||||
STRNCPY(main_newid->filepath, mainptr->filepath);
|
||||
main_newid->curlib = mainptr->curlib;
|
||||
|
||||
ListBase *lbarray[INDEX_ID_MAX];
|
||||
|
|
|
@ -39,7 +39,7 @@ TempLibraryContext *BLO_library_temp_load_id(struct Main *real_main,
|
|||
temp_lib_ctx->bf_reports.reports = reports;
|
||||
|
||||
/* Copy the file path so any path remapping is performed properly. */
|
||||
STRNCPY(temp_lib_ctx->bmain_base->name, real_main->name);
|
||||
STRNCPY(temp_lib_ctx->bmain_base->filepath, real_main->filepath);
|
||||
|
||||
temp_lib_ctx->blendhandle = BLO_blendhandle_from_file(blend_file_path,
|
||||
&temp_lib_ctx->bf_reports);
|
||||
|
|
|
@ -1028,7 +1028,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
|
|||
|
||||
/* prevent mem checkers from complaining */
|
||||
memset(fg._pad, 0, sizeof(fg._pad));
|
||||
memset(fg.filename, 0, sizeof(fg.filename));
|
||||
memset(fg.filepath, 0, sizeof(fg.filepath));
|
||||
memset(fg.build_hash, 0, sizeof(fg.build_hash));
|
||||
fg._pad1 = NULL;
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
|
|||
fg.globalf = G.f;
|
||||
/* Write information needed for recovery. */
|
||||
if (fileflags & G_FILE_RECOVER_WRITE) {
|
||||
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
|
||||
STRNCPY(fg.filepath, mainvar->filepath);
|
||||
}
|
||||
sprintf(subvstr, "%4d", BLENDER_FILE_SUBVERSION);
|
||||
memcpy(fg.subvstr, subvstr, 4);
|
||||
|
@ -1362,12 +1362,12 @@ bool BLO_write_file(Main *mainvar,
|
|||
|
||||
char dir_src[FILE_MAX];
|
||||
char dir_dst[FILE_MAX];
|
||||
BLI_split_dir_part(mainvar->name, dir_src, sizeof(dir_src));
|
||||
BLI_split_dir_part(mainvar->filepath, dir_src, sizeof(dir_src));
|
||||
BLI_split_dir_part(filepath, dir_dst, sizeof(dir_dst));
|
||||
|
||||
/* Just in case there is some subtle difference. */
|
||||
BLI_path_normalize(mainvar->name, dir_dst);
|
||||
BLI_path_normalize(mainvar->name, dir_src);
|
||||
BLI_path_normalize(mainvar->filepath, dir_dst);
|
||||
BLI_path_normalize(mainvar->filepath, dir_src);
|
||||
|
||||
/* Only for relative, not relative-all, as this means making existing paths relative. */
|
||||
if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) {
|
||||
|
|
|
@ -787,7 +787,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op)
|
|||
* any datablock expansion?
|
||||
*/
|
||||
Main *temp_bmain = BKE_main_new();
|
||||
STRNCPY(temp_bmain->name, BKE_main_blendfile_path_from_global());
|
||||
STRNCPY(temp_bmain->filepath, BKE_main_blendfile_path_from_global());
|
||||
|
||||
Object ob_copy = *ob;
|
||||
ob_copy.adt = NULL;
|
||||
|
@ -856,7 +856,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
|
|||
/* Read copy buffer .blend file. */
|
||||
char str[FILE_MAX];
|
||||
Main *tmp_bmain = BKE_main_new();
|
||||
STRNCPY(tmp_bmain->name, BKE_main_blendfile_path_from_global());
|
||||
STRNCPY(tmp_bmain->filepath, BKE_main_blendfile_path_from_global());
|
||||
|
||||
BLI_join_dirfile(str, sizeof(str), BKE_tempdir_base(), "copybuffer_pose.blend");
|
||||
if (!BKE_copybuffer_read(tmp_bmain, str, op->reports, FILTER_ID_OB)) {
|
||||
|
|
|
@ -173,7 +173,7 @@ void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *
|
|||
/* Since writing to disk also means loading any on-disk changes, it may be a good idea to store
|
||||
* an undo step. */
|
||||
catalog_service->undo_push();
|
||||
catalog_service->write_to_disk(bmain->name);
|
||||
catalog_service->write_to_disk(bmain->filepath);
|
||||
}
|
||||
|
||||
void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(const bool should_save)
|
||||
|
|
|
@ -637,7 +637,7 @@ static bool asset_catalogs_save_poll(bContext *C)
|
|||
}
|
||||
|
||||
const Main *bmain = CTX_data_main(C);
|
||||
if (!bmain->name[0]) {
|
||||
if (!bmain->filepath[0]) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Cannot save asset catalogs before the Blender file is saved");
|
||||
return false;
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ static bool asset_bundle_install_poll(bContext *C)
|
|||
|
||||
/* Check whether this file is already located inside any asset library. */
|
||||
const struct bUserAssetLibrary *asset_lib = BKE_preferences_asset_library_containing_path(
|
||||
&U, bmain->name);
|
||||
&U, bmain->filepath);
|
||||
if (asset_lib) {
|
||||
return false;
|
||||
}
|
||||
|
@ -779,7 +779,7 @@ static int asset_bundle_install_exec(bContext *C, wmOperator *op)
|
|||
BKE_reportf(op->reports,
|
||||
RPT_INFO,
|
||||
R"(Saved "%s" to asset library "%s")",
|
||||
BLI_path_basename(bmain->name),
|
||||
BLI_path_basename(bmain->filepath),
|
||||
lib->name);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ static void ASSET_OT_bundle_install(struct wmOperatorType *ot)
|
|||
* referenced. */
|
||||
static bool could_be_asset_bundle(const Main *bmain)
|
||||
{
|
||||
return fnmatch("*_bundle.blend", bmain->name, FNM_CASEFOLD) == 0;
|
||||
return fnmatch("*_bundle.blend", bmain->filepath, FNM_CASEFOLD) == 0;
|
||||
}
|
||||
|
||||
static const bUserAssetLibrary *selected_asset_library(struct wmOperator *op)
|
||||
|
@ -864,7 +864,7 @@ static bool set_filepath_for_asset_lib(const Main *bmain, struct wmOperator *op)
|
|||
}
|
||||
|
||||
/* Concatenate the filename of the current blend file. */
|
||||
const char *blend_filename = BLI_path_basename(bmain->name);
|
||||
const char *blend_filename = BLI_path_basename(bmain->filepath);
|
||||
if (blend_filename == nullptr || blend_filename[0] == '\0') {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -461,7 +461,7 @@ static Scene *preview_prepare_scene(
|
|||
Scene *sce;
|
||||
Main *pr_main = sp->pr_main;
|
||||
|
||||
memcpy(pr_main->name, BKE_main_blendfile_path(bmain), sizeof(pr_main->name));
|
||||
memcpy(pr_main->filepath, BKE_main_blendfile_path(bmain), sizeof(pr_main->filepath));
|
||||
|
||||
sce = preview_get_scene(pr_main);
|
||||
if (sce) {
|
||||
|
|
|
@ -373,7 +373,7 @@ static void workspace_append_button(uiLayout *layout,
|
|||
const Main *from_main)
|
||||
{
|
||||
const ID *id = (ID *)workspace;
|
||||
const char *filepath = from_main->name;
|
||||
const char *filepath = from_main->filepath;
|
||||
|
||||
if (strlen(filepath) == 0) {
|
||||
filepath = BLO_EMBEDDED_STARTUP_BLEND;
|
||||
|
|
|
@ -209,7 +209,7 @@ static int open_exec(bContext *C, wmOperator *op)
|
|||
|
||||
RNA_string_get(op->ptr, "directory", dir_only);
|
||||
if (relative) {
|
||||
BLI_path_rel(dir_only, bmain->name);
|
||||
BLI_path_rel(dir_only, bmain->filepath);
|
||||
}
|
||||
|
||||
prop = RNA_struct_find_property(op->ptr, "files");
|
||||
|
@ -285,7 +285,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
|
|||
if (clip) {
|
||||
BLI_strncpy(path, clip->filepath, sizeof(path));
|
||||
|
||||
BLI_path_abs(path, CTX_data_main(C)->name);
|
||||
BLI_path_abs(path, CTX_data_main(C)->filepath);
|
||||
BLI_path_parent_dir(path);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -71,7 +71,7 @@ class PythonInterpreter : public Interpreter {
|
|||
bool ok = BPY_run_filepath(_context, fn, reports);
|
||||
#else
|
||||
bool ok;
|
||||
Text *text = BKE_text_load(&_freestyle_bmain, fn, G_MAIN->name);
|
||||
Text *text = BKE_text_load(&_freestyle_bmain, fn, G_MAIN->filepath);
|
||||
if (text) {
|
||||
ok = BPY_run_text(_context, text, reports, false);
|
||||
BKE_id_delete(&_freestyle_bmain, text);
|
||||
|
|
|
@ -51,7 +51,7 @@ static MetaData create_abc_metadata(const Main *bmain, double scene_fps)
|
|||
{
|
||||
MetaData abc_metadata;
|
||||
|
||||
std::string abc_user_description(bmain->name);
|
||||
std::string abc_user_description(bmain->filepath);
|
||||
if (abc_user_description.empty()) {
|
||||
abc_user_description = "unknown";
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef struct FileGlobal {
|
|||
/** Hash from buildinfo. */
|
||||
char build_hash[16];
|
||||
/** File path where this was saved, for recover (1024 = FILE_MAX). */
|
||||
char filename[1024];
|
||||
char filepath[1024];
|
||||
} FileGlobal;
|
||||
|
||||
/* minversion: in file, the oldest past blender version you can use compliant */
|
||||
|
|
|
@ -82,6 +82,7 @@ DNA_STRUCT_RENAME_ELEM(Editing, over_border, overlay_frame_rect)
|
|||
DNA_STRUCT_RENAME_ELEM(Editing, over_cfra, overlay_frame_abs)
|
||||
DNA_STRUCT_RENAME_ELEM(Editing, over_flag, overlay_frame_flag)
|
||||
DNA_STRUCT_RENAME_ELEM(Editing, over_ofs, overlay_frame_ofs)
|
||||
DNA_STRUCT_RENAME_ELEM(FileGlobal, filename, filepath)
|
||||
DNA_STRUCT_RENAME_ELEM(FluidDomainSettings, cache_frame_pause_guiding, cache_frame_pause_guide)
|
||||
DNA_STRUCT_RENAME_ELEM(FluidDomainSettings, guiding_alpha, guide_alpha)
|
||||
DNA_STRUCT_RENAME_ELEM(FluidDomainSettings, guiding_beta, guide_beta)
|
||||
|
|
|
@ -76,20 +76,20 @@ static bool rna_Main_is_dirty_get(PointerRNA *ptr)
|
|||
static void rna_Main_filepath_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
Main *bmain = (Main *)ptr->data;
|
||||
BLI_strncpy(value, bmain->name, sizeof(bmain->name));
|
||||
BLI_strncpy(value, bmain->filepath, sizeof(bmain->filepath));
|
||||
}
|
||||
|
||||
static int rna_Main_filepath_length(PointerRNA *ptr)
|
||||
{
|
||||
Main *bmain = (Main *)ptr->data;
|
||||
return strlen(bmain->name);
|
||||
return strlen(bmain->filepath);
|
||||
}
|
||||
|
||||
# if 0
|
||||
static void rna_Main_filepath_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
Main *bmain = (Main *)ptr->data;
|
||||
BLI_strncpy(bmain->name, value, sizeof(bmain->name));
|
||||
STRNCPY(bmain->filepath, value);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ static PyObject *bpy_rna_data_temp_data(PyObject *UNUSED(self), PyObject *args,
|
|||
|
||||
ret = PyObject_GC_New(BPy_DataContext, &bpy_rna_data_context_Type);
|
||||
|
||||
STRNCPY(ret->filepath, filepath ? filepath : G_MAIN->name);
|
||||
STRNCPY(ret->filepath, filepath ? filepath : G_MAIN->filepath);
|
||||
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ bool seq_disk_cache_is_enabled(Main *bmain)
|
|||
{
|
||||
return (U.sequencer_disk_cache_dir[0] != '\0' && U.sequencer_disk_cache_size_limit != 0 &&
|
||||
(U.sequencer_disk_cache_flag & SEQ_CACHE_DISK_CACHE_ENABLE) != 0 &&
|
||||
bmain->name[0] != '\0');
|
||||
bmain->filepath[0] != '\0');
|
||||
}
|
||||
|
||||
static DiskCacheFile *seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, const char *path)
|
||||
|
|
|
@ -1356,7 +1356,7 @@ void wm_homefile_read_ex(bContext *C,
|
|||
if (use_data) {
|
||||
WM_check(C); /* opens window(s), checks keymaps */
|
||||
|
||||
bmain->name[0] = '\0';
|
||||
bmain->filepath[0] = '\0';
|
||||
|
||||
/* start with save preference untitled.blend */
|
||||
G.save_over = 0;
|
||||
|
@ -1828,7 +1828,7 @@ static bool wm_file_write(bContext *C,
|
|||
/* First time saving. */
|
||||
/* XXX(ton): temp solution to solve bug, real fix coming. */
|
||||
if ((BKE_main_blendfile_path(bmain)[0] == '\0') && (use_save_as_copy == false)) {
|
||||
BLI_strncpy(bmain->name, filepath, sizeof(bmain->name));
|
||||
STRNCPY(bmain->filepath, filepath);
|
||||
}
|
||||
|
||||
/* XXX(ton): temp solution to solve bug, real fix coming. */
|
||||
|
@ -1849,7 +1849,7 @@ static bool wm_file_write(bContext *C,
|
|||
|
||||
if (use_save_as_copy == false) {
|
||||
G.relbase_valid = 1;
|
||||
BLI_strncpy(bmain->name, filepath, sizeof(bmain->name)); /* is guaranteed current file */
|
||||
STRNCPY(bmain->filepath, filepath); /* is guaranteed current file */
|
||||
|
||||
G.save_over = 1; /* disable untitled.blend convention */
|
||||
}
|
||||
|
@ -3035,21 +3035,21 @@ static void save_set_filepath(bContext *C, wmOperator *op)
|
|||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
PropertyRNA *prop;
|
||||
char name[FILE_MAX];
|
||||
char filepath[FILE_MAX];
|
||||
|
||||
prop = RNA_struct_find_property(op->ptr, "filepath");
|
||||
if (!RNA_property_is_set(op->ptr, prop)) {
|
||||
/* if not saved before, get the name of the most recently used .blend file */
|
||||
if (BKE_main_blendfile_path(bmain)[0] == '\0' && G.recent_files.first) {
|
||||
struct RecentFile *recent = G.recent_files.first;
|
||||
BLI_strncpy(name, recent->filepath, FILE_MAX);
|
||||
STRNCPY(filepath, recent->filepath);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(name, bmain->name, FILE_MAX);
|
||||
STRNCPY(filepath, bmain->filepath);
|
||||
}
|
||||
|
||||
wm_filepath_default(name);
|
||||
RNA_property_string_set(op->ptr, prop, name);
|
||||
wm_filepath_default(filepath);
|
||||
RNA_property_string_set(op->ptr, prop, filepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -314,9 +314,9 @@ void WM_init(bContext *C, int argc, const char **argv)
|
|||
NULL,
|
||||
¶ms_file_read_post);
|
||||
|
||||
/* NOTE: leave `G_MAIN->name` set to an empty string since this
|
||||
/* NOTE: leave `G_MAIN->filepath` set to an empty string since this
|
||||
* matches behavior after loading a new file. */
|
||||
BLI_assert(G_MAIN->name[0] == '\0');
|
||||
BLI_assert(G_MAIN->filepath[0] == '\0');
|
||||
|
||||
/* Call again to set from preferences. */
|
||||
BLT_lang_set(NULL);
|
||||
|
|
|
@ -429,7 +429,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
|
|||
else if (win->ghostwin) {
|
||||
/* this is set to 1 if you don't have startup.blend open */
|
||||
if (G.save_over && BKE_main_blendfile_path_from_global()[0]) {
|
||||
char str[sizeof(((Main *)NULL)->name) + 24];
|
||||
char str[sizeof(((Main *)NULL)->filepath) + 24];
|
||||
BLI_snprintf(str,
|
||||
sizeof(str),
|
||||
"Blender%s [%s%s]",
|
||||
|
|
|
@ -1994,7 +1994,7 @@ static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
|
|||
if (BLO_has_bfile_extension(filename)) {
|
||||
/* Just pretend a file was loaded, so the user can press Save and it'll
|
||||
* save at the filename from the CLI. */
|
||||
BLI_strncpy(G_MAIN->name, filename, FILE_MAX);
|
||||
STRNCPY(G_MAIN->filepath, filename);
|
||||
G.relbase_valid = true;
|
||||
G.save_over = true;
|
||||
printf("... opened default scene instead; saving will write to: %s\n", filename);
|
||||
|
|
|
@ -117,11 +117,11 @@ static void sig_handle_crash(int signum)
|
|||
if (memfile) {
|
||||
char fname[FILE_MAX];
|
||||
|
||||
if (!(G_MAIN && G_MAIN->name[0])) {
|
||||
if (!(G_MAIN && G_MAIN->filepath[0])) {
|
||||
BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), "crash.blend");
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(fname, G_MAIN->name, sizeof(fname));
|
||||
STRNCPY(fname, G_MAIN->filepath);
|
||||
BLI_path_extension_replace(fname, sizeof(fname), ".crash.blend");
|
||||
}
|
||||
|
||||
|
@ -138,11 +138,12 @@ static void sig_handle_crash(int signum)
|
|||
|
||||
char fname[FILE_MAX];
|
||||
|
||||
if (!(G_MAIN && G_MAIN->name[0])) {
|
||||
if (!(G_MAIN && G_MAIN->filepath[0])) {
|
||||
BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), "blender.crash.txt");
|
||||
}
|
||||
else {
|
||||
BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), BLI_path_basename(G_MAIN->name));
|
||||
BLI_join_dirfile(
|
||||
fname, sizeof(fname), BKE_tempdir_base(), BLI_path_basename(G_MAIN->filepath));
|
||||
BLI_path_extension_replace(fname, sizeof(fname), ".crash.txt");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue