Coverage Report

Created: 2026-02-26 07:02

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