static PyObject* pydat_name(HDSObject *self) { // Recover C-pointer passed via Python HDSLoc* loc = HDS_retrieve_locator(self); char name_str[DAT__SZNAM+1]; int status = SAI__OK; errBegin(&status); datName(loc, name_str, &status); if (raiseHDSException(&status)) return NULL; return Py_BuildValue("s", name_str); };
int datCopy( const HDSLoc *locator1, const HDSLoc *locator2, const char *name_str, int *status) { char sourcename[DAT__SZNAM+1]; char cleanname[DAT__SZNAM+1]; hid_t parent_id = -1; hid_t objid = -1; if (*status != SAI__OK) return *status; /* Validate input locators. */ dat1ValidateLocator( "datCopy", 1, locator1, 1, status ); dat1ValidateLocator( "datCopy", 1, locator2, 0, status ); dau1CheckName( name_str, 1, cleanname, sizeof(cleanname), status ); if (*status != SAI__OK) return *status; /* Have to give the source name as "." doesn't seem to be allowed. so get the name and the parent locator. */ objid = dat1RetrieveIdentifier( locator1, status ); /* If we are at the root group we can not get a parent so just use the "/" name instead */ parent_id = dat1GetParentID( objid, 1, status ); if (*status == DAT__OBJIN) { emsAnnul(status); star_strlcpy( sourcename, "/", sizeof(sourcename)); parent_id = -1; } else { datName( locator1, sourcename, status ); } CALLHDFQ(H5Ocopy( (parent_id == -1 ? objid : parent_id), sourcename, locator2->group_id, cleanname, H5P_DEFAULT, H5P_DEFAULT)); CLEANUP: if (parent_id) H5Gclose(parent_id); return *status; }
int datErase(const HDSLoc *locator, const char *name_str, int *status) { char groupstr[DAT__SZNAM+1]; char cleanname[DAT__SZNAM+1]; if (*status != SAI__OK) return *status; /* Validate input locator. */ dat1ValidateLocator( "datErase", 1, locator, 0, status ); /* containing locator must refer to a group */ if (locator->group_id <= 0) { *status = DAT__OBJIN; emsRep("datErase_1", "Input object is not a structure", status); return *status; } /* Parent group for error reporting */ datName( locator, groupstr, status); /* Ensure the name is cleaned up before we use it */ dau1CheckName( name_str, 1, cleanname, sizeof(cleanname), status ); CALLHDFQ( H5Ldelete( locator->group_id, cleanname, H5P_DEFAULT )); /* Remove the handle for the erased component and all sub-components */ dat1EraseHandle( locator->handle, cleanname, status ); CLEANUP: if (*status != SAI__OK) { emsRepf("datErase_2", "Error deleting component %s in group %s", status, name_str, groupstr); } return *status; }