10 #include "HDFexception.hxx"
12 HDFfile::HDFfile(char *name)
13 : HDFcontainerObject(name)
16 void HDFfile::CreateOnDisk()
18 if ((_id = HDFfileCreate(_name)) < 0)
19 throw HDFexception("Can't create HDF file");
22 void HDFfile::OpenOnDisk(hdf_access_mode access_mode)
24 _access_mode = access_mode;
29 if (access(_name,F_OK))
31 if ((_id = HDFfileCreate(_name)) < 0)
32 throw HDFexception("Can't open HDF file");
35 if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
36 throw HDFexception("Can't open HDF file");
40 if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
41 throw HDFexception("Can't open HDF file");
45 throw HDFexception("Can't open HDF file : bad acces option");
49 void HDFfile::CloseOnDisk()
53 if ((ret = HDFfileClose(_id)) < 0)
54 throw HDFexception("Can't close HDF file");
59 hdf_access_mode HDFfile::GetAccessMode()
64 hdf_object_type HDFfile::GetObjectType()
69 int HDFfile::nInternalObjects()
74 if ((ret = HDFnObjects(_id,"/",&n)) < 0)
75 throw HDFexception("Can't determine the number of internal objects");
80 void HDFfile::InternalObjectIndentify(int rank, char *object_name)
84 if ((ret = HDFobjectIdentify(_id,"/",rank,object_name)) < 0)
85 throw HDFexception("Can't identify an internal object");
88 int HDFfile::ExistInternalObject(char *object_name)
92 char name[HDF_NAME_MAX_LEN+1];
94 n = this->nInternalObjects();
97 this->InternalObjectIndentify(i,name);
98 if (!strcmp(name,object_name))
107 hdf_object_type HDFfile::InternalObjectType(char *object_name)
109 hdf_object_type type;
112 if ((ret = HDFobjectType(_id,object_name,&type)) < 0)
113 throw HDFexception("Can't determine internal object type");