Coverage Report

Created: 2025-06-09 07:42

/src/gdal/frmts/zarr/zarr_dimension.cpp
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 *
3
 * Project:  GDAL
4
 * Purpose:  Zarr driver
5
 * Author:   Even Rouault <even dot rouault at spatialys.com>
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2021, Even Rouault <even dot rouault at spatialys.com>
9
 *
10
 * SPDX-License-Identifier: MIT
11
 ****************************************************************************/
12
13
#include "zarr.h"
14
15
/************************************************************************/
16
/*                              Rename()                                */
17
/************************************************************************/
18
19
bool ZarrDimension::Rename(const std::string &osNewName)
20
0
{
21
0
    if (!m_bUpdatable)
22
0
    {
23
0
        CPLError(CE_Failure, CPLE_NotSupported,
24
0
                 "Dataset not open in update mode");
25
0
        return false;
26
0
    }
27
0
    if (!IsXArrayDimension())
28
0
    {
29
0
        CPLError(CE_Failure, CPLE_NotSupported,
30
0
                 "Cannot rename an implicit dimension "
31
0
                 "(that is one listed in _ARRAY_DIMENSIONS attribute)");
32
0
        return false;
33
0
    }
34
0
    if (!ZarrGroupBase::IsValidObjectName(osNewName))
35
0
    {
36
0
        CPLError(CE_Failure, CPLE_NotSupported, "Invalid dimension name");
37
0
        return false;
38
0
    }
39
40
0
    if (auto poParentGroup = m_poParentGroup.lock())
41
0
    {
42
0
        if (!poParentGroup->RenameDimension(m_osName, osNewName))
43
0
        {
44
0
            return false;
45
0
        }
46
0
    }
47
48
0
    BaseRename(osNewName);
49
50
0
    m_bModified = true;
51
52
0
    return true;
53
0
}