createHardLink

C++ Function Reference

1 Signature

void BigDataStatMeth::createHardLink(H5::H5File *file, std::string original, std::string link)

2 Description

Creates a hard link in an HDF5 file.

3 Parameters

  • file (H5::H5File *): Pointer to HDF5 file
  • original (std::string): Path to original element
  • link (std::string): Path for new link

4 Details

filePointer to HDF5 file originalPath to original element linkPath for new linkH5::FileIExceptionon file operation errors H5::DataSetIExceptionon dataset operation errors H5::GroupIExceptionon group operation errors std::exceptionon other errorsThis function is not fully tested

5 Source Code

File: inst/include/hdf5Utilities/hdf5Utilities.hppLines 241-276

inline void createHardLink( H5::H5File* file, std::string original, std::string link)
    {
        
        try{
            
            H5::Exception::dontPrint();
            
            const char * charOriginal = original.c_str();
            const char * charLink = link.c_str();
            
            herr_t status = H5Lcreate_hard(file->getId(), charOriginal, file->getId(), charLink, H5P_DEFAULT, H5P_DEFAULT);
            
            if(status<0) {
                Rcpp::Rcerr<<"c++ exception createHardLink (create_hard IException)" << std::endl;
                return void();
            }
            
        } catch(H5::FileIException& error) { 
            Rcpp::Rcerr<<"c++ exception createHardLink (File IException)" << std::endl;
            return void();
        } catch(H5::DataSetIException& error) { 
            Rcpp::Rcerr<<"c++ exception createHardLink (DataSet IException)" << std::endl;
            return void();
        } catch(H5::GroupIException& error) { 
            Rcpp::Rcerr<<"c++ exception createHardLink (Group IException)" << std::endl;
            return void();
        } catch(std::exception &ex) {
            Rcpp::Rcerr << "c++ exception createHardLink: " << ex.what();
            return void();
        }  catch (...) {
            Rcpp::Rcerr<<"\nC++ exception createHardLink (unknown reason)";
            return void();
        }
        
        return void();
    }

6 Usage Example

#include "BigDataStatMeth.hpp"

// Example usage
auto result = createHardLink(...);