I have code which opens an hdf file, and if the file does not exist it does
create an hdf file.
std::string filename_;
hid_t file_;
hid_t filename_;
void open()
{
file_ = H5Fopen(filename_.c_str(), H5F_ACC_RDWR, fileaccessProp_);
if(file_ < 0 ) //if file does not exist creat one
{
file_ = H5Fcreate(filename_.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT,
fileaccessProp_ );
}
}
The problem with that code is that if the file does not exist already than
H5open not just returns -1 but also prints multiple lines of error messages
on the command prompt
Is there a 'quiet' way to check for the existence of an hdf file?
I do have a very similar problem when trying to open a dataset which does
not exist yet in an open hdf file.
I have code which opens an hdf file, and if the file does not exist it does create an hdf file.
std::string filename_;
hid_t file_;
hid_t filename_;
void open()
{
file_ = H5Fopen(filename_.c_str(), H5F_ACC_RDWR, fileaccessProp_);
if(file_ < 0 ) //if file does not exist creat one
{
file_ = H5Fcreate(filename_.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fileaccessProp_ );
}
The problem with that code is that if the file does not exist already than H5open not just returns -1 but also prints multiple lines of error messages on the command prompt
Is there a 'quiet' way to check for the existence of an hdf file?
You could wrap the call to H5Fopen() in the H5E_BEGIN_TRY/H5E_END_TRY macros.
I do have a very similar problem when trying to open a dataset which does not exist yet in an open hdf file.
I have code which opens an hdf file, and if the file does not exist it
does create an hdf file.
std::string filename_;
hid_t file_;
hid_t filename_;
void open()
{
file_ = H5Fopen(filename_.c_str(), H5F_ACC_RDWR,
fileaccessProp_);
if(file_ < 0 ) //if file does not exist creat one
{
file_ = H5Fcreate(filename_.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT,
fileaccessProp_ );
}
}
The problem with that code is that if the file does not exist already
than H5open not just returns -1 but also prints multiple lines of
error messages on the command prompt
Is there a 'quiet' way to check for the existence of an hdf file?
I do have a very similar problem when trying to open a dataset which
does not exist yet in an open hdf file.
--
Mark C. Miller, Lawrence Livermore National Laboratory
email: mailto:miller86@llnl.gov
(M/T/W) (925)-423-5901 (!!LLNL BUSINESS ONLY!!)
(Th/F) (530)-753-8511 (!!LLNL BUSINESS ONLY!!)
The problem with that code is that if the file does not exist already
than H5open not just returns -1 but also prints multiple lines of error
messages on the command prompt
Is there a 'quiet' way to check for the existence of an hdf file?
I do have a very similar problem when trying to open a dataset which
does not exist yet in an open hdf file.
I have code which opens an hdf file, and if the file does not exist it does create an hdf file.
std::string filename_;
hid_t file_;
hid_t filename_;
void open()
{
file_ = H5Fopen(filename_.c_str(), H5F_ACC_RDWR, fileaccessProp_);
if(file_ < 0 ) //if file does not exist creat one
{
file_ = H5Fcreate(filename_.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fileaccessProp_ );
}
The problem with that code is that if the file does not exist already than H5open not just returns -1 but also prints multiple lines of error messages on the command prompt
Is there a 'quiet' way to check for the existence of an hdf file?
I do have a very similar problem when trying to open a dataset which does not exist yet in an open hdf file.
The easiest way to check for the existence of any file is to use stat()
Cheers,
Allen
···
On Jul 9, 2009, at 3:10 AM, W Eryk Wolski wrote:
I have code which opens an hdf file, and if the file does not exist it does create an hdf file.
std::string filename_;
hid_t file_;
hid_t filename_;
void open()
{
file_ = H5Fopen(filename_.c_str(), H5F_ACC_RDWR, fileaccessProp_);
if(file_ < 0 ) //if file does not exist creat one
{
file_ = H5Fcreate(filename_.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fileaccessProp_ );
}
The problem with that code is that if the file does not exist already than H5open not just returns -1 but also prints multiple lines of error messages on the command prompt
Is there a 'quiet' way to check for the existence of an hdf file?
I do have a very similar problem when trying to open a dataset which does not exist yet in an open hdf file.