Пример #1
0
//--------------------------------------------------------------------------
// This function is private and contains common code between the
// constructors taking a string or a char*
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist)
{
    // These bits only set for creation, so if any of them are set,
    // create the file.
    if( flags & (H5F_ACC_CREAT|H5F_ACC_EXCL|H5F_ACC_TRUNC|H5F_ACC_DEBUG))
    {
	hid_t create_plist_id = create_plist.getId();
	hid_t access_plist_id = access_plist.getId();
	id = H5Fcreate( name, flags, create_plist_id, access_plist_id );
	if( id < 0 )  // throw an exception when open/create fail
	{
	    throw FileIException("H5File constructor", "H5Fcreate failed");
	}
    }
    // Open the file if none of the bits above are set.
    else
    {
	hid_t access_plist_id = access_plist.getId();
	id = H5Fopen( name, flags, access_plist_id );
	if( id < 0 )  // throw an exception when open/create fail
	{
	    throw FileIException("H5File constructor", "H5Fopen failed");
	}
    }
}
Пример #2
0
//--------------------------------------------------------------------------
// Function:	FileAccPropList::setSplit
///\brief	Emulates the old split file driver, which stored meta data
///		in one file and raw data in another file.
///\param	meta_plist  - IN: File access plist for the metadata file
///\param	raw_plist   - IN: File access plist for the raw data file
///\param	meta_ext    - IN: Metadata filename extension as \c char*
///\param	raw_ext     - IN: Raw data filename extension as \c char*
///\exception	H5::PropListIException
///\par Description
///		Temporary - For information, please refer to:
/// <A HREF="../RM_H5P.html#Property-SetFaplSplit">../RM_H5P.html#Property-SetFaplSplit</A>
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
void FileAccPropList::setSplit( FileAccPropList& meta_plist, FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext ) const
{
   hid_t meta_pid = meta_plist.getId();
   hid_t raw_pid = raw_plist.getId();
   herr_t ret_value = H5Pset_fapl_split( id, meta_ext, meta_pid, raw_ext, raw_pid );
   if( ret_value < 0 )
{
      throw PropListIException("FileAccPropList::setSplit", "H5Pset_fapl_split failed");
   }
}
Пример #3
0
//--------------------------------------------------------------------------
// Function:	FileAccPropList::setFamily
///\brief	Sets this file access property list to use the family driver.
///\param	memb_size  - IN: Size in bytes of each file member
///\param	memb_plist - IN: File access property list to be used for
///					each family member
///\exception	H5::PropListIException
///\par Description
///		Note that \a memb_size is used only when creating a new file.
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
void FileAccPropList::setFamily( hsize_t memb_size, const FileAccPropList& memb_plist ) const
{
   herr_t ret_value = H5Pset_fapl_family (id, memb_size, memb_plist.getId() );
   if( ret_value < 0 )
   {
      throw PropListIException("FileAccPropList::setFamily", "H5Pset_fapl_family failed");
   }
}
Пример #4
0
//--------------------------------------------------------------------------
// Function:	H5File::getVFDHandle
///\brief	Returns the pointer to the file handle of the low-level file
///		driver.
///\param	fapl        - File access property list
///\param	file_handle - Pointer to the file handle being used by
///			      the low-level virtual file driver
///\exception	H5::FileIException
///\par Description
///		For the \c FAMILY or \c MULTI drivers, \a fapl should be
///		defined through the property list functions:
///		\c FileAccPropList::setFamilyOffset for the \c FAMILY driver
///		and \c FileAccPropList::setMultiType for the \c MULTI driver.
///
///		The obtained file handle is dynamic and is valid only while
///		the file remains open; it will be invalid if the file is
///		closed and reopened or opened during a subsequent session.
// Programmer   Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const
{
   hid_t fapl_id = fapl.getId();
   herr_t ret_value = H5Fget_vfd_handle(id, fapl_id, file_handle);
   if( ret_value < 0 )
   {
      throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed");
   }
}
Пример #5
0
//--------------------------------------------------------------------------
// Function:	openFile
///\brief	Opens an HDF5 file
///\param	name         - IN: Name of the file
///\param	flags        - IN: File access flags
///\param	access_plist - IN: File access property list.  Default to
///		FileAccPropList::DEFAULT
///\par Description
///		Valid values of \a flags include:
///		H5F_ACC_RDWR:   Open with read/write access. If the file is
///				currently open for read-only access then it
///				will be reopened. Absence of this flag
///				implies read-only access.
///
///		H5F_ACC_RDONLY: Open with read only access. - default
///
// Programmer	Binh-Minh Ribler - Oct, 2005
//--------------------------------------------------------------------------
void H5File::openFile(const char* name, unsigned int flags, const FileAccPropList& access_plist)
{
    hid_t access_plist_id = access_plist.getId();
    id = H5Fopen (name, flags, access_plist_id);
    if (id < 0)  // throw an exception when open fails
    {
	throw FileIException("H5File::openFile", "H5Fopen failed");
    }
}
Пример #6
0
//--------------------------------------------------------------------------
// Function:	FileAccPropList::getFamily
///\brief	Returns information about the family file access property
///		list.
///\param	memb_size  - OUT: Size in bytes of each file member
///\param	memb_plist - OUT: Retrieved file access property list for each
///				  file member
///\exception	H5::PropListIException
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const
{
   hid_t memb_plist_id;
   herr_t ret_value = H5Pget_fapl_family( id, &memb_size, &memb_plist_id );
   if( ret_value < 0 )
   {
      throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed");
   }
   memb_plist.setId(memb_plist_id);
}
Пример #7
0
int HDF5FileBase::open(bool newfile, int nChans)
{
    int accFlags,ret=0;

    if (opened) return -1;

    try
    {
		FileAccPropList props = FileAccPropList::DEFAULT;
		if (nChans > 0)
		{
			props.setCache(0, 809, 8 * 2 * 640 * nChans, 1);
			//std::cout << "opening HDF5 " << getFileName() << " with nchans: " << nChans << std::endl;
		}

        if (newfile) accFlags = H5F_ACC_TRUNC;
        else accFlags = H5F_ACC_RDWR;
        file = new H5File(getFileName().toUTF8(),accFlags,FileCreatPropList::DEFAULT,props);
        opened = true;
        if (newfile)
        {
            ret = createFileStructure();
        }

        if (ret)
        {
            file = nullptr;
            opened = false;
            std::cerr << "Error creating file structure" << std::endl;
        }


        return ret;
    }
    catch (FileIException error)
    {
        PROCESS_ERROR;
    }
}
Пример #8
0
//--------------------------------------------------------------------------
// Function:	openFile
///\brief	Opens an HDF5 file
///\param	name         - IN: Name of the file
///\param	flags        - IN: File access flags
///\param	access_plist - IN: File access property list.  Default to
///		FileAccPropList::DEFAULT
///\par Description
///		Valid values of \a flags include:
///		H5F_ACC_RDWR:   Open with read/write access. If the file is
///				currently open for read-only access then it
///				will be reopened. Absence of this flag
///				implies read-only access.
///
///		H5F_ACC_RDONLY: Open with read only access. - default
///
// Programmer	Binh-Minh Ribler - Oct, 2005
//--------------------------------------------------------------------------
void H5File::openFile(const char* name, unsigned int flags, const FileAccPropList& access_plist)
{
    try {
        close();
    }
    catch (Exception close_error) {
        throw FileIException("H5File::openFile", close_error.getDetailMsg());
    }

    hid_t access_plist_id = access_plist.getId();
    id = H5Fopen (name, flags, access_plist_id);
    if (id < 0)  // throw an exception when open fails
    {
	throw FileIException("H5File::openFile", "H5Fopen failed");
    }
}
Пример #9
0
static void test_libver_bounds_real(
                H5F_libver_t libver_create, unsigned oh_vers_create,
                H5F_libver_t libver_mod, unsigned oh_vers_mod)
{
    try {

    /*
     * Create a new file using the default creation property and access property
     * with latest library version.
     */
    FileAccPropList fapl;
    fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST);
    H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);

    /*
     * Make sure the root group has the correct object header version
     */
    unsigned obj_version = file.childObjVersion(ROOTGROUP);
    verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);

    // Verify object header version another way
    H5O_info_t oinfo;
    HDmemset(&oinfo, 0, sizeof(oinfo));
    file.getObjinfo(oinfo, H5O_INFO_HDR);
    verify_val(oinfo.hdr.version, oh_vers_create, "H5File::getObjinfo", __LINE__, __FILE__);

    /*
     * Reopen the file and make sure the root group still has the correct
     * version
     */
    file.close();

    fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST);

    file.openFile(FILE6, H5F_ACC_RDWR, fapl);

    obj_version = file.childObjVersion(ROOTGROUP);
    verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);

    /*
     * Create a group named "/G1" in the file, and make sure it has the correct
     * object header version
     */
    Group group = file.createGroup(GROUP1);

    obj_version = group.objVersion();
    verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);

    // Verify object header version another way
    HDmemset(&oinfo, 0, sizeof(oinfo));
    group.getObjinfo(oinfo, H5O_INFO_HDR);
    verify_val(oinfo.hdr.version, oh_vers_mod, "Group::getObjinfo", __LINE__, __FILE__);

    group.close(); // close "/G1"

    /*
     * Create a group named "/G1/G3" in the file, and make sure it has the
     * correct object header version
     */
    group = file.createGroup(SUBGROUP3);

    obj_version = group.objVersion();
    verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);

    group.close(); // close "/G1/G3"

    /*
     * Make sure the root group still has the correct object header version
     */
    obj_version = file.childObjVersion(ROOTGROUP);
    verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);

    // Everything should be closed as they go out of scope
    }   // end of try block

    catch (Exception& E)
    {
        issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg());
    }

} /* end test_libver_bounds_real() */