Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/bpath.c
| Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_bpath.h" /* own include */ | #include "BKE_bpath.h" /* own include */ | ||||
| #include "CLG_log.h" | |||||
| #ifndef _MSC_VER | #ifndef _MSC_VER | ||||
| # include "BLI_strict_flags.h" | # include "BLI_strict_flags.h" | ||||
| #endif | #endif | ||||
| static CLG_LogRef LOG = {"bke.bpath"}; | |||||
| static bool checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src) | static bool checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src) | ||||
| { | { | ||||
| ReportList *reports = (ReportList *)userdata; | ReportList *reports = (ReportList *)userdata; | ||||
| if (!BLI_exists(path_src)) { | if (!BLI_exists(path_src)) { | ||||
| BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src); | BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src); | ||||
| } | } | ||||
| Show All 40 Lines | |||||
| } | } | ||||
| void BKE_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *reports) | void BKE_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *reports) | ||||
| { | { | ||||
| BPathRemap_Data data = {NULL}; | BPathRemap_Data data = {NULL}; | ||||
| const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY; | const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY; | ||||
| if (basedir[0] == '\0') { | if (basedir[0] == '\0') { | ||||
| printf("%s: basedir='', this is a bug\n", __func__); | CLOG_ERROR(&LOG, "basedir='', this is a bug"); | ||||
| return; | return; | ||||
| } | } | ||||
| data.basedir = basedir; | data.basedir = basedir; | ||||
| data.reports = reports; | data.reports = reports; | ||||
| BKE_bpath_traverse_main(bmain, bpath_relative_convert_visit_cb, flag, (void *)&data); | BKE_bpath_traverse_main(bmain, bpath_relative_convert_visit_cb, flag, (void *)&data); | ||||
| Show All 27 Lines | |||||
| /* similar to BKE_bpath_relative_convert - keep in sync! */ | /* similar to BKE_bpath_relative_convert - keep in sync! */ | ||||
| void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports) | void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports) | ||||
| { | { | ||||
| BPathRemap_Data data = {NULL}; | BPathRemap_Data data = {NULL}; | ||||
| const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY; | const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY; | ||||
| if (basedir[0] == '\0') { | if (basedir[0] == '\0') { | ||||
| printf("%s: basedir='', this is a bug\n", __func__); | CLOG_ERROR(&LOG, "basedir='', this is a bug"); | ||||
| return; | return; | ||||
| } | } | ||||
| data.basedir = basedir; | data.basedir = basedir; | ||||
| data.reports = reports; | data.reports = reports; | ||||
| BKE_bpath_traverse_main(bmain, bpath_absolute_convert_visit_cb, flag, (void *)&data); | BKE_bpath_traverse_main(bmain, bpath_absolute_convert_visit_cb, flag, (void *)&data); | ||||
| ▲ Show 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | |||||
| bool BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src) | bool BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src) | ||||
| { | { | ||||
| /* be sure there is low chance of the path being too short */ | /* be sure there is low chance of the path being too short */ | ||||
| char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE]; | char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE]; | ||||
| const char *base_new = ((char **)pathbase_v)[0]; | const char *base_new = ((char **)pathbase_v)[0]; | ||||
| const char *base_old = ((char **)pathbase_v)[1]; | const char *base_old = ((char **)pathbase_v)[1]; | ||||
| if (BLI_path_is_rel(base_old)) { | if (BLI_path_is_rel(base_old)) { | ||||
| printf("%s: error, old base path '%s' is not absolute.\n", | CLOG_ERROR(&LOG, "old base path '%s' is not absolute.", base_old); | ||||
| __func__, base_old); | |||||
| return false; | return false; | ||||
| } | } | ||||
| /* Make referenced file absolute. This would be a side-effect of | /* Make referenced file absolute. This would be a side-effect of | ||||
| * BLI_cleanup_file, but we do it explicitly so we know if it changed. */ | * BLI_cleanup_file, but we do it explicitly so we know if it changed. */ | ||||
| BLI_strncpy(filepath, path_src, FILE_MAX); | BLI_strncpy(filepath, path_src, FILE_MAX); | ||||
| if (BLI_path_abs(filepath, base_old)) { | if (BLI_path_abs(filepath, base_old)) { | ||||
| /* Path was relative and is now absolute. Remap. | /* Path was relative and is now absolute. Remap. | ||||
| ▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines | |||||