예제 #1
0
파일: H5File.cpp 프로젝트: Hulalazz/rnnlib
//--------------------------------------------------------------------------
// 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
파일: H5File.cpp 프로젝트: Hulalazz/rnnlib
//--------------------------------------------------------------------------
// 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
파일: H5File.cpp 프로젝트: Hulalazz/rnnlib
//--------------------------------------------------------------------------
// 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:	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");
    }
}