Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BKE_bpath.h « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3ec5409ca7ff051fdeb325c9bba685d2fb6b9644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

/** \file
 * \ingroup bke
 * \attention Based on ghash, difference is ghash is not a fixed size,
 *   so for BPath we don't need to malloc
 */

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

struct ID;
struct ListBase;
struct Main;
struct ReportList;

/* Function that does something with an ID's file path. Should return 1 if the
 * path has changed, and in that case, should write the result to pathOut. */
typedef bool (*BPathVisitor)(void *userdata, char *path_dst, const char *path_src);
/* Executes 'visit' for each path associated with 'id'. */
void BKE_bpath_traverse_id(struct Main *bmain,
                           struct ID *id,
                           BPathVisitor visit_cb,
                           const int flag,
                           void *bpath_user_data);
void BKE_bpath_traverse_id_list(struct Main *bmain,
                                struct ListBase *lb,
                                BPathVisitor visit_cb,
                                const int flag,
                                void *bpath_user_data);
void BKE_bpath_traverse_main(struct Main *bmain,
                             BPathVisitor visit_cb,
                             const int flag,
                             void *bpath_user_data);
bool BKE_bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src);

/* Functions for temp backup/restore of paths, path count must NOT change */
void *BKE_bpath_list_backup(struct Main *bmain, const int flag);
void BKE_bpath_list_restore(struct Main *bmain, const int flag, void *ls_handle);
void BKE_bpath_list_free(void *ls_handle);

enum {
  /* convert paths to absolute */
  BKE_BPATH_TRAVERSE_ABS = (1 << 0),
  /* skip library paths */
  BKE_BPATH_TRAVERSE_SKIP_LIBRARY = (1 << 1),
  /* skip packed data */
  BKE_BPATH_TRAVERSE_SKIP_PACKED = (1 << 2),
  /* skip paths where a single dir is used with an array of files, eg.
   * sequence strip images and pointcache. in this case only use the first
   * file, this is needed for directory manipulation functions which might
   * otherwise modify the same directory multiple times */
  BKE_BPATH_TRAVERSE_SKIP_MULTIFILE = (1 << 3),
  /* reload data (when the path is edited) */
  BKE_BPATH_TRAVERSE_RELOAD_EDITED = (1 << 4),
};

/* high level funcs */

/* creates a text file with missing files if there are any */
void BKE_bpath_missing_files_check(struct Main *bmain, struct ReportList *reports);
void BKE_bpath_missing_files_find(struct Main *bmain,
                                  const char *searchpath,
                                  struct ReportList *reports,
                                  const bool find_all);
void BKE_bpath_relative_rebase(struct Main *bmain,
                               const char *basedir_src,
                               const char *basedir_dst,
                               struct ReportList *reports);
void BKE_bpath_relative_convert(struct Main *bmain,
                                const char *basedir,
                                struct ReportList *reports);
void BKE_bpath_absolute_convert(struct Main *bmain,
                                const char *basedir,
                                struct ReportList *reports);

#ifdef __cplusplus
}
#endif