[svn-r8818]

Purpose:  Potential bug fix

Description:  In H5Fget_filesize, file size was returned as haddr_t.  Change it to hsize_t
and return it as parameter to make fortran interface easier.


Platforms tested:  fuss(simple change).
This commit is contained in:
Raymond Lu 2004-07-07 12:03:02 -05:00
parent faa845f84b
commit c949e7c391
3 changed files with 23 additions and 20 deletions

View File

@ -4714,7 +4714,7 @@ done:
* is called after an existing file is opened in order
* to learn the true size of the underlying file.
*
* Return: Success: File size
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: David Pitt
@ -4725,22 +4725,25 @@ done:
*
*-------------------------------------------------------------------------
*/
haddr_t
H5Fget_filesize(hid_t file_id)
herr_t
H5Fget_filesize(hid_t file_id, hsize_t *size)
{
H5F_t *file=NULL; /* File object for file ID */
haddr_t ret_value; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */
haddr_t eof;
FUNC_ENTER_API(H5Fget_filesize, HADDR_UNDEF)
H5TRACE1("a","i",file_id);
FUNC_ENTER_API(H5Fget_filesize, FAIL)
H5TRACE2("e","i*h",file_id,size);
/* Check args */
if(NULL==(file=H5I_object_verify(file_id, H5I_FILE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "not a file ID")
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
/* Go get the actual file size */
if((ret_value = H5FDget_eof(file->shared->lf))==HADDR_UNDEF)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, HADDR_UNDEF, "unable to get file size")
if((eof = H5FDget_eof(file->shared->lf))==HADDR_UNDEF)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size")
*size = (hsize_t)eof;
done:
FUNC_LEAVE_API(ret_value)

View File

@ -113,7 +113,7 @@ 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);
H5_DLL haddr_t H5Fget_filesize(hid_t file_id);
H5_DLL herr_t H5Fget_filesize(hid_t file_id, hsize_t *size);
H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size);
#ifdef __cplusplus

View File

@ -62,7 +62,7 @@ test_sec2(void)
hid_t file=(-1), fapl, access_fapl = -1;
char filename[1024];
int *fhandle=NULL;
haddr_t file_size;
hsize_t file_size;
TESTING("SEC2 file driver");
@ -90,7 +90,7 @@ test_sec2(void)
goto error;
/* Check file size API */
if((file_size = H5Fget_filesize(file)) <= 0)
if(H5Fget_filesize(file, &file_size) < 0)
goto error;
/* There is no garantee the size of metadata in file is constant.
@ -140,7 +140,7 @@ test_core(void)
hid_t file=(-1), fapl, access_fapl = -1;
char filename[1024];
void *fhandle=NULL;
haddr_t file_size;
hsize_t file_size;
TESTING("CORE file driver");
@ -170,7 +170,7 @@ test_core(void)
}
/* Check file size API */
if((file_size = H5Fget_filesize(file)) <= 0)
if(H5Fget_filesize(file, &file_size) < 0)
goto error;
/* There is no garantee the size of metadata in file is constant.
@ -225,7 +225,7 @@ test_family(void)
int *fhandle=NULL, *fhandle2=NULL;
int buf[FAMILY_NUMBER][FAMILY_SIZE];
hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE};
haddr_t file_size;
hsize_t file_size;
TESTING("FAMILY file driver");
@ -239,7 +239,7 @@ test_family(void)
goto error;
/* Check file size API */
if((file_size = H5Fget_filesize(file)) <= 0)
if(H5Fget_filesize(file, &file_size) < 0)
goto error;
/* The file size is supposed to be 2KB right now. */
@ -286,7 +286,7 @@ test_family(void)
goto error;
/* Check file size API */
if((file_size = H5Fget_filesize(file)) <= 0)
if(H5Fget_filesize(file, &file_size) < 0)
goto error;
/* Some data has been written. The file size should be bigger(4KB) now. */
@ -344,7 +344,7 @@ test_multi(void)
hid_t access_fapl = -1;
char filename[1024];
int *fhandle2=NULL, *fhandle=NULL;
haddr_t file_size;
hsize_t file_size;
H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES];
hid_t memb_fapl[H5FD_MEM_NTYPES];
haddr_t memb_addr[H5FD_MEM_NTYPES];
@ -399,7 +399,7 @@ test_multi(void)
goto error;
/* Check file size API */
if((file_size = H5Fget_filesize(file)) <= 0)
if(H5Fget_filesize(file, &file_size) < 0)
goto error;
/* Before any data is written, the raw data file is empty. So
@ -435,7 +435,7 @@ test_multi(void)
goto error;
/* Check file size API */
if((file_size = H5Fget_filesize(file)) <= 0)
if(H5Fget_filesize(file, &file_size) < 0)
goto error;
/* After the data is written, the file size is huge because the