Blender
V2.93
source
blender
blenkernel
intern
library.c
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU General Public License
4
* as published by the Free Software Foundation; either version 2
5
* of the License, or (at your option) any later version.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software Foundation,
14
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
*
16
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17
* All rights reserved.
18
*/
19
26
#include "
CLG_log.h
"
27
28
#include "
MEM_guardedalloc.h
"
29
30
/* all types are needed here, in order to do memory operations */
31
#include "
DNA_ID.h
"
32
33
#include "
BLI_utildefines.h
"
34
35
#include "
BLI_blenlib.h
"
36
37
#include "
BLT_translation.h
"
38
39
#include "
BKE_idtype.h
"
40
#include "
BKE_lib_id.h
"
41
#include "
BKE_lib_query.h
"
42
#include "
BKE_library.h
"
43
#include "
BKE_main.h
"
44
#include "
BKE_packedFile.h
"
45
46
/* Unused currently. */
47
// static CLG_LogRef LOG = {.identifier = "bke.library"};
48
49
static
void
library_free_data
(
ID
*
id
)
50
{
51
Library
*
library
= (
Library
*)
id
;
52
if
(
library
->packedfile) {
53
BKE_packedfile_free
(
library
->packedfile);
54
}
55
}
56
57
static
void
library_foreach_id
(
ID
*
id
,
LibraryForeachIDData
*
data
)
58
{
59
Library
*
lib
= (
Library
*)
id
;
60
BKE_LIB_FOREACHID_PROCESS
(
data
,
lib
->parent,
IDWALK_CB_NEVER_SELF
);
61
}
62
63
IDTypeInfo
IDType_ID_LI
= {
64
.
id_code
=
ID_LI
,
65
.id_filter = 0,
66
.main_listbase_index =
INDEX_ID_LI
,
67
.struct_size =
sizeof
(
Library
),
68
.name =
"Library"
,
69
.name_plural =
"libraries"
,
70
.translation_context =
BLT_I18NCONTEXT_ID_LIBRARY
,
71
.flags =
IDTYPE_FLAGS_NO_COPY
|
IDTYPE_FLAGS_NO_LIBLINKING
|
IDTYPE_FLAGS_NO_MAKELOCAL
|
72
IDTYPE_FLAGS_NO_ANIMDATA
,
73
74
.
init_data
=
NULL
,
75
.copy_data =
NULL
,
76
.free_data =
library_free_data
,
77
.make_local =
NULL
,
78
.foreach_id =
library_foreach_id
,
79
.foreach_cache =
NULL
,
80
.owner_get =
NULL
,
81
82
.blend_write =
NULL
,
83
.blend_read_data =
NULL
,
84
.blend_read_lib =
NULL
,
85
.blend_read_expand =
NULL
,
86
87
.blend_read_undo_preserve =
NULL
,
88
89
.lib_override_apply_post =
NULL
,
90
};
91
92
void
BKE_library_filepath_set
(
Main
*bmain,
Library
*
lib
,
const
char
*filepath)
93
{
94
/* in some cases this is used to update the absolute path from the
95
* relative */
96
if
(
lib
->filepath != filepath) {
97
BLI_strncpy
(
lib
->filepath, filepath,
sizeof
(
lib
->filepath));
98
}
99
100
BLI_strncpy
(
lib
->filepath_abs, filepath,
sizeof
(
lib
->filepath_abs));
101
102
/* Not essential but set `filepath_abs` is an absolute copy of value which
103
* is more useful if its kept in sync. */
104
if
(
BLI_path_is_rel
(
lib
->filepath_abs)) {
105
/* note that the file may be unsaved, in this case, setting the
106
* `filepath_abs` on an indirectly linked path is not allowed from the
107
* outliner, and its not really supported but allow from here for now
108
* since making local could cause this to be directly linked - campbell
109
*/
110
/* Never make paths relative to parent lib - reading code (blenloader) always set *all*
111
* `lib->filepath` relative to current main, not to their parent for indirectly linked ones. */
112
const
char
*basepath =
BKE_main_blendfile_path
(bmain);
113
BLI_path_abs
(
lib
->filepath_abs, basepath);
114
}
115
}
BKE_idtype.h
IDTYPE_FLAGS_NO_MAKELOCAL
@ IDTYPE_FLAGS_NO_MAKELOCAL
Definition:
BKE_idtype.h:49
IDTYPE_FLAGS_NO_ANIMDATA
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition:
BKE_idtype.h:51
IDTYPE_FLAGS_NO_COPY
@ IDTYPE_FLAGS_NO_COPY
Definition:
BKE_idtype.h:45
IDTYPE_FLAGS_NO_LIBLINKING
@ IDTYPE_FLAGS_NO_LIBLINKING
Definition:
BKE_idtype.h:47
BKE_lib_id.h
BKE_lib_query.h
BKE_LIB_FOREACHID_PROCESS
#define BKE_LIB_FOREACHID_PROCESS(_data, _id_super, _cb_flag)
Definition:
BKE_lib_query.h:163
IDWALK_CB_NEVER_SELF
@ IDWALK_CB_NEVER_SELF
Definition:
BKE_lib_query.h:49
BKE_library.h
BKE_main.h
BKE_main_blendfile_path
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
BKE_packedFile.h
BKE_packedfile_free
void BKE_packedfile_free(struct PackedFile *pf)
Definition:
packedFile.c:155
BLI_blenlib.h
BLI_path_is_rel
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition:
path_util.c:411
BLI_path_abs
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
Definition:
path_util.c:1016
BLI_strncpy
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition:
string.c:108
BLI_utildefines.h
BLT_translation.h
BLT_I18NCONTEXT_ID_LIBRARY
#define BLT_I18NCONTEXT_ID_LIBRARY
Definition:
BLT_translation.h:126
CLG_log.h
DNA_ID.h
ID and Library types, which are fundamental for sdna.
Library
struct Library Library
INDEX_ID_LI
@ INDEX_ID_LI
Definition:
DNA_ID.h:781
ID_LI
@ ID_LI
Definition:
DNA_ID_enums.h:58
MEM_guardedalloc.h
Read Guarded memory(de)allocation.
init_data
static void init_data(ModifierData *md)
Definition:
MOD_laplaciansmooth.c:498
NULL
return NULL
Definition:
bmesh_operator_api_inline.h:224
data
data
Definition:
bmesh_operator_api_inline.h:176
lib
DRWShaderLibrary * lib
Definition:
eevee_shaders.c:158
library
static FT_Library library
Definition:
freetypefont.c:51
BKE_library_filepath_set
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
Definition:
library.c:92
library_foreach_id
static void library_foreach_id(ID *id, LibraryForeachIDData *data)
Definition:
library.c:57
IDType_ID_LI
IDTypeInfo IDType_ID_LI
Definition:
library.c:63
library_free_data
static void library_free_data(ID *id)
Definition:
library.c:49
IDTypeInfo
Definition:
BKE_idtype.h:113
IDTypeInfo::id_code
short id_code
Definition:
BKE_idtype.h:120
ID
Definition:
DNA_ID.h:273
LibraryForeachIDData
Definition:
lib_query.c:46
Library
Definition:
DNA_ID.h:348
Main
Definition:
BKE_main.h:116
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1