summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-10-26 20:09:29 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-10-26 20:09:29 (GMT)
commited6e5dd6dcde54d16569fc28f8b062bac81fb81a (patch)
tree3a131d220d13a6e68f4cd3f7971befbda91d723d /src/H5F.c
parentacab18c8ded316c7c22680757fd55b2b2d3745d3 (diff)
downloadhdf5-ed6e5dd6dcde54d16569fc28f8b062bac81fb81a.zip
hdf5-ed6e5dd6dcde54d16569fc28f8b062bac81fb81a.tar.gz
hdf5-ed6e5dd6dcde54d16569fc28f8b062bac81fb81a.tar.bz2
[svn-r9460] Purpose:
Code cleanup & optimization Description: Bring back new metadata cache code from development branch. Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel Solaris 2.7 (arabica) Linux 2.4 (heping) w/C++ & FORTRAN
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c638
1 files changed, 319 insertions, 319 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 1de663c..c68c83b 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -2590,7 +2590,7 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags)
} /* end if */
/* flush (and invalidate) the entire meta data cache */
- if (H5AC_flush(f, dxpl_id, NULL, HADDR_UNDEF, flags & (H5F_FLUSH_INVALIDATE|H5F_FLUSH_CLEAR_ONLY)) < 0)
+ if (H5AC_flush(f, dxpl_id, flags & (H5F_FLUSH_INVALIDATE|H5F_FLUSH_CLEAR_ONLY)) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush meta data cache");
} /* end if */
@@ -2987,9 +2987,9 @@ H5F_close(H5F_t *f)
/* Only flush at this point if the file will be closed */
if (closing) {
/* Dump debugging info */
-#ifdef H5AC_DEBUG
- H5AC_debug(f);
-#endif /* H5AC_DEBUG */
+#if H5AC_DUMP_STATS_ON_CLOSE
+ H5AC_stats(f);
+#endif /* H5AC_DUMP_STATS_ON_CLOSE */
/* Only try to flush the file if it was opened with write access */
if(f->intent&H5F_ACC_RDWR) {
@@ -3952,6 +3952,216 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5F_get_id
+ *
+ * Purpose: Get the file ID, incrementing it, or "resurrecting" it as
+ * appropriate.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Raymond Lu
+ * Oct 29, 2003
+ *
+ * Modifications:
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5F_get_id(H5F_t *file)
+{
+ hid_t ret_value;
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_get_id)
+
+ assert(file);
+
+ if(file->file_id == -1) {
+ if(H5I_remove(file->closing)==NULL)
+ HGOTO_ERROR(H5E_ATOM, H5E_READERROR, FAIL, "unable to remove from closing list")
+
+ /* Get an atom for the file */
+ if ((file->file_id = H5I_register(H5I_FILE, file))<0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file")
+
+ /* Indicate file is not closing */
+ file->closing = 0;
+ } else {
+ /* Increment reference count on atom. */
+ if (H5I_inc_ref(file->file_id)<0)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed");
+ }
+
+ ret_value = file->file_id;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_get_id() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_get_base_addr
+ *
+ * Purpose: Quick and dirty routine to retrieve the file's 'base_addr' value
+ * (Mainly added to stop non-file routines from poking about in the
+ * H5F_t data structure)
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Raymond Lu <slu@ncsa.uiuc.edu>
+ * December 20, 2002
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+haddr_t
+H5F_get_base_addr(const H5F_t *f)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_base_addr)
+
+ assert(f);
+ assert(f->shared);
+
+ FUNC_LEAVE_NOAPI(f->shared->base_addr)
+} /* end H5F_get_base_addr() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_get_eoa
+ *
+ * Purpose: Quick and dirty routine to retrieve the file's 'eoa' value
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * June 1, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+haddr_t
+H5F_get_eoa(const H5F_t *f)
+{
+ haddr_t ret_value;
+
+ FUNC_ENTER_NOAPI(H5F_get_eoa, HADDR_UNDEF)
+
+ assert(f);
+ assert(f->shared);
+
+ /* Dispatch to driver */
+ if (HADDR_UNDEF==(ret_value=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_get_eoa() */
+
+#ifdef H5_HAVE_PARALLEL
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_mpi_get_rank
+ *
+ * Purpose: Retrieves the rank of an MPI process.
+ *
+ * Return: Success: The rank (non-negative)
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Friday, January 30, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5F_mpi_get_rank(const H5F_t *f)
+{
+ int ret_value;
+
+ FUNC_ENTER_NOAPI(H5F_mpi_get_rank, FAIL)
+
+ assert(f && f->shared);
+
+ /* Dispatch to driver */
+ if ((ret_value=H5FD_mpi_get_rank(f->shared->lf))<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_mpi_get_rank() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_mpi_get_comm
+ *
+ * Purpose: Retrieves the file's communicator
+ *
+ * Return: Success: The communicator (non-negative)
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Friday, January 30, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+MPI_Comm
+H5F_mpi_get_comm(const H5F_t *f)
+{
+ MPI_Comm ret_value;
+
+ FUNC_ENTER_NOAPI(H5F_mpi_get_comm, MPI_COMM_NULL)
+
+ assert(f && f->shared);
+
+ /* Dispatch to driver */
+ if ((ret_value=H5FD_mpi_get_comm(f->shared->lf))==MPI_COMM_NULL)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_mpi_get_comm() */
+#endif /* H5_HAVE_PARALLEL */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_grp_btree_shared
+ *
+ * Purpose: Replaced a macro to retrieve the shared B-tree node info
+ * now that the generic properties are being used to store
+ * the values.
+ *
+ * Return: Success: Non-void, and the shared B-tree node info
+ * is returned.
+ *
+ * Failure: void (should not happen)
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Jul 5 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5RC_t *H5F_grp_btree_shared(const H5F_t *f)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_grp_btree_shared)
+
+ assert(f);
+ assert(f->shared);
+
+ FUNC_LEAVE_NOAPI(f->shared->grp_btree_shared)
+} /* end H5F_grp_btree_shared() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_block_read
*
* Purpose: Reads some data from a file/server/etc into a buffer.
@@ -3987,7 +4197,7 @@ H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t
haddr_t abs_addr;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5F_block_read, FAIL);
+ FUNC_ENTER_NOAPI(H5F_block_read, FAIL)
assert (f);
assert (f->shared);
@@ -3999,10 +4209,10 @@ H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t
/* Read the data */
if (H5FD_read(f->shared->lf, type, dxpl_id, abs_addr, size, buf)<0)
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -4043,7 +4253,7 @@ H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size,
haddr_t abs_addr;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5F_block_write, FAIL);
+ FUNC_ENTER_NOAPI(H5F_block_write, FAIL)
assert (f);
assert (f->shared);
@@ -4051,17 +4261,17 @@ H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size,
assert (buf);
if (0==(f->intent & H5F_ACC_RDWR))
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "no write intent");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "no write intent")
/* Convert the relative address to an absolute address */
abs_addr = f->shared->base_addr + addr;
/* Write the data */
if (H5FD_write(f->shared->lf, type, dxpl_id, abs_addr, size, buf))
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -4083,7 +4293,7 @@ done:
*-------------------------------------------------------------------------
*/
void
-H5F_addr_encode(H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr)
+H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr)
{
unsigned i;
@@ -4124,7 +4334,7 @@ H5F_addr_encode(H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_decode(H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/)
+H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/)
{
unsigned i;
haddr_t tmp;
@@ -4144,7 +4354,7 @@ H5F_addr_decode(H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/)
if (i<sizeof(*addr_p)) {
tmp = c;
- tmp <<= i * 8; /*use tmp to get casting right */
+ tmp <<= (i * 8); /*use tmp to get casting right */
*addr_p |= tmp;
} else if (!all_zero) {
assert(0 == **pp); /*overflow */
@@ -4217,6 +4427,7 @@ H5Fget_freespace(hid_t file_id)
hssize_t ret_value; /* Return value */
FUNC_ENTER_API(H5Fget_freespace, FAIL)
+ H5TRACE1("Hs","i",file_id);
/* Check args */
if(NULL==(file=H5I_object_verify(file_id, H5I_FILE)))
@@ -4232,6 +4443,100 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Fget_filesize
+ *
+ * Purpose: Retrieves the file size of the HDF5 file. This function
+ * is called after an existing file is opened in order
+ * to learn the true size of the underlying file.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: David Pitt
+ * david.pitt@bigpond.com
+ * Apr 27, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fget_filesize(hid_t file_id, hsize_t *size)
+{
+ H5F_t *file=NULL; /* File object for file ID */
+ herr_t ret_value = SUCCEED; /* Return value */
+ haddr_t eof;
+
+ 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, FAIL, "not a file ID")
+
+ /* Go get the actual 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)
+} /* end H5Fget_filesize() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fget_name
+ *
+ * Purpose: Gets the name of the file to which object OBJ_ID belongs.
+ * If `name' is non-NULL then write up to `size' bytes into that
+ * buffer and always return the length of the entry name.
+ * Otherwise `size' is ignored and the function does not store the name,
+ * just returning the number of characters required to store the name.
+ * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL)
+ * is unchanged and the function returns a negative value.
+ *
+ * Return: Success: The length of the file name
+ * Failure: Negative
+ *
+ * Programmer: Raymond Lu
+ * June 29, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size)
+{
+ H5G_entry_t *ent; /*symbol table entry */
+ size_t len=0;
+ ssize_t ret_value;
+
+ FUNC_ENTER_API (H5Fget_name, FAIL);
+ H5TRACE3("Zs","ixz",obj_id,name,size);
+
+ /* get symbol table entry */
+ if((ent = H5G_loc(obj_id))==NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID")
+
+ len = HDstrlen(ent->file->name);
+
+ if(name) {
+ HDstrncpy(name, ent->file->name, MIN(len+1,size));
+ if(len >= size)
+ name[size-1]='\0';
+ } /* end if */
+
+ /* Set return value */
+ ret_value=(ssize_t)len;
+
+done:
+ FUNC_LEAVE_API(ret_value);
+} /* end H5Fget_name() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_debug
*
* Purpose: Prints a file header to the specified stream. Each line
@@ -4344,308 +4649,3 @@ H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE * stream, int inden
done:
FUNC_LEAVE_NOAPI(ret_value);
}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_get_id
- *
- * Purpose: Get the file ID, incrementing it, or "resurrecting" it as
- * appropriate.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Raymond Lu
- * Oct 29, 2003
- *
- * Modifications:
- *-------------------------------------------------------------------------
- */
-hid_t
-H5F_get_id(H5F_t *file)
-{
- hid_t ret_value;
-
- FUNC_ENTER_NOAPI_NOINIT(H5F_get_id)
-
- assert(file);
-
- if(file->file_id == -1) {
- if(H5I_remove(file->closing)==NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_READERROR, FAIL, "unable to remove from closing list")
-
- /* Get an atom for the file */
- if ((file->file_id = H5I_register(H5I_FILE, file))<0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file")
-
- /* Indicate file is not closing */
- file->closing = 0;
- } else {
- /* Increment reference count on atom. */
- if (H5I_inc_ref(file->file_id)<0)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed");
- }
-
- ret_value = file->file_id;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_get_id() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_get_base_addr
- *
- * Purpose: Quick and dirty routine to retrieve the file's 'base_addr' value
- * (Mainly added to stop non-file routines from poking about in the
- * H5F_t data structure)
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Raymond Lu <slu@ncsa.uiuc.edu>
- * December 20, 2002
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-haddr_t
-H5F_get_base_addr(const H5F_t *f)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_base_addr)
-
- assert(f);
- assert(f->shared);
-
- FUNC_LEAVE_NOAPI(f->shared->base_addr)
-} /* end H5F_get_base_addr() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_get_eoa
- *
- * Purpose: Quick and dirty routine to retrieve the file's 'eoa' value
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
- * June 1, 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-haddr_t
-H5F_get_eoa(const H5F_t *f)
-{
- haddr_t ret_value;
-
- FUNC_ENTER_NOAPI(H5F_get_eoa, HADDR_UNDEF)
-
- assert(f);
- assert(f->shared);
-
- /* Dispatch to driver */
- if (HADDR_UNDEF==(ret_value=H5FD_get_eoa(f->shared->lf)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_get_eoa() */
-
-#ifdef H5_HAVE_PARALLEL
-
-/*-------------------------------------------------------------------------
- * Function: H5F_mpi_get_rank
- *
- * Purpose: Retrieves the rank of an MPI process.
- *
- * Return: Success: The rank (non-negative)
- *
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Friday, January 30, 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-int
-H5F_mpi_get_rank(const H5F_t *f)
-{
- int ret_value;
-
- FUNC_ENTER_NOAPI(H5F_mpi_get_rank, FAIL)
-
- assert(f && f->shared);
-
- /* Dispatch to driver */
- if ((ret_value=H5FD_mpi_get_rank(f->shared->lf))<0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_mpi_get_rank() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_mpi_get_comm
- *
- * Purpose: Retrieves the file's communicator
- *
- * Return: Success: The communicator (non-negative)
- *
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Friday, January 30, 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-MPI_Comm
-H5F_mpi_get_comm(const H5F_t *f)
-{
- MPI_Comm ret_value;
-
- FUNC_ENTER_NOAPI(H5F_mpi_get_comm, MPI_COMM_NULL)
-
- assert(f && f->shared);
-
- /* Dispatch to driver */
- if ((ret_value=H5FD_mpi_get_comm(f->shared->lf))==MPI_COMM_NULL)
- HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_mpi_get_comm() */
-#endif /* H5_HAVE_PARALLEL */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_grp_btree_shared
- *
- * Purpose: Replaced a macro to retrieve the shared B-tree node info
- * now that the generic properties are being used to store
- * the values.
- *
- * Return: Success: Non-void, and the shared B-tree node info
- * is returned.
- *
- * Failure: void (should not happen)
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Jul 5 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-H5RC_t *H5F_grp_btree_shared(const H5F_t *f)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_grp_btree_shared)
-
- assert(f);
- assert(f->shared);
-
- FUNC_LEAVE_NOAPI(f->shared->grp_btree_shared)
-} /* end H5F_grp_btree_shared() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5Fget_filesize
- *
- * Purpose: Retrieves the file size of the HDF5 file. This function
- * is called after an existing file is opened in order
- * to learn the true size of the underlying file.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: David Pitt
- * david.pitt@bigpond.com
- * Apr 27, 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5Fget_filesize(hid_t file_id, hsize_t *size)
-{
- H5F_t *file=NULL; /* File object for file ID */
- herr_t ret_value = SUCCEED; /* Return value */
- haddr_t eof;
-
- 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, FAIL, "not a file ID")
-
- /* Go get the actual 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)
-} /* end H5Fget_filesize() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5Fget_name
- *
- * Purpose: Gets the name of the file to which object OBJ_ID belongs.
- * If `name' is non-NULL then write up to `size' bytes into that
- * buffer and always return the length of the entry name.
- * Otherwise `size' is ignored and the function does not store the name,
- * just returning the number of characters required to store the name.
- * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL)
- * is unchanged and the function returns a negative value.
- *
- * Return: Success: The length of the file name
- * Failure: Negative
- *
- * Programmer: Raymond Lu
- * June 29, 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-ssize_t
-H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size)
-{
- H5G_entry_t *ent; /*symbol table entry */
- size_t len=0;
- ssize_t ret_value;
-
- FUNC_ENTER_API (H5Fget_name, FAIL);
- H5TRACE3("Zs","ixz",obj_id,name,size);
-
- /* get symbol table entry */
- if((ent = H5G_loc(obj_id))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID")
-
- len = HDstrlen(ent->file->name);
-
- if(name) {
- HDstrncpy(name, ent->file->name, MIN(len+1,size));
- if(len >= size)
- name[size-1]='\0';
- } /* end if */
-
- /* Set return value */
- ret_value=(ssize_t)len;
-
-done:
- FUNC_LEAVE_API(ret_value);
-} /* end H5Fget_name() */
-