1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * Copyright by the Board of Trustees of the University of Illinois. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the COPYING file, which can be found at the root of the source code *
9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10 * If you do not have access to either file, you may request a copy from *
11 * help@hdfgroup.org. *
12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14 /*-------------------------------------------------------------------------
15 *
16 * Created: H5Plcpl.c
17 * May 8 2006
18 * Peter Cao <xcao@ncsa.uiuc.edu>
19 *
20 * Purpose: Link creation property list class routines
21 *
22 *-------------------------------------------------------------------------
23 */
24
25 /****************/
26 /* Module Setup */
27 /****************/
28 #define H5P_PACKAGE /*suppress error about including H5Ppkg */
29
30
31 /***********/
32 /* Headers */
33 /***********/
34 #include "H5private.h" /* Generic Functions */
35 #include "H5Eprivate.h" /* Error handling */
36 #include "H5Iprivate.h" /* IDs */
37 #include "H5Lprivate.h" /* Links */
38 #include "H5Ppkg.h" /* Property lists */
39
40
41 /****************/
42 /* Local Macros */
43 /****************/
44
45 /* ======== Link creation properties ======== */
46 /* Definitions for create intermediate groups flag */
47 #define H5L_CRT_INTERMEDIATE_GROUP_SIZE sizeof(unsigned)
48 #define H5L_CRT_INTERMEDIATE_GROUP_DEF 0
49
50
51 /******************/
52 /* Local Typedefs */
53 /******************/
54
55
56 /********************/
57 /* Package Typedefs */
58 /********************/
59
60
61 /********************/
62 /* Local Prototypes */
63 /********************/
64
65 /* Property class callbacks */
66 static herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass);
67
68
69 /*********************/
70 /* Package Variables */
71 /*********************/
72
73 /* Link creation property list class library initialization object */
74 const H5P_libclass_t H5P_CLS_LCRT[1] = {{
75 "link create", /* Class name for debugging */
76 H5P_TYPE_LINK_CREATE, /* Class type */
77
78 &H5P_CLS_STRING_CREATE_g, /* Parent class */
79 &H5P_CLS_LINK_CREATE_g, /* Pointer to class */
80 &H5P_CLS_LINK_CREATE_ID_g, /* Pointer to class ID */
81 &H5P_LST_LINK_CREATE_ID_g, /* Pointer to default property list ID */
82 H5P_lcrt_reg_prop, /* Default property registration routine */
83
84 NULL, /* Class creation callback */
85 NULL, /* Class creation callback info */
86 NULL, /* Class copy callback */
87 NULL, /* Class copy callback info */
88 NULL, /* Class close callback */
89 NULL /* Class close callback info */
90 }};
91
92
93 /*****************************/
94 /* Library Private Variables */
95 /*****************************/
96
97
98 /*******************/
99 /* Local Variables */
100 /*******************/
101
102
103
104 /*-------------------------------------------------------------------------
105 * Function: H5P_lcrt_reg_prop
106 *
107 * Purpose: Register the dataset creation property list class's properties
108 *
109 * Return: Non-negative on success/Negative on failure
110 *
111 * Programmer: Quincey Koziol
112 * October 31, 2006
113 *-------------------------------------------------------------------------
114 */
115 herr_t
H5P_lcrt_reg_prop(H5P_genclass_t * pclass)116 H5P_lcrt_reg_prop(H5P_genclass_t *pclass)
117 {
118 unsigned intmd_group = H5L_CRT_INTERMEDIATE_GROUP_DEF; /* Default setting for creating intermediate groups */
119 herr_t ret_value = SUCCEED; /* Return value */
120
121 FUNC_ENTER_NOAPI(FAIL)
122
123 /* Register create intermediate groups property */
124 if(H5P_register_real(pclass, H5L_CRT_INTERMEDIATE_GROUP_NAME, H5L_CRT_INTERMEDIATE_GROUP_SIZE, &intmd_group, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
125 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
126
127 done:
128 FUNC_LEAVE_NOAPI(ret_value)
129 } /* end H5P_lcrt_reg_prop() */
130
131
132 /*-------------------------------------------------------------------------
133 * Function: H5Pset_create_intermediate_group
134 *
135 * Purpose: set crt_intmd_group so that H5Lcreate_*, H5Olink, etc.
136 * will create missing groups along the given path "name"
137 *
138 * Note: XXX: This property should really be an access property. -QAK
139 *
140 * Return: Non-negative on success/Negative on failure
141 *
142 * Programmer: Peter Cao
143 * May 08, 2005
144 *-------------------------------------------------------------------------
145 */
146 herr_t
H5Pset_create_intermediate_group(hid_t plist_id,unsigned crt_intmd_group)147 H5Pset_create_intermediate_group(hid_t plist_id, unsigned crt_intmd_group)
148 {
149 H5P_genplist_t *plist; /* Property list pointer */
150 herr_t ret_value = SUCCEED; /* Return value */
151
152 FUNC_ENTER_API(FAIL)
153 H5TRACE2("e", "iIu", plist_id, crt_intmd_group);
154
155 /* Get the plist structure */
156 if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE)))
157 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
158
159 /* Set value */
160 crt_intmd_group = (unsigned)(crt_intmd_group > 0 ? 1 : 0);
161 if(H5P_set(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0)
162 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set intermediate group creation flag")
163
164 done:
165 FUNC_LEAVE_API(ret_value)
166 } /* end H5Pset_create_intermediate_group() */
167
168
169 /*-------------------------------------------------------------------------
170 * Function: H5Pget_create_intermediate_group
171 *
172 * Purpose: Returns the crt_intmd_group, which is set to create missing
173 * groups during H5Olink, etc.
174 *
175 * Return: Non-negative on success/Negative on failure
176 *
177 * Programmer: Peter Cao
178 * May 08, 2005
179 *-------------------------------------------------------------------------
180 */
181 herr_t
H5Pget_create_intermediate_group(hid_t plist_id,unsigned * crt_intmd_group)182 H5Pget_create_intermediate_group(hid_t plist_id, unsigned *crt_intmd_group /*out*/)
183 {
184 H5P_genplist_t *plist; /* Property list pointer */
185 herr_t ret_value = SUCCEED; /* return value */
186
187 FUNC_ENTER_API(FAIL)
188 H5TRACE2("e", "ix", plist_id, crt_intmd_group);
189
190 /* Get the plist structure */
191 if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE)))
192 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
193
194 /* Get values */
195 if(crt_intmd_group)
196 if(H5P_get(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, crt_intmd_group) < 0)
197 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get intermediate group creation flag")
198
199 done:
200 FUNC_LEAVE_API(ret_value)
201 } /* end H5Pget_create_intermediate_group() */
202
203