diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 1997-08-15 14:36:27 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 1997-08-15 14:36:27 (GMT) |
commit | 876badec3f143c1ca90f240c02e09e54b1b20608 (patch) | |
tree | 482b5859f061f4a1bbe8e6d52989e2ee34a9d16f | |
parent | 2339599b7c98ac329e7baa28b6d657e98771d768 (diff) | |
download | hdf5-876badec3f143c1ca90f240c02e09e54b1b20608.zip hdf5-876badec3f143c1ca90f240c02e09e54b1b20608.tar.gz hdf5-876badec3f143c1ca90f240c02e09e54b1b20608.tar.bz2 |
[svn-r30] Intermediate checkin of (non-working) dataset code to allow for source code
rearrangement.
-rw-r--r-- | src/H5D.c | 81 | ||||
-rw-r--r-- | src/H5F.c | 72 | ||||
-rw-r--r-- | src/H5Fprivate.h | 4 | ||||
-rw-r--r-- | src/H5Fproto.h | 9 | ||||
-rw-r--r-- | src/H5G.c | 1 | ||||
-rw-r--r-- | src/H5Mprivate.h | 16 |
6 files changed, 170 insertions, 13 deletions
@@ -96,7 +96,10 @@ hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); /* Initialize the dimensionality object */ - /* new_dset->file=? */ + if(H5Aatom_group(owner_id)==H5_FILE) + new_dset->file=owner_id; + else + new_dset->file=owner_id; new_dset->parent=owner_id; /* set the owner's ID */ new_dset->name=HDstrdup(name); /* make a copy of the dataset name */ new_dset->modified=BTRUE; /* Yep, we're new... */ @@ -235,6 +238,67 @@ done: /*-------------------------------------------------------------------------- NAME + H5D_flush + PURPOSE + Flush an an HDF5 dataset object to disk. + USAGE + herr_t H5D_flush(oid) + hatom_t oid; IN: Object to flush to disk + RETURNS + SUCCEED/FAIL + DESCRIPTION + This function flushes a dataset to disk. (i.e. makes the disk version + agree with what's in memory, it does _not_ update the memory version with + any changes on disk) +--------------------------------------------------------------------------*/ +herr_t H5D_flush(hatom_t oid) +{ + H5D_dataset_t *dataset; /* dataset object to release */ + H5F_ + herr_t ret_value = SUCCEED; + + FUNC_ENTER(H5D_flush, H5D_init_interface, FAIL); + + /* Clear errors and check args and all the boring stuff. */ + H5ECLEAR; + + /* Get the object */ + if((dataset=H5Aatom_object(oid))==NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + /* Check if we have information to flush to the file... */ + if(dataset->modified==BTRUE) + { + /* Check if we need to create the dataset header and insert the dataset in the file's hierarchy */ + if(dataset->header==0) + { + H5F_root_symtype_t root_type=H5F_root_type(dataset->file); + + /* Flush object header, etc. to the file... */ + if(root_type==H5F_ROOT_ERROR) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL); + if(root_type==H5F_ROOT_DATASET || H5F_ROOT_UNKNOWN) + { + } /* end if */ + else + { + if(root_type + } /* end if */ + } /* end if */ + } /* end if */ + +done: + if(ret_value == FAIL) + { /* Error condition cleanup */ + + } /* end if */ + + /* Normal function cleanup */ + + FUNC_LEAVE(ret_value); +} /* end H5D_flush() */ + +/*-------------------------------------------------------------------------- + NAME H5D_release PURPOSE Release access to an HDF5 dataset object. @@ -256,18 +320,23 @@ herr_t H5D_release(hatom_t oid) /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; - /* Chuck the object! :-) */ - if((dataset=H5Aremove_atom(oid))==NULL) + /* Get the dataset so we can check for changes and release it */ + if((dataset=H5Aatom_object(oid))==NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + /* Check if we have information to flush to the file... */ if(dataset->modified==BTRUE) - { - /* Flush object header, etc. to the file... */ - } /* end if */ + H5D_flush(oid); + + /* relase the memory used for the dataset */ if(dataset->name!=NULL) HDfree(dataset->name); HDfree(dataset); + /* Delete the dataset from the atom group */ + if(H5Aatom_object(oid)==NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + done: if(ret_value == FAIL) { /* Error condition cleanup */ @@ -338,6 +338,7 @@ H5F_new (void) /* Create a root symbol slot */ f->root_sym = H5MM_xcalloc (1, sizeof (H5G_entry_t)); f->root_sym->type = H5G_NOTHING_CACHED; + f->root_type=H5F_ROOT_NONE; return f; } @@ -670,7 +671,7 @@ hatom_t H5Fopen(const char *filename, uintn flags, hatom_t access_temp) else curr_off*=2; } /* end while */ - if(curr_off>file_len) + if(curr_off>file_len) /* Why didn't H5Fis_hdf5 catch this? */ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL); /* Read in the fixed-size part of the boot-block */ @@ -709,6 +710,8 @@ hatom_t H5Fopen(const char *filename, uintn flags, hatom_t access_temp) if (H5G_decode (new_file, &p, new_file->root_sym)<0) { HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL); } + /* Set the initial type of the root symbol-entry */ + new_file->root_type= (new_file->root_sym->addr>=0) ? H5F_ROOT_UNKNOWN : H5F_NONE; /* Get an atom for the file */ if((ret_value=H5Aregister_atom(H5_FILE, new_file))==FAIL) @@ -771,12 +774,12 @@ herr_t H5Fclose(hatom_t fid) { H5AC_flush (file, NULL, 0, TRUE); if(file->file_handle!=H5F_INVALID_FILE) { - H5F_CLOSE(file->file_handle); - } - H5F_dest (file); + H5F_CLOSE(file->file_handle); + } + H5F_dest (file); if(H5Aremove_atom(fid)==NULL) { - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); - } + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + } } /* end if */ done: @@ -789,6 +792,63 @@ done: FUNC_LEAVE(ret_value); } /* end H5Fclose() */ +/*-------------------------------------------------------------------------- + NAME + H5F_root_type + PURPOSE + Check the type of the root symbol-entry for a file. + USAGE + H5F_root_symtype_t_ H5F_root_type(fid) + int32 fid; IN: File ID of file to query + RETURNS + Returns root symbol type on success, H5F_ROOT_ERROR on failure. + DESCRIPTION + This function retrieves the type of symbol-entry the root object in the + file describes. Legimate values are: + H5F_ROOT_NONE - Root-symbol table is empty, neither a dataset nor a directory is the root object + H5F_ROOT_UNKNOWN - Don't know (yet) if the root object is a dataset or a directory + H5F_ROOT_DATASET - Root object is a dataset + H5F_ROOT_DIRECTORY - Root object is a directory + + This function is designed for internal use and should be modified to + not return H5F_ROOT_UNKNOWN if it is made part of the public API. + + ERRORS + H5E_ARGS - H5E_BADTYPE - Argument checking + H5E_ATOM - H5E_BADATOM - Can't get the object for an atom + MODIFICATIONS: + Quincey Koziol, 13 Aug 1997 +--------------------------------------------------------------------------*/ +H5F_root_symtype_t H5F_root_type(hatom_t fid) +{ + hdf5_file_t *f=NULL; /* file struct for new file */ + H5F_root_symtype_t ret_value = H5F_ROOT_ERROR; + + FUNC_ENTER(H5F_root_type, H5F_init_interface, H5F_ROOT_ERROR); + + /* Clear errors and check args and all the boring stuff. */ + H5ECLEAR; + if(H5Aatom_group(fid)!=H5_FILE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL); + + /* Get the file handle to close */ + if((f=H5Aatom_object(fid))==NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + + ret_value=f->root_type; + +done: + if(ret_value == H5F_ROOT_ERROR) + { /* Error condition cleanup */ + + } + + /* Normal function cleanup */ + + FUNC_LEAVE(ret_value); +} /* end H5F_root_type() */ + + /*------------------------------------------------------------------------- * Function: H5F_block_read diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 8654920..eebb55d 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -27,7 +27,7 @@ /*** packages! ***/ /*****************************************/ -/* Maximum size of boot-block */ +/* Maximum size of boot-block buffer */ #define H5F_BOOTBLOCK_SIZE 1024 @@ -51,6 +51,7 @@ typedef struct { file_access_temp_t file_access_parms; /* File-access template parameters */ #endif /* LATER */ struct H5G_entry_t *root_sym; /* Extra for the root symbol in the file */ + H5F_root_symtype_t root_type; /* What kind of symbol is the root? */ } hdf5_file_t; @@ -96,6 +97,7 @@ typedef struct { void H5F_encode_length_unusual(const hdf5_file_t *f, uint8 **p, uint8 *l); void H5F_encode_offset_unusual(const hdf5_file_t *f, uint8 **p, uint8 *o); intn H5F_compare_filename(const VOIDP obj, const VOIDP key); +H5F_root_symtype_t H5F_root_type(hatom_t fid); herr_t H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf); herr_t H5F_block_write (hdf5_file_t *f, haddr_t addr, size_t size, void *buf); herr_t H5F_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, diff --git a/src/H5Fproto.h b/src/H5Fproto.h index 7236bdd..8872d8d 100644 --- a/src/H5Fproto.h +++ b/src/H5Fproto.h @@ -23,6 +23,15 @@ #define H5ACC_WRITE 0x0001 /* User in H5Fopen to open a file with write access */ #define H5ACC_OVERWRITE 0x0002 /* User in H5Fcreate truncate an existing file */ +/* Type of root rymbol-table entry */ +typedef enum { + H5F_ROOT_NONE=0, /* Root-symbol table is empty, neither a dataset nor a directory is the root object */ + H5F_ROOT_UNKNOWN, /* Don't know if the root object is a dataset or a directory */ + H5F_ROOT_DATASET, /* Root object is a dataset */ + H5F_ROOT_DIRECTORY, /* Root object is a directory */ + H5F_ROOT_ERROR /* Error value */ + } H5F_root_symtype_t; + /* * If we're using POSIXUNBUFIO and lseek64() is available, then use * 64-bit file offsets. Otherwise use whatever `off_t' is. @@ -331,6 +331,7 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) } H5O_reset (H5O_NAME, &name); } + f->root_type=H5F_ROOT_DIRECTORY; /* set the root symbol type be a directory */ FUNC_LEAVE (SUCCEED); } diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h index b97548b..927e956 100644 --- a/src/H5Mprivate.h +++ b/src/H5Mprivate.h @@ -93,6 +93,22 @@ meta_func_t meta_func_arr[]={ NULL, /* Dimensionality Delete */ NULL, /* Dimensionality GetParent */ H5P_release /* Dimensionality Release */ + }, + { /* Dataset object meta-functions (defined in H5D.c) */ + H5_DATASPACE, /* Dataset Type ID */ + H5D_create, /* Dataset Create */ + NULL, /* Dataset Access */ + NULL, /* Dataset Copy */ + NULL, /* Dataset FindName */ + NULL, /* Dataset NameLen */ + NULL, /* Dataset GetName */ + NULL, /* Dataset SetName */ + NULL, /* Dataset Search */ + NULL, /* Dataset Index */ + H5D_flush, /* Dataset Flush */ + NULL, /* Dataset Delete */ + NULL, /* Dataset GetParent */ + H5D_release /* Dataset Release */ } }; |