LCOV - code coverage report
Current view: top level - frmts/zarr - vsikerchunk.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 22 22 100.0 %
Date: 2025-09-10 17:48:50 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  Zarr driver
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "vsikerchunk.h"
      14             : 
      15             : #include "cpl_port.h"
      16             : #include "cpl_conv.h"
      17             : #include "cpl_error.h"
      18             : #include "cpl_string.h"
      19             : 
      20             : /************************************************************************/
      21             : /*                    VSIInstallKerchunkFileSystems()                   */
      22             : /************************************************************************/
      23             : 
      24        1741 : void VSIInstallKerchunkFileSystems()
      25             : {
      26        1741 :     VSIInstallKerchunkJSONRefFileSystem();
      27        1741 :     VSIInstallKerchunkParquetRefFileSystem();
      28        1741 : }
      29             : 
      30             : /************************************************************************/
      31             : /*                    VSIKerchunkFileSystemsCleanCache()                */
      32             : /************************************************************************/
      33             : 
      34        1063 : void VSIKerchunkFileSystemsCleanCache()
      35             : {
      36        1063 :     VSIKerchunkParquetRefFileSystemCleanCache();
      37        1063 : }
      38             : 
      39             : /************************************************************************/
      40             : /*                    VSIKerchunkMorphURIToVSIPath()                    */
      41             : /************************************************************************/
      42             : 
      43          40 : std::string VSIKerchunkMorphURIToVSIPath(const std::string &osURI,
      44             :                                          const std::string &osRootDirname)
      45             : {
      46          80 :     const std::string osRet = VSIURIToVSIPath(osURI);
      47          40 :     if (osRet != osURI)
      48           1 :         return osRet;
      49             : 
      50          39 :     if (CPLIsFilenameRelative(osURI.c_str()))
      51             :     {
      52             :         return CPLFormFilenameSafe(osRootDirname.c_str(), osURI.c_str(),
      53          31 :                                    nullptr);
      54             :     }
      55           8 :     else if (VSIIsLocal(osURI.c_str()) && !VSIIsLocal(osRootDirname.c_str()))
      56             :     {
      57           3 :         const char *pszVal = CPLGetConfigOption(
      58             :             "GDAL_ALLOW_REMOTE_RESOURCE_TO_ACCESS_LOCAL_FILE", nullptr);
      59           3 :         if (pszVal == nullptr)
      60             :         {
      61           1 :             CPLError(CE_Failure, CPLE_AppDefined,
      62             :                      "Remote resource '%s' tries to access local file '%s'. "
      63             :                      "This is disabled by default. Set the "
      64             :                      "GDAL_ALLOW_REMOTE_RESOURCE_TO_ACCESS_LOCAL_FILE "
      65             :                      "configuration option to YES to allow that.",
      66             :                      osRootDirname.c_str(), osURI.c_str());
      67           1 :             return std::string();
      68             :         }
      69           2 :         else if (!CPLTestBool(pszVal))
      70             :         {
      71           1 :             CPLError(CE_Failure, CPLE_AppDefined,
      72             :                      "Remote resource '%s' tries to access local file '%s'.",
      73             :                      osRootDirname.c_str(), osURI.c_str());
      74           1 :             return std::string();
      75             :         }
      76             :     }
      77             : 
      78           6 :     return osURI;
      79             : }

Generated by: LCOV version 1.14