summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-08-24 00:52:21 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-08-24 00:52:21 (GMT)
commit9edac8a668f823aa7a60a97e4332216619609ba5 (patch)
treed3ba30d52bdaac0270ea68046cddeac8938765dc /src/H5F.c
parentafb817a0a71058e02625fb67f3935ddd33a48404 (diff)
downloadhdf5-9edac8a668f823aa7a60a97e4332216619609ba5.zip
hdf5-9edac8a668f823aa7a60a97e4332216619609ba5.tar.gz
hdf5-9edac8a668f823aa7a60a97e4332216619609ba5.tar.bz2
[svn-r12623] Added H5Fget_intent() function to get the "intent" of a file (read/write or
read-only). Added this to external links, so that external files are opened with the same intent as the source file. Added tests.
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 80fccd3..cb24a4a 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -2729,6 +2729,51 @@ done:
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file")
FUNC_LEAVE_API(ret_value)
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fget_intent
+ *
+ * Purpose: Public API to retrieve the file's 'intent' flags passed
+ * during H5Fopen()
+ *
+ * Return: Non-negative on success/negative on failure
+ *
+ * Programmer: James Laird
+ * August 23, 2006
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fget_intent(hid_t file_id, unsigned *intent_flags)
+{
+ H5F_t * file = NULL;
+ herr_t ret_value;
+ FUNC_ENTER_API(H5Fget_intent, FAIL)
+
+ if (NULL==(file=H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
+
+ /* If no intent flags were passed in, exit quietly */
+ if(!intent_flags)
+ HGOTO_DONE(SUCCEED)
+
+ *intent_flags = H5F_get_intent(file);
+
+ /* HDF5 uses some flags internally that users don't know about.
+ * Simplify things for them so that they get one of H5F_ACC_RDWR
+ * or H5F_ACC_RDONLY.
+ */
+ if(*intent_flags & H5F_ACC_RDWR)
+ *intent_flags = H5F_ACC_RDWR;
+ else
+ *intent_flags = H5F_ACC_RDONLY;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+}
/*-------------------------------------------------------------------------