diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-10-07 13:32:32 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-10-07 13:32:32 (GMT) |
commit | f766b32d07fae4562e95b9166255c35c8f3e467a (patch) | |
tree | 59aa2706ca5c91e1ac4c314a9de9b48f8979dc40 /src | |
parent | 259247fc328fa17b705fc16ab8e004d8c5814ea8 (diff) | |
download | hdf5-f766b32d07fae4562e95b9166255c35c8f3e467a.zip hdf5-f766b32d07fae4562e95b9166255c35c8f3e467a.tar.gz hdf5-f766b32d07fae4562e95b9166255c35c8f3e467a.tar.bz2 |
[svn-r7559] Purpose:
Add feature
Description:
Add H5Fget_freespace() routine, to check the amount of free space in a
file. This information is only valid until the file is closed currently,
however (until we start recording the free space information in the file
itself).
Platforms tested:
FreeBSD 4.9 (sleipnir)
h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 39 | ||||
-rw-r--r-- | src/H5FD.c | 47 | ||||
-rw-r--r-- | src/H5FDprivate.h | 1 | ||||
-rw-r--r-- | src/H5Fpublic.h | 1 |
4 files changed, 88 insertions, 0 deletions
@@ -4498,3 +4498,42 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_sieve_overlap_clear() */ + +/*------------------------------------------------------------------------- + * Function: H5Fget_freespace + * + * Purpose: Retrieves the amount of free space (of a given type) in the + * file. If TYPE is 'H5FD_MEM_DEFAULT', then the amount of free + * space for all types is returned. + * + * Return: Success: Amount of free space for type + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Oct 6, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hssize_t +H5Fget_freespace(hid_t file_id) +{ + H5F_t *file=NULL; /* File object for file ID */ + hssize_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5Fget_freespace, FAIL) + + /* Check args */ + if(NULL==(file=H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + + /* Go get the actual amount of free space in the file */ + if((ret_value = H5FD_get_freespace(file->shared->lf))<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fget_freespace() */ + @@ -3372,3 +3372,50 @@ herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle) done: FUNC_LEAVE_NOAPI(ret_value) } + + +/*------------------------------------------------------------------------- + * Function: H5FD_get_freespace + * + * Purpose: Retrieve the amount of free space in a file. + * + * Return: Success: Amount of free space in file + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, October 6, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hssize_t +H5FD_get_freespace(H5FD_t *file) +{ + H5FD_free_t *free_node; /* Pointer to node on free list */ + H5FD_mem_t type; /* Type of memory */ + hssize_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5FD_get_freespace, FAIL) + + /* check args */ + assert(file); + assert(file->cls); + + /* Initialize return value */ + ret_value=0; + + /* Iterate over all the types of memory, to retrieve amount of free space for each */ + for (type=H5FD_MEM_DEFAULT; type<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,type)) { + /* Iterate through the free list, accumulating the amount of free space for this type */ + free_node = file->fl[type]; + while(free_node) { + ret_value+=free_node->size; + free_node=free_node->next; + } /* end while */ + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_get_freespace() */ + diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 2df3072..4f1785c 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -69,5 +69,6 @@ H5_DLL herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t a H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing); H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle); +H5_DLL hssize_t H5FD_get_freespace(H5FD_t *file); #endif /* !_H5FDprivate_H */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 02fd70b..431f9bc 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -112,6 +112,7 @@ H5_DLL int H5Fget_obj_ids(hid_t file_id, unsigned types, int max_objs, hid_t *ob H5_DLL herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void** file_handle); H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist); H5_DLL herr_t H5Funmount(hid_t loc, const char *name); +H5_DLL hssize_t H5Fget_freespace(hid_t file_id); #ifdef __cplusplus } |