close file properly in h5readatt_octave
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>pull/10/head
parent
8ec70a6df5
commit
041339d2a7
|
@ -41,6 +41,8 @@ DEFUN_DLD (h5readatt_octave, args, nargout, "h5readatt_octave(<File_Name>,<DataS
|
||||||
|
|
||||||
if (obj==-1)
|
if (obj==-1)
|
||||||
{
|
{
|
||||||
|
H5Oclose(obj);
|
||||||
|
H5Fclose(file);
|
||||||
error("h5readatt_octave: opening the given Object failed");
|
error("h5readatt_octave: opening the given Object failed");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +50,8 @@ DEFUN_DLD (h5readatt_octave, args, nargout, "h5readatt_octave(<File_Name>,<DataS
|
||||||
hid_t attr = H5Aopen_name(obj, args(2).string_value().c_str());
|
hid_t attr = H5Aopen_name(obj, args(2).string_value().c_str());
|
||||||
if (attr==-1)
|
if (attr==-1)
|
||||||
{
|
{
|
||||||
|
H5Oclose(obj);
|
||||||
|
H5Fclose(file);
|
||||||
error("h5readatt_octave: opening the given Attribute failed");
|
error("h5readatt_octave: opening the given Attribute failed");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -55,12 +59,18 @@ DEFUN_DLD (h5readatt_octave, args, nargout, "h5readatt_octave(<File_Name>,<DataS
|
||||||
hid_t type = H5Aget_type(attr);
|
hid_t type = H5Aget_type(attr);
|
||||||
if (type<0)
|
if (type<0)
|
||||||
{
|
{
|
||||||
|
H5Aclose(attr);
|
||||||
|
H5Oclose(obj);
|
||||||
|
H5Fclose(file);
|
||||||
error("h5readatt_octave: dataset type error");
|
error("h5readatt_octave: dataset type error");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (H5Tget_class(type)!=H5T_FLOAT)
|
if (H5Tget_class(type)!=H5T_FLOAT)
|
||||||
{
|
{
|
||||||
|
H5Aclose(attr);
|
||||||
|
H5Oclose(obj);
|
||||||
|
H5Fclose(file);
|
||||||
error("h5readatt_octave: attribute type not supported");
|
error("h5readatt_octave: attribute type not supported");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +82,9 @@ DEFUN_DLD (h5readatt_octave, args, nargout, "h5readatt_octave(<File_Name>,<DataS
|
||||||
float f_value[numVal];
|
float f_value[numVal];
|
||||||
if (H5Aread(attr, H5T_NATIVE_FLOAT, f_value)<0)
|
if (H5Aread(attr, H5T_NATIVE_FLOAT, f_value)<0)
|
||||||
{
|
{
|
||||||
|
H5Aclose(attr);
|
||||||
|
H5Oclose(obj);
|
||||||
|
H5Fclose(file);
|
||||||
error("h5readatt_octave: reading the given Attribute failed");
|
error("h5readatt_octave: reading the given Attribute failed");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -82,12 +95,18 @@ DEFUN_DLD (h5readatt_octave, args, nargout, "h5readatt_octave(<File_Name>,<DataS
|
||||||
{
|
{
|
||||||
if (H5Aread(attr, H5T_NATIVE_DOUBLE, value)<0)
|
if (H5Aread(attr, H5T_NATIVE_DOUBLE, value)<0)
|
||||||
{
|
{
|
||||||
|
H5Aclose(attr);
|
||||||
|
H5Oclose(obj);
|
||||||
|
H5Fclose(file);
|
||||||
error("h5readatt_octave: reading the given Attribute failed");
|
error("h5readatt_octave: reading the given Attribute failed");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
H5Aclose(attr);
|
||||||
|
H5Oclose(obj);
|
||||||
|
H5Fclose(file);
|
||||||
error("h5readatt_octave: reading the given Attribute failed: unknown type");
|
error("h5readatt_octave: reading the given Attribute failed: unknown type");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue