Blender V5.3
bpath.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9/* TODO:
10 * currently there are some cases we don't support.
11 * - passing output paths to the visitor?, like render out.
12 * - passing sequence strips with many images.
13 * - passing directory paths - visitors don't know which path is a dir or a file.
14 */
15
16#include <sys/stat.h>
17
18#include <cstring>
19
20/* path/file handling stuff */
21#ifndef WIN32
22# include <dirent.h>
23# include <unistd.h>
24#else
25# include "BLI_winstuff.hh"
26# include <io.h>
27#endif
28
29#include "MEM_guardedalloc.h"
30
31#include "BLI_fileops.hh"
32#include "BLI_listbase.hh"
33#include "BLI_path_utils.hh"
34#include "BLI_string.hh"
35#include "BLI_utildefines.hh"
36
37#include "DEG_depsgraph.hh"
38
39#include "BKE_idtype.hh"
40#include "BKE_library.hh"
41#include "BKE_main.hh"
42#include "BKE_node.hh"
43#include "BKE_report.hh"
44
45#include "BKE_bpath.hh" /* own include */
46
47#include "CLG_log.h"
48
49namespace blender {
50
51#ifndef _MSC_VER
52# include "BLI_strict_flags.hh" /* IWYU pragma: keep. Keep last. */
53#endif
54
55static CLG_LogRef LOG = {"lib.bpath"};
56
57/* -------------------------------------------------------------------- */
60
61void BKE_bpath_summary_report(const BPathSummary &summary, ReportList *reports)
62{
63 BKE_reportf(reports,
65 "Total files %d | Changed %d | Failed %d",
66 summary.count_total,
67 summary.count_changed,
68 summary.count_failed);
69}
70
72
73/* -------------------------------------------------------------------- */
76
78{
79 const eBPathForeachFlag flag = bpath_data->flag;
80 const char *absbase = (flag & BKE_BPATH_FOREACH_PATH_ABSOLUTE) ?
81 ID_BLEND_PATH(bpath_data->bmain, id) :
82 nullptr;
83 bpath_data->absolute_base_path = absbase;
84 bpath_data->owner_id = id;
85 bpath_data->is_path_modified = false;
86 bpath_data->is_expanded = false;
87 bpath_data->is_cache = false;
88 bpath_data->is_readonly = false;
89
91 return;
92 }
93
94 if (id->library_weak_reference != nullptr &&
96 {
98 id->library_weak_reference->library_filepath,
99 sizeof(id->library_weak_reference->library_filepath));
100 }
101
102 bNodeTree *embedded_node_tree = bke::node_tree_from_id(id);
103 if (embedded_node_tree != nullptr) {
104 BKE_bpath_foreach_path_id(bpath_data, &embedded_node_tree->id);
105 }
106
107 const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
108
109 BLI_assert(id_type != nullptr);
110 if (id_type == nullptr || id_type->foreach_path == nullptr) {
111 return;
112 }
113
114 id_type->foreach_path(id, bpath_data);
115
116 if (bpath_data->is_path_modified) {
118 }
119}
120
122{
123 ID *id;
124 FOREACH_MAIN_ID_BEGIN (bpath_data->bmain, id) {
125 BKE_bpath_foreach_path_id(bpath_data, id);
126 }
128}
129
131 char *path,
132 size_t path_maxncpy)
133{
134 const char *absolute_base_path = bpath_data->absolute_base_path;
135
136 char path_src_buf[FILE_MAX];
137 const char *path_src;
138 char path_dst[FILE_MAX];
139
140 if (absolute_base_path) {
141 STRNCPY(path_src_buf, path);
142 BLI_path_abs(path_src_buf, absolute_base_path);
143 path_src = path_src_buf;
144 }
145 else {
146 path_src = path;
147 }
148
149 /* so functions can check old value */
150 STRNCPY(path_dst, path);
151
152 if (bpath_data->callback_function(bpath_data, path_dst, sizeof(path_dst), path_src)) {
153 BLI_strncpy(path, path_dst, path_maxncpy);
154 bpath_data->is_path_modified = true;
155 return true;
156 }
157
158 return false;
159}
160
162{
163 char path_src[FILE_MAX];
164 char path_dst[FILE_MAX];
165
166 STRNCPY(path_src, path);
167 if (bpath_data->absolute_base_path) {
168 BLI_path_abs(path_src, bpath_data->absolute_base_path);
169 }
170 /* Any modification to path_dst will be discarded. */
171 STRNCPY(path_dst, path_src);
172
173 bpath_data->is_readonly = true;
174 const bool changed = bpath_data->callback_function(
175 bpath_data, path_dst, sizeof(path_dst), path_src);
176 bpath_data->is_readonly = false;
177
178 BLI_assert_msg(!changed, "Read-only path edited in bpath foreach");
179 UNUSED_VARS_NDEBUG(changed);
180}
181
182void BKE_bpath_sequence_filepaths_foreach(const char *abs_filepath,
183 FunctionRef<void(StringRef frame_filepath)> callback)
184{
186 BLI_path_split_dir_file(abs_filepath, dirname, sizeof(dirname), filename, sizeof(filename));
187
188 char head[FILE_MAX], tail[FILE_MAX];
189 ushort digits_len = 0;
190 BLI_path_sequence_decode(filename, head, sizeof(head), tail, sizeof(tail), &digits_len);
191
192 if (digits_len == 0) {
193 /* Not a numbered sequence, treat as a single file. */
194 if (BLI_is_file(abs_filepath)) {
195 callback(abs_filepath);
196 }
197 return;
198 }
199
200 const size_t head_len = strlen(head);
201 const size_t tail_len = strlen(tail);
202 const size_t expected_len = head_len + size_t(digits_len) + tail_len;
203
204 direntry *filelist = nullptr;
205 const uint filelist_num = BLI_filelist_dir_contents(dirname, &filelist);
206 for (uint i = 0; i < filelist_num; i++) {
207 const direntry &entry = filelist[i];
208 if (!(entry.type & S_IFREG)) {
209 continue;
210 }
211 const char *name = entry.relname;
212 const size_t name_len = strlen(name);
213
214 /* Match files of the form <head><digits><tail>. */
215 if (name_len != expected_len) {
216 continue;
217 }
218 if (!STRPREFIX(name, head) || !BLI_str_endswith(name, tail)) {
219 continue;
220 }
221 bool all_digits = true;
222 for (size_t c = head_len; c < head_len + digits_len; c++) {
223 if (!(name[c] >= '0' && name[c] <= '9')) {
224 all_digits = false;
225 break;
226 }
227 }
228 if (all_digits) {
229 callback(entry.path);
230 }
231 }
232 BLI_filelist_free(filelist, filelist_num);
233}
234
236 char *path_dir,
237 size_t path_dir_maxncpy,
238 char *path_file,
239 size_t path_file_maxncpy)
240{
241 const char *absolute_base_path = bpath_data->absolute_base_path;
242
243 char path_src[FILE_MAX];
244 char path_dst[FILE_MAX];
245
246 BLI_path_join(path_src, sizeof(path_src), path_dir, path_file);
247
248 /* So that functions can access the old value. */
249 STRNCPY(path_dst, path_src);
250
251 if (absolute_base_path) {
252 BLI_path_abs(path_src, absolute_base_path);
253 }
254
255 if (bpath_data->callback_function(
256 bpath_data, path_dst, sizeof(path_dst), const_cast<const char *>(path_src)))
257 {
258 BLI_path_split_dir_file(path_dst, path_dir, path_dir_maxncpy, path_file, path_file_maxncpy);
259 bpath_data->is_path_modified = true;
260 return true;
261 }
262
263 return false;
264}
265
267{
268 const char *absolute_base_path = bpath_data->absolute_base_path;
269
270 char path_src_buf[FILE_MAX];
271 const char *path_src;
272 char path_dst[FILE_MAX];
273
274 if (absolute_base_path) {
275 STRNCPY(path_src_buf, *path);
276 BLI_path_abs(path_src_buf, absolute_base_path);
277 path_src = path_src_buf;
278 }
279 else {
280 path_src = *path;
281 }
282
283 if (bpath_data->callback_function(bpath_data, path_dst, sizeof(path_dst), path_src)) {
284 MEM_delete(*path);
285 (*path) = BLI_strdup(path_dst);
286 bpath_data->is_path_modified = true;
287 return true;
288 }
289
290 return false;
291}
292
294
295/* -------------------------------------------------------------------- */
298
300 char * /*path_dst*/,
301 size_t /*path_dst_maxncpy*/,
302 const char *path_src)
303{
304 ReportList *reports = static_cast<ReportList *>(bpath_data->user_data);
305
306 if (!BLI_exists(path_src)) {
307 ID *owner_id = bpath_data->owner_id;
308 if (owner_id) {
309 if (ID_IS_LINKED(owner_id)) {
310 BKE_reportf(reports,
312 "Path '%s' not found, from linked data-block '%s' (from library '%s')",
313 path_src,
314 owner_id->name,
315 owner_id->lib->runtime->filepath_abs);
316 }
317 else {
318 BKE_reportf(reports,
320 "Path '%s' not found, from local data-block '%s'",
321 path_src,
322 owner_id->name);
323 }
324 }
325 else {
327 reports, RPT_WARNING, "Path '%s' not found (no known owner data-block)", path_src);
328 }
329 }
330
331 return false;
332}
333
335{
336 BPathForeachPathData path_data{};
337 path_data.bmain = bmain;
341 path_data.user_data = reports;
342 BKE_bpath_foreach_path_main(&path_data);
343
344 if (reports->list.is_empty()) {
345 BKE_reportf(reports, RPT_INFO, "No missing files");
346 }
347}
348
350
351/* -------------------------------------------------------------------- */
354
355#define MAX_DIR_RECURSE 16
356#define FILESIZE_INVALID_DIRECTORY -1
357
373static bool missing_files_find__recursive(const char *search_directory,
374 const char *filename_src,
375 char r_filepath_new[FILE_MAX],
376 int64_t *r_filesize,
377 int *r_recurse_depth)
378{
379 /* TODO: Move this function to BLI_path_utils? The 'biggest size' behavior is quite specific
380 * though... */
381 DIR *dir;
382 BLI_stat_t status;
383 char path[FILE_MAX];
384 int64_t size;
385 bool found = false;
386
387 BLI_assert(!BLI_path_is_rel(search_directory));
388 dir = opendir(search_directory);
389
390 if (dir == nullptr) {
391 return found;
392 }
393
394 if (*r_filesize == FILESIZE_INVALID_DIRECTORY) {
395 *r_filesize = 0; /* The directory opened fine. */
396 }
397
398 for (dirent *de = readdir(dir); de != nullptr; de = readdir(dir)) {
399 if (FILENAME_IS_CURRPAR(de->d_name)) {
400 continue;
401 }
402
403 BLI_path_join(path, sizeof(path), search_directory, de->d_name);
404
405 if (BLI_stat(path, &status) == -1) {
406 CLOG_WARN(&LOG, "Cannot get file status (`stat()`) of '%s'", path);
407 continue;
408 }
409
410 if (S_ISREG(status.st_mode)) { /* It is a file. */
411 if (BLI_path_ncmp(filename_src, de->d_name, FILE_MAX) == 0) { /* Names match. */
412 size = status.st_size;
413 if ((size > 0) && (size > *r_filesize)) { /* Find the biggest matching file. */
414 *r_filesize = size;
415 BLI_strncpy(r_filepath_new, path, FILE_MAX);
416 found = true;
417 }
418 }
419 }
420 else if (S_ISDIR(status.st_mode)) { /* It is a sub-directory. */
421 if (*r_recurse_depth <= MAX_DIR_RECURSE) {
422 (*r_recurse_depth)++;
424 path, filename_src, r_filepath_new, r_filesize, r_recurse_depth);
425 (*r_recurse_depth)--;
426 }
427 }
428 }
429
430 closedir(dir);
431 return found;
432}
433
435 const char *basedir;
436 const char *searchdir;
438 bool find_all; /* Also search for files which current path is still valid. */
440};
441
443 char *path_dst,
444 size_t path_dst_maxncpy,
445 const char *path_src)
446{
447 BPathFind_Data *data = static_cast<BPathFind_Data *>(bpath_data->user_data);
448 char filepath_new[FILE_MAX];
449
451 int recurse_depth = 0;
452 bool is_found;
453
454 if (!data->find_all && BLI_exists(path_src)) {
455 return false;
456 }
457
458 data->summary.count_total++;
459
460 filepath_new[0] = '\0';
461
463 data->searchdir, BLI_path_basename(path_src), filepath_new, &filesize, &recurse_depth);
464
465 if (filesize == FILESIZE_INVALID_DIRECTORY) {
466 BKE_reportf(data->reports,
468 "Could not open the directory '%s'",
469 BLI_path_basename(data->searchdir));
470 data->summary.count_failed++;
471 return false;
472 }
473 if (is_found == false) {
474 BKE_reportf(data->reports,
476 "Could not find '%s' in '%s'",
477 BLI_path_basename(path_src),
478 data->searchdir);
479 data->summary.count_failed++;
480 return false;
481 }
482
483 /* Keep the path relative if the previous one was relative. */
484 if (BLI_path_is_rel(path_dst)) {
485 BLI_path_rel(filepath_new, data->basedir);
486 }
487 BLI_strncpy(path_dst, filepath_new, path_dst_maxncpy);
488 data->summary.count_changed++;
489 return true;
490}
491
493 const char *searchpath,
494 ReportList *reports,
495 const bool find_all,
496 BPathSummary *r_summary)
497{
498 BPathFind_Data data = {nullptr};
501
502 data.basedir = BKE_main_blendfile_path(bmain);
503 data.reports = reports;
504 data.searchdir = searchpath;
505 data.find_all = find_all;
506
507 BPathForeachPathData path_data{};
508 path_data.bmain = bmain;
510 path_data.flag = eBPathForeachFlag(flag);
511 path_data.user_data = &data;
512 BKE_bpath_foreach_path_main(&path_data);
513
514 if (r_summary) {
515 *r_summary = data.summary;
516 }
517}
518
519#undef MAX_DIR_RECURSE
520#undef FILESIZE_INVALID_DIRECTORY
521
523
524/* -------------------------------------------------------------------- */
527
535
537 char *path_dst,
538 size_t path_dst_maxncpy,
539 const char *path_src)
540{
541 BPathRebase_Data *data = static_cast<BPathRebase_Data *>(bpath_data->user_data);
542
543 data->summary.count_total++;
544
545 if (!BLI_path_is_rel(path_src)) {
546 /* Absolute, leave this as-is. */
547 return false;
548 }
549
550 char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE];
551 BLI_strncpy(filepath, path_src, FILE_MAX);
552 if (!BLI_path_abs(filepath, data->basedir_src)) {
553 BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made absolute", path_src);
554 data->summary.count_failed++;
555 return false;
556 }
557
558 BLI_path_normalize(filepath);
559
560 /* This may fail, if so it's fine to leave absolute since the path is still valid. */
561 BLI_path_rel(filepath, data->basedir_dst);
562
563 BLI_strncpy(path_dst, filepath, path_dst_maxncpy);
564 data->summary.count_changed++;
565 return true;
566}
567
569 const char *basedir_src,
570 const char *basedir_dst,
571 ReportList *reports,
572 BPathSummary *r_summary)
573{
574 BPathRebase_Data data = {nullptr};
576
577 BLI_assert(basedir_src[0] != '\0');
578 BLI_assert(basedir_dst[0] != '\0');
579
580 data.basedir_src = basedir_src;
581 data.basedir_dst = basedir_dst;
582 data.reports = reports;
583
584 BPathForeachPathData path_data{};
585 path_data.bmain = bmain;
587 path_data.flag = eBPathForeachFlag(flag);
588 path_data.user_data = &data;
589 BKE_bpath_foreach_path_main(&path_data);
590
591 if (r_summary) {
592 *r_summary = data.summary;
593 }
594}
595
597
598/* -------------------------------------------------------------------- */
601
608
610 char *path_dst,
611 size_t path_dst_maxncpy,
612 const char *path_src)
613{
614 BPathRemap_Data *data = static_cast<BPathRemap_Data *>(bpath_data->user_data);
615
616 data->summary.count_total++;
617
618 if (path_src[0] == '\0') {
619 return false; /* Empty, nothing to make relative. */
620 }
621 if (BLI_path_is_rel(path_src)) {
622 return false; /* Already relative. */
623 }
624
625 char path_test[FILE_MAX];
626 STRNCPY(path_test, path_src);
627
628 BLI_path_rel(path_test, data->basedir);
629 if (!BLI_path_is_rel(path_test)) {
630 const char *type_name = BKE_idtype_get_info_from_id(bpath_data->owner_id)->name;
631 const char *id_name = bpath_data->owner_id->name + 2;
632 BKE_reportf(data->reports,
634 "Path '%s' cannot be made relative for %s '%s'",
635 path_src,
636 type_name,
637 id_name);
638 data->summary.count_failed++;
639 return false;
640 }
641
642 BLI_strncpy(path_dst, path_test, path_dst_maxncpy);
643 data->summary.count_changed++;
644 return true;
645}
646
648 char *path_dst,
649 size_t path_dst_maxncpy,
650 const char *path_src)
651{
652 BPathRemap_Data *data = static_cast<BPathRemap_Data *>(bpath_data->user_data);
653
654 data->summary.count_total++;
655
656 if (!BLI_path_is_rel(path_src)) {
657 return false; /* Already absolute. */
658 }
659
660 char path_test[FILE_MAX];
661 STRNCPY(path_test, path_src);
662 BLI_path_abs(path_test, data->basedir);
663 if (BLI_path_is_rel(path_test)) {
664 const char *type_name = BKE_idtype_get_info_from_id(bpath_data->owner_id)->name;
665 const char *id_name = bpath_data->owner_id->name + 2;
666 BKE_reportf(data->reports,
668 "Path '%s' cannot be made absolute for %s '%s'",
669 path_src,
670 type_name,
671 id_name);
672 data->summary.count_failed++;
673 return false;
674 }
675
676 BLI_strncpy(path_dst, path_test, path_dst_maxncpy);
677 data->summary.count_changed++;
678 return true;
679}
680
682 const char *basedir,
683 ReportList *reports,
684 BPathForeachPathFunctionCallback callback_function,
685 BPathSummary *r_summary)
686{
687 BPathRemap_Data data = {nullptr};
688 const int flag = BKE_BPATH_FOREACH_PATH_SKIP_LINKED;
689
690 BLI_assert(basedir[0] != '\0');
691 if (basedir[0] == '\0') {
692 CLOG_ERROR(&LOG, "basedir='', this is a bug");
693 return;
694 }
695
696 data.basedir = basedir;
697 data.reports = reports;
698
699 BPathForeachPathData path_data{};
700 path_data.bmain = bmain;
701 path_data.callback_function = callback_function;
702 path_data.flag = eBPathForeachFlag(flag);
703 path_data.user_data = &data;
704 BKE_bpath_foreach_path_main(&path_data);
705
706 if (r_summary) {
707 *r_summary = data.summary;
708 }
709}
710
712 const char *basedir,
713 ReportList *reports,
714 BPathSummary *r_summary)
715{
717 bmain, basedir, reports, relative_convert_foreach_path_cb, r_summary);
718}
719
721 const char *basedir,
722 ReportList *reports,
723 BPathSummary *r_summary)
724{
726 bmain, basedir, reports, absolute_convert_foreach_path_cb, r_summary);
727}
728
730
731/* -------------------------------------------------------------------- */
735
736struct PathStore {
739 char filepath[0];
740};
741
743 char * /*path_dst*/,
744 size_t /*path_dst_maxncpy*/,
745 const char *path_src)
746{
747 ListBaseT<PathStore> *path_list = static_cast<ListBaseT<PathStore> *>(bpath_data->user_data);
748 size_t path_size = strlen(path_src) + 1;
749
750 /* NOTE: the PathStore and its string are allocated together in a single alloc. */
751 PathStore *path_store = static_cast<PathStore *>(
752 MEM_new_uninitialized(sizeof(PathStore) + path_size, __func__));
753
754 char *filepath = path_store->filepath;
755
756 memcpy(filepath, path_src, path_size);
757 BLI_addtail(path_list, path_store);
758 return false;
759}
760
762 char *path_dst,
763 size_t path_dst_maxncpy,
764 const char *path_src)
765{
766 ListBaseT<PathStore> *path_list = static_cast<ListBaseT<PathStore> *>(bpath_data->user_data);
767
768 /* `ls->first` should never be nullptr, because the number of paths should not change.
769 * If this happens, there is a bug in caller code. */
770 BLI_assert(!path_list->is_empty());
771
772 PathStore *path_store = path_list->first();
773 const char *filepath = path_store->filepath;
774 bool is_path_changed = false;
775
776 if (!STREQ(path_src, filepath)) {
777 BLI_strncpy(path_dst, filepath, path_dst_maxncpy);
778 is_path_changed = true;
779 }
780
781 BLI_freelinkN(path_list, path_store);
782 return is_path_changed;
783}
784
786{
787 ListBaseT<PathStore> *path_list = MEM_new_zeroed<ListBaseT<PathStore>>(__func__);
788
789 BPathForeachPathData path_data{};
790 path_data.bmain = bmain;
791 path_data.callback_function = bpath_list_append;
792 path_data.flag = flag;
793 path_data.user_data = path_list;
794 BKE_bpath_foreach_path_main(&path_data);
795
796 return path_list;
797}
798
799void BKE_bpath_list_restore(Main *bmain, const eBPathForeachFlag flag, void *path_list_handle)
800{
801 ListBaseT<PathStore> *path_list = static_cast<ListBaseT<PathStore> *>(path_list_handle);
802
803 BPathForeachPathData path_data{};
804 path_data.bmain = bmain;
805 path_data.callback_function = bpath_list_restore;
806 path_data.flag = flag;
807 path_data.user_data = path_list;
808 BKE_bpath_foreach_path_main(&path_data);
809}
810
811void BKE_bpath_list_free(void *path_list_handle)
812{
813 ListBaseT<PathStore> *path_list = static_cast<ListBaseT<PathStore> *>(path_list_handle);
814 /* The whole list should have been consumed by #BKE_bpath_list_restore, see also comment in
815 * #bpath_list_restore. */
816 BLI_assert(path_list->is_empty());
817
818 path_list->free_no_destruct();
819 MEM_delete(path_list);
820}
821
823
824} // namespace blender
#define FOREACH_MAIN_ID_END
Definition BKE_main.hh:735
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
Definition BKE_main.hh:729
File and directory operations.
#define BLI_path_ncmp
#define FILE_MAXFILE
#define FILE_MAX
#define BLI_path_join(...)
#define FILENAME_IS_CURRPAR(_n)
#define FILE_MAXDIR
Compatibility-like things for windows.
struct __dirstream DIR
struct dirent * readdir(DIR *dp)
int closedir(DIR *dp)
#define S_ISDIR(x)
const char * dirname(char *path)
DIR * opendir(const char *path)
#define S_ISREG(x)
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:188
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_BLEND_PATH(_bmain, _id)
Definition DNA_ID.h:688
Read Blender memory allocation and freeing.
#define STRPREFIX(a, b)
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
#define MAX_DIR_RECURSE
Definition bpath.cc:355
#define FILESIZE_INVALID_DIRECTORY
Definition bpath.cc:356
bNodeTree * node_tree_from_id(ID *id)
Definition node.cc:5337
std::string filename(const std::string_view &str, size_t pos)
BMesh Iterators.
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
char * STRNCPY(char(&dst)[N], const char *src)
bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_data, char *path_dir, size_t path_dir_maxncpy, char *path_file, size_t path_file_maxncpy)
Definition bpath.cc:235
@ RPT_WARNING
Definition BKE_report.hh:40
unsigned int uint
Definition BKE_text.h:55
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
bool BKE_bpath_foreach_path_allocated_process(BPathForeachPathData *bpath_data, char **path)
Definition bpath.cc:266
unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_filelist)
int bool bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(1
bool(*)(BPathForeachPathData *bpath_data, char *path_dst, size_t path_dst_maxncpy, const char *path_src) BPathForeachPathFunctionCallback
Definition BKE_bpath.hh:115
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
void BKE_bpath_foreach_path_main(BPathForeachPathData *bpath_data)
Definition bpath.cc:121
unsigned short ushort
Definition BKE_text.h:56
void BKE_bpath_relative_rebase(Main *bmain, const char *basedir_src, const char *basedir_dst, ReportList *reports, BPathSummary *r_summary=nullptr)
Definition bpath.cc:568
static bool bpath_list_append(BPathForeachPathData *bpath_data, char *, size_t, const char *path_src)
Definition bpath.cc:742
static bool relative_rebase_foreach_path_cb(BPathForeachPathData *bpath_data, char *path_dst, size_t path_dst_maxncpy, const char *path_src)
Definition bpath.cc:536
void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportList *reports, bool find_all, BPathSummary *r_summary=nullptr)
Definition bpath.cc:492
void BKE_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *reports, BPathSummary *r_summary=nullptr)
Definition bpath.cc:711
static bool missing_files_find_foreach_path_cb(BPathForeachPathData *bpath_data, char *path_dst, size_t path_dst_maxncpy, const char *path_src)
Definition bpath.cc:442
void BKE_bpath_summary_report(const BPathSummary &summary, ReportList *reports)
Definition bpath.cc:61
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
Definition main.cc:1058
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
static void bpath_absolute_relative_convert(Main *bmain, const char *basedir, ReportList *reports, BPathForeachPathFunctionCallback callback_function, BPathSummary *r_summary)
Definition bpath.cc:681
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
const IDTypeInfo * BKE_idtype_get_info_from_id(const ID *id)
Definition idtype.cc:232
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void DEG_id_tag_update(ID *id, unsigned int flags)
BMesh const char void * data
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:277
bool void BLI_path_rel(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1)
static bool check_missing_files_foreach_path_cb(BPathForeachPathData *bpath_data, char *, size_t, const char *path_src)
Definition bpath.cc:299
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
void BKE_bpath_foreach_path_id(BPathForeachPathData *bpath_data, ID *id)
Definition bpath.cc:77
static bool missing_files_find__recursive(const char *search_directory, const char *filename_src, char r_filepath_new[FILE_MAX], int64_t *r_filesize, int *r_recurse_depth)
Definition bpath.cc:373
void BKE_bpath_foreach_path_readonly_process(BPathForeachPathData *bpath_data, const char *path)
Definition bpath.cc:161
eBPathForeachFlag
Definition BKE_bpath.hh:39
@ BKE_BPATH_FOREACH_PATH_SKIP_PACKED
Definition BKE_bpath.hh:49
@ BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE
Definition BKE_bpath.hh:76
@ BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES
Definition BKE_bpath.hh:62
@ BKE_BPATH_FOREACH_PATH_ABSOLUTE
Definition BKE_bpath.hh:45
@ BKE_BPATH_FOREACH_PATH_RELOAD_EDITED
Definition BKE_bpath.hh:81
@ BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN
Definition BKE_bpath.hh:54
@ BKE_BPATH_FOREACH_PATH_SKIP_LINKED
Definition BKE_bpath.hh:47
void BKE_bpath_sequence_filepaths_foreach(const char *abs_filepath, blender::FunctionRef< void(blender::StringRef frame_filepath)> callback)
void BKE_bpath_list_restore(Main *bmain, eBPathForeachFlag flag, void *path_list_handle)
Definition bpath.cc:799
void BKE_bpath_list_free(void *path_list_handle)
Definition bpath.cc:811
void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char *path, size_t path_maxncpy)
Definition bpath.cc:130
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void * BKE_bpath_list_backup(Main *bmain, eBPathForeachFlag flag)
Definition bpath.cc:785
static bool relative_convert_foreach_path_cb(BPathForeachPathData *bpath_data, char *path_dst, size_t path_dst_maxncpy, const char *path_src)
Definition bpath.cc:609
@ ID_RECALC_SOURCE
Definition DNA_ID.h:1143
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
int BLI_path_sequence_decode(const char *path, char *head, size_t head_maxncpy, char *tail, size_t tail_maxncpy, unsigned short *r_digits_len)
Definition path_utils.cc:61
void BLI_path_split_dir_file(const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
static CLG_LogRef LOG
Definition logging.cpp:12
static bool absolute_convert_foreach_path_cb(BPathForeachPathData *bpath_data, char *path_dst, size_t path_dst_maxncpy, const char *path_src)
Definition bpath.cc:647
struct stat BLI_stat_t
void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports, BPathSummary *r_summary=nullptr)
Definition bpath.cc:720
void BKE_bpath_missing_files_check(Main *bmain, ReportList *reports)
Definition bpath.cc:334
static bool bpath_list_restore(BPathForeachPathData *bpath_data, char *path_dst, size_t path_dst_maxncpy, const char *path_src)
Definition bpath.cc:761
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:469
ReportList * reports
Definition bpath.cc:437
const char * basedir
Definition bpath.cc:435
BPathSummary summary
Definition bpath.cc:439
const char * searchdir
Definition bpath.cc:436
BPathForeachPathFunctionCallback callback_function
Definition BKE_bpath.hh:124
const char * basedir_dst
Definition bpath.cc:530
const char * basedir_src
Definition bpath.cc:529
BPathSummary summary
Definition bpath.cc:533
ReportList * reports
Definition bpath.cc:531
BPathSummary summary
Definition bpath.cc:606
const char * basedir
Definition bpath.cc:603
ReportList * reports
Definition bpath.cc:604
IDTypeForeachPathFunction foreach_path
const char * name
char name[258]
Definition DNA_ID.h:433
struct Library * lib
Definition DNA_ID.h:421
bke::library::LibraryRuntime * runtime
Definition DNA_ID.h:591
PathStore * prev
Definition bpath.cc:737
char filepath[0]
Definition bpath.cc:739
PathStore * next
Definition bpath.cc:737
ListBaseT< Report > list
Definition BKE_report.hh:79