summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2004-07-07 18:04:16 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2004-07-07 18:04:16 (GMT)
commit2afbcb2f0e536dfdd00c405278154ea4464d866b (patch)
tree289c75ed09e8adee11474db2bf39698c4ccc16bb
parentc889f67f9c3650e0b3008e0c3ab98bf01c078500 (diff)
downloadhdf5-2afbcb2f0e536dfdd00c405278154ea4464d866b.zip
hdf5-2afbcb2f0e536dfdd00c405278154ea4464d866b.tar.gz
hdf5-2afbcb2f0e536dfdd00c405278154ea4464d866b.tar.bz2
[svn-r8819] Purpose: Potential bug fix
Description: In H5Fget_filesize, file size was returned as haddr_t. Solution: Return file size as hsize_t and parameter for Fortran. Platforms tested: eirene
-rw-r--r--c++/src/H5File.cpp10
-rw-r--r--c++/src/H5File.h2
-rw-r--r--c++/test/tfile.cpp5
-rw-r--r--src/H5F.c19
-rw-r--r--src/H5Fpublic.h2
-rw-r--r--test/file_handle.c25
6 files changed, 32 insertions, 31 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index cced607..f44d6f0 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -175,14 +175,16 @@ FileAccPropList H5File::getAccessPlist() const
// is called after an existing file is opened in order
// to learn the true size of the underlying file.
// (Raymond Lu)
-haddr_t H5File::getFileSize(void) const
+herr_t H5File::getFileSize(hsize_t *size) const
{
- haddr_t file_size = H5Fget_filesize(id);
- if( file_size < 0 )
+ herr_t ret;
+
+ ret = H5Fget_filesize(id, size);
+ if( ret < 0 )
{
throw FileIException("H5File::getFileSize", "H5Fget_filesize failed");
}
- return file_size;
+ return ret;
}
// Calls the C API H5Fclose to close this file. Used by IdComponent::reset
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index 82615df..d1fe153 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -51,7 +51,7 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
void reopen();
// Retrieves the file size of an opened file.
- haddr_t getFileSize() const;
+ herr_t getFileSize(hsize_t *size) const;
// Gets the creation property list of this file
FileCreatPropList getCreatePlist() const;
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index 47d06f7..c756e2f 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -350,8 +350,9 @@ test_file_size(void)
H5File fid( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
// Get file size
- haddr_t file_size = fid.getFileSize();
- CHECK(file_size, FAIL, "H5File::getFileSize");
+ hsize_t file_size;
+ herr_t ret = fid.getFileSize(&file_size);
+ CHECK(ret, FAIL, "H5File::getFileSize");
// Check if file size is reasonable. It's supposed to be 2KB now.
if(file_size<1*KB || file_size>4*KB)
diff --git a/src/H5F.c b/src/H5F.c
index 33e89bc..d220933 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -4679,22 +4679,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)
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index c372130..c83f12e 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -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
diff --git a/test/file_handle.c b/test/file_handle.c
index ec9362c..787ce83 100644
--- a/test/file_handle.c
+++ b/test/file_handle.c
@@ -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,18 +170,13 @@ 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.
* Just try to check if it's reasonable. Currently, this file size
* is 976.
*/
-
-
-
-
-
if(file_size<KB/2 || file_size>1*KB)
goto error;
@@ -231,7 +226,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");
@@ -245,7 +240,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. */
@@ -292,7 +287,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. */
@@ -350,7 +345,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];
@@ -405,7 +400,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
@@ -441,7 +436,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