当前位置: 首页>>代码示例>>C++>>正文


C++ H5Lexists函数代码示例

本文整理汇总了C++中H5Lexists函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Lexists函数的具体用法?C++ H5Lexists怎么用?C++ H5Lexists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了H5Lexists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: luaC_h5_open_group

int luaC_h5_open_group(lua_State *L)
{
  const char *gname = luaL_checkstring(L, 1);
  const char *mode  = luaL_checkstring(L, 2);

  hid_t grp = 0;

  if (PresentFile < 0) {
    luaL_error(L, "need an open file to open group\n");
  }
  else if (strcmp(mode, "w") == 0) {
    if (H5Lexists(PresentFile, gname, H5P_DEFAULT)) {
      H5Ldelete(PresentFile, gname, H5P_DEFAULT);
    }
    grp = H5Gcreate(PresentFile, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  }
  else if (strcmp(mode, "r+") == 0) {
    if (H5Lexists(PresentFile, gname, H5P_DEFAULT)) {
      grp = H5Gopen(PresentFile, gname, H5P_DEFAULT);
    }
    else {
      grp = H5Gcreate(PresentFile, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    }
  }
  else {
    luaL_error(L, "invalid group access mode '%s'\n", mode);
  }

  lua_pushnumber(L, grp);
  return 1;
}
开发者ID:jzrake,项目名称:luview,代码行数:31,代码来源:h5lua.c

示例2: cxi_open_data

CXI_Data * cxi_open_data(CXI_Data_Reference * ref){
  cxi_debug("opening data");
  char buffer[1024];
  if(!ref){
    return NULL;
  }
  CXI_Data * data = calloc(sizeof(CXI_Data),1);
  if(!data){
    return NULL;
  }

  data->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT);
  if(data->handle < 0){
    free(data);
    return NULL;
  }
  ref->data = data;  
  if(H5Lexists(data->handle,"data",H5P_DEFAULT)){
    data->data = calloc(sizeof(CXI_Dataset_Reference),1);
    data->data->parent_handle = data->handle;
    data->data->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
    strcpy(data->data->group_name,"data");          
  }

  if(H5Lexists(data->handle,"errors",H5P_DEFAULT)){
    data->errors = calloc(sizeof(CXI_Dataset_Reference),1);
    data->errors->parent_handle = data->handle;
    data->errors->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
    strcpy(data->errors->group_name,"errors");          
  }
  return data;
}
开发者ID:cxidb,项目名称:libcxi,代码行数:32,代码来源:cxi.c

示例3: read_nvnunrnl

/** read solution sizes */
static int read_nvnunrnl (hid_t file_id, int *nv, int *nr, int *nl)
{
  if (H5Lexists (file_id, "/fclib_global", H5P_DEFAULT))
  {
    IO (H5LTread_dataset_int (file_id, "/fclib_global/M/n", nv));
    IO (H5LTread_dataset_int (file_id, "/fclib_global/H/n", nr));
    if (H5Lexists (file_id, "/fclib_global/G", H5P_DEFAULT))
    {
      IO (H5LTread_dataset_int (file_id, "/fclib_global/G/n", nl));
    }
    else *nl = 0;
  }
  else if (H5Lexists (file_id, "/fclib_local", H5P_DEFAULT))
  {
    *nv = 0;
    IO (H5LTread_dataset_int (file_id, "/fclib_local/W/n", nr));
    if (H5Lexists (file_id, "/fclib_local/R", H5P_DEFAULT))
    {
      IO (H5LTread_dataset_int (file_id, "/fclib_local/R/n", nl));
    }
    else *nl = 0;
  }
  else
  {
    fprintf (stderr, "ERROR: neither global nor local problem has been stored. Global or local have to be stored before solutions or guesses\n");
    return 0;
  }

  return 1;
}
开发者ID:xhub,项目名称:fclib,代码行数:31,代码来源:fclib.c

示例4: cxi_open_image

CXI_Image * cxi_open_image(CXI_Image_Reference * ref){
  cxi_debug("opening image");
  char buffer[1024];
  if(!ref){
    return NULL;
  }
  CXI_Image * image = calloc(sizeof(CXI_Image),1);
  if(!image){
    return NULL;
  }

  image->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT);
  if(image->handle < 0){
    free(image);
    return NULL;
  }

  /* Search for Detector groups */
  int n = find_max_suffix(image->handle, "detector");
  image->detector_count = n;
  image->detectors = calloc(sizeof(CXI_Detector_Reference *),n);
  for(int i = 0;i<n;i++){
    image->detectors[i] = calloc(sizeof(CXI_Detector_Reference),1);
    sprintf(buffer,"detector_%d",i+1);
    image->detectors[i]->parent_handle = image->handle;
    image->detectors[i]->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
    strcpy(image->detectors[i]->group_name,buffer);      
  }

  ref->image = image;  
  if(H5Lexists(image->handle,"data",H5P_DEFAULT)){
    image->data = calloc(sizeof(CXI_Dataset_Reference),1);
    image->data->parent_handle = image->handle;
    image->data->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
    strcpy(image->data->group_name,"data");          
  }

  if(H5Lexists(image->handle,"data_error",H5P_DEFAULT)){
    image->data_error = calloc(sizeof(CXI_Dataset_Reference),1);
    image->data_error->parent_handle = image->handle;
    image->data_error->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
    strcpy(image->data_error->group_name,"data_error");          
  }


  if(H5Lexists(image->handle,"mask",H5P_DEFAULT)){
    image->mask = calloc(sizeof(CXI_Dataset_Reference),1);
    image->mask->parent_handle = image->handle;
    image->mask->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
    strcpy(image->mask->group_name,"mask");      
    
  }

  //  try_read_string(image->handle, "data_space",&image->data_space);
  //  try_read_string(image->handle, "data_type",&image->data_type);
  image->dimensionality_valid = try_read_int(image->handle, "dimensionality",&image->dimensionality);
  image->image_center_valid = try_read_float_array(image->handle, "image_center",image->image_center,3);

  return image;
}
开发者ID:cxidb,项目名称:libcxi,代码行数:60,代码来源:cxi.c

示例5: H5Eset_auto2

/**
   Traverse the path of an object in HDF5 file, checking existence of
   groups in the path and creating them if required.  */
hid_t HDF5DataWriter::getDataset(string path)
{
    if (filehandle_ < 0){
        return -1;
    }
    herr_t status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
    // Create the groups corresponding to this path
    string::size_type lastslash = path.find_last_of("/");
    vector<string> pathTokens;
    moose::tokenize(path, "/", pathTokens);
    hid_t prev_id = filehandle_;
    hid_t id = -1;
    for ( unsigned int ii = 0; ii < pathTokens.size()-1; ++ii ){
        // check if object exists
        htri_t exists = H5Lexists(prev_id, pathTokens[ii].c_str(),
                                  H5P_DEFAULT);
        if (exists > 0){
            // try to open existing group
            id = H5Gopen2(prev_id, pathTokens[ii].c_str(), H5P_DEFAULT);
        } else if (exists == 0) {
            // If that fails, try to create a group
            id = H5Gcreate2(prev_id, pathTokens[ii].c_str(),
                            H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
        }
        if ((exists < 0) || (id < 0)){
            // Failed to open/create a group, print the
            // offending path (for debugging; the error is
            // perhaps at the level of hdf5 or file system).
            cerr << "Error: failed to open/create group: ";
            for (unsigned int jj = 0; jj <= ii; ++jj){
                cerr << "/" << pathTokens[jj];
            }
            cerr << endl;
            prev_id = -1;
        }
        if (prev_id >= 0  && prev_id != filehandle_){
            // Successfully opened/created new group, close the old group
            status = H5Gclose(prev_id);
            assert( status >= 0 );
        }
        prev_id = id;
    }
    string name = pathTokens[pathTokens.size()-1];
    htri_t exists = H5Lexists(prev_id, name.c_str(), H5P_DEFAULT);
    hid_t dataset_id = -1;
    if (exists > 0){
        dataset_id = H5Dopen2(prev_id, name.c_str(), H5P_DEFAULT);
    } else if (exists == 0){
        dataset_id = createDoubleDataset(prev_id, name);
    } else {
        cerr << "Error: H5Lexists returned "
             << exists << " for path \""
             << path << "\"" << endl;
    }
    return dataset_id;
}
开发者ID:hrani,项目名称:moose-core,代码行数:59,代码来源:HDF5DataWriter.cpp

示例6: regn_writes_all

int regn_writes_all() {
  OPEN_WRITE_TEST_FILE;
  int **regions = fixture_regions(5);
  
  int result = (ch5m_regn_set_all(file, 5, regions[0]) == 0);
  
  htri_t exists = H5Lexists(file, CH5_REGN_GROUP_NAME, H5P_DEFAULT);
  if (exists < 1) {
    fprintf(stderr, "Could not find regions main group\n");
    result = 0;
  }
  
  hid_t main_group_id = H5Gopen(file, CH5_REGN_GROUP_NAME, H5P_DEFAULT);
  exists = H5Lexists(main_group_id, CH5_REGN_DSET_NAME, H5P_DEFAULT);
  if (exists < 1) {
    fprintf(stderr, "Could not find regions dataset\n");
    result = 0;
  }
  
  hid_t dset_id = H5Dopen(main_group_id, CH5_REGN_DSET_NAME, H5P_DEFAULT);
  if (dset_id < 0) {
    fprintf(stderr, "Error opening regions dataset\n");
    result = 0;
  }
  
  ch5_dataset dset_info;
  result &= (ch5_gnrc_get_dset_info(file, CH5_REGN_DSET_FULL_PATH, &dset_info) == 0);
  if ((dset_info.count != 5) || (dset_info.width != 2)) {
    fprintf(stderr, "Regions dataset dimensions incorrect (%d,%d)\n",
      dset_info.count, dset_info.width);
    result = 0;
  }
  
  int read_regions[5 * 2];
  herr_t status = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
    H5P_DEFAULT, read_regions);
  if (status < 0) {
    fprintf(stderr, "Regions reading failed\n");
    result = 0;
  }
  
  if (int_arrays_same(regions[0], read_regions, 5 * 2) == 0) {
    fprintf(stderr, "Regions data incorrect\n");
    result = 0;
  }
  
  H5Dclose(dset_id);
  H5Gclose(main_group_id);
  fixture_free_regions(regions);
  
  CLOSE_WRITE_TEST_FILE;
  
  return result;
}
开发者ID:cardiosolv,项目名称:meshalyzer,代码行数:54,代码来源:test_regions.c

示例7: fclib_read_local

/** read local problem;
 * return problem on success; NULL on failure */
struct fclib_local* fclib_read_local (const char *path)
{
  struct fclib_local *problem;
  hid_t  file_id, main_id, id;

  if ((file_id = H5Fopen (path, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
  {
    fprintf (stderr, "ERROR: opening file failed\n");
    return NULL;
  }

  if (!H5Lexists (file_id, "/fclib_local", H5P_DEFAULT))
  {
    fprintf (stderr, "ERROR: spurious input file %s :: fclib_local group does not exists", path);
    return NULL;
  }

  MM (problem = calloc (1, sizeof (struct fclib_local)));

  IO (main_id = H5Gopen (file_id, "/fclib_local", H5P_DEFAULT));
  IO (H5LTread_dataset_int (file_id, "/fclib_local/spacedim", &problem->spacedim));

  IO (id = H5Gopen (file_id, "/fclib_local/W", H5P_DEFAULT));
  problem->W = read_matrix (id);
  IO (H5Gclose (id));

  if (H5Lexists (file_id, "/fclib_local/V", H5P_DEFAULT))
  {
    IO (id = H5Gopen (file_id, "/fclib_local/V", H5P_DEFAULT));
    problem->V = read_matrix (id);
    IO (H5Gclose (id));

    IO (id = H5Gopen (file_id, "/fclib_local/R", H5P_DEFAULT));
    problem->R = read_matrix (id);
    IO (H5Gclose (id));
  }

  IO (id = H5Gopen (file_id, "/fclib_local/vectors", H5P_DEFAULT));
  read_local_vectors (id, problem);
  IO (H5Gclose (id));

  if (H5Lexists (file_id, "/fclib_local/info", H5P_DEFAULT))
  {
    IO (id = H5Gopen (file_id, "/fclib_local/info", H5P_DEFAULT));
    problem->info = read_problem_info (id);
    IO (H5Gclose (id));
  }

  IO (H5Gclose (main_id));
  IO (H5Fclose (file_id));

  return problem;
}
开发者ID:xhub,项目名称:fclib,代码行数:55,代码来源:fclib.c

示例8: AH5_path_valid

// Check for path validity
char AH5_path_valid(hid_t loc_id, const char *path)
{
  char *temp;
  int i, slashes = 0;

  temp = strdup(path);
  for (i = (int) strlen(path); i > 0; i--)
  {
    if (temp[i] == '/')
    {
      temp[i] = '\0';
      slashes++;  /* count number of slashes excluding the first one */
    }
  }

  if (strcmp(path, ".") == 0)
  {
    if (!H5Iis_valid(loc_id))
    {
      free(temp);
      return AH5_FALSE;
    }
  }
  else
  {
    if(H5Lexists(loc_id, temp, H5P_DEFAULT) != AH5_TRUE)
    {
      free(temp);
      return AH5_FALSE;
    }
  }

  i = 1;
  while (slashes > 0)
  {
    while (temp[i] != '\0')
      i++;
    temp[i] = '/';
    slashes--;
    if(H5Lexists(loc_id, temp, H5P_DEFAULT) != AH5_TRUE)
    {
      free(temp);
      return AH5_FALSE;
    }
  }
  free(temp);
  return AH5_TRUE;
}
开发者ID:axessim,项目名称:amelethdf-c,代码行数:49,代码来源:ah5_general.c

示例9: checkExist

char HDocument::checkExist(const std::string & path)
{
	if(!H5Lexists(fFileId, path.c_str(), H5P_DEFAULT))
		return 0;
		
	return 1;
}
开发者ID:spinos,项目名称:aphid,代码行数:7,代码来源:HDocument.cpp

示例10: H5Lexists_safe

int H5Lexists_safe(hid_t base, char *path)
// -----------------------------------------------------------------------------
// The HDF5 specification only allows H5Lexists to be called on an immediate
// child of the current object. However, you may wish to see whether a whole
// relative path exists, returning false if any of the intermediate links are
// not present. This function does that.
// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-Exists
// -----------------------------------------------------------------------------
{
  hid_t last = base, next;
  char *pch;
  char pathc[2048];
  strcpy(pathc, path);
  pch = strtok(pathc, "/");
  while (pch != NULL) {
    int exists = H5Lexists(last, pch, H5P_DEFAULT);
    if (!exists) {
      if (last != base) H5Gclose(last);
      return 0;
    }
    else {
      next = H5Gopen(last, pch, H5P_DEFAULT);
      if (last != base) H5Gclose(last);
      last = next;
    }
    pch = strtok(NULL, "/");
  }
  if (last != base) H5Gclose(last);
  return 1;
}
开发者ID:geoffryan,项目名称:calvis,代码行数:30,代码来源:hist.c

示例11: ObjectExists

//-*****************************************************************************
bool ObjectExists( H5Node& iParent, const std::string &iName )
{
    ABCA_ASSERT( iParent.isValidObject(),
                 "Invalid parent node passed into HDF5Util GroupExists: "
                 << iName << std::endl );

    HDF5Hierarchy* H5HPtr = iParent.getH5HPtr();

    if ( H5HPtr )
    {
        return H5HPtr->childExists( iParent.getRef(), iName );
    }
    else
    {
        // First, check to make sure the link exists.
        hid_t iParentObject = iParent.getObject();

        htri_t exi = H5Lexists( iParentObject, iName.c_str(), H5P_DEFAULT );
        if ( exi < 1 )
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}
开发者ID:AWhetter,项目名称:alembic,代码行数:29,代码来源:HDF5Util.cpp

示例12: DatasetExists

//-*****************************************************************************
bool DatasetExists( hid_t iParent, const std::string &iName )
{
    ABCA_ASSERT( iParent >= 0, "Invalid Parent in DatasetExists" );
    
    // First, check to make sure the link exists.
    htri_t exi = H5Lexists( iParent, iName.c_str(), H5P_DEFAULT );
    if ( exi < 1 )
    {
        return false;
    }
    
    // Now make sure it is a group.
    H5O_info_t oinfo;
    herr_t status = H5Oget_info_by_name( iParent,
                                         iName.c_str(), &oinfo,
                                         H5P_DEFAULT );
    if ( status < 0 )
    {
        return false;
    }
    
    if ( oinfo.type != H5O_TYPE_DATASET )
    {
        return false;
    }

    return true;
}
开发者ID:ryutaro765,项目名称:Alembic,代码行数:29,代码来源:HDF5Util.cpp

示例13: path_

hdf5_dataset::hdf5_dataset(
    hdf5_file const& file,
    std::string const& path
)
    :
      path_(path)
{
    // Check if name exists in this file.
    htri_t status = H5Lexists(file.get_id(), path.c_str(), H5P_DEFAULT);
    if(status > 0) { // Full path exists.
        // Attempt to open it as a dataset
        set_id(H5Dopen2(file.get_id(), path.c_str(), H5P_DEFAULT));
        if(get_id() < 0) {
            boost::serialization::throw_exception(
                hdf5_archive_exception(
                    hdf5_archive_exception::hdf5_archive_dataset_access_error,
                    path.c_str()
                )
            );
        }
    }
    else { // path does not exist, or other error
        boost::serialization::throw_exception(
            hdf5_archive_exception(
                hdf5_archive_exception::hdf5_archive_bad_path_error,
                path.c_str()
            )
        );
    }
}
开发者ID:warn-naught,项目名称:serialization,代码行数:30,代码来源:hdf5_dataset.cpp

示例14: H5Object

H5Link::H5Link(H5Object & _parent, const std::string & _name) : H5Object(_parent, _name)
{
    if (H5Lexists(_parent.getH5Id(), name.c_str(), H5P_DEFAULT) <= 0)
    {
        throw H5Exception(__LINE__, __FILE__, _("The link %s does not exist."), name.c_str());
    }
}
开发者ID:ZhanlinWang,项目名称:scilab,代码行数:7,代码来源:H5Link.cpp

示例15: throw

    void DCDataSet::createReference(hid_t refGroup,
            hid_t srcGroup,
            DCDataSet &srcDataSet)
    throw (DCException)
    {
        if (opened)
            throw DCException(getExceptionString("createReference: dataset is already open"));

        if (checkExistence && H5Lexists(refGroup, name.c_str(), H5P_LINK_ACCESS_DEFAULT))
            throw DCException(getExceptionString("createReference: this reference already exists"));

        getLogicalSize().set(srcDataSet.getLogicalSize());
        this->ndims = srcDataSet.getNDims();

        if (H5Rcreate(&regionRef, srcGroup, srcDataSet.getName().c_str(), H5R_OBJECT, -1) < 0)
            throw DCException(getExceptionString("createReference: failed to create region reference"));

        hsize_t ndims = 1;
        dataspace = H5Screate_simple(1, &ndims, NULL);
        if (dataspace < 0)
            throw DCException(getExceptionString("createReference: failed to create dataspace for reference"));

        dataset = H5Dcreate(refGroup, name.c_str(), H5T_STD_REF_OBJ,
                dataspace, H5P_DEFAULT, dsetProperties, H5P_DEFAULT);

        if (dataset < 0)
            throw DCException(getExceptionString("createReference: failed to create dataset for reference"));

        if (H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL,
                dsetWriteProperties, &regionRef) < 0)
            throw DCException(getExceptionString("createReference: failed to write reference"));

        isReference = true;
        opened = true;
    }
开发者ID:c-schumann-zih,项目名称:libSplash,代码行数:35,代码来源:DCDataSet.cpp


注:本文中的H5Lexists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。