summaryrefslogtreecommitdiffstats
path: root/src/H5Lexternal.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/H5Lexternal.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/H5Lexternal.c')
-rw-r--r--src/H5Lexternal.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index 612c4c6..3452c20 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -53,6 +53,7 @@ static hid_t H5L_extern_traverse(const char * link_name, hid_t cur_group, void *
char *prefix;
size_t fname_len;
hbool_t fname_alloc = FALSE;
+ unsigned intent;
hid_t ret_value = -1;
file_name = (char *) udata;
@@ -79,7 +80,15 @@ static hid_t H5L_extern_traverse(const char * link_name, hid_t cur_group, void *
strcat(file_name, udata);
}
- if((fid = H5Fopen(file_name, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ /* Figure out if we should open with read-write or read-only */
+ if((fid = H5Iget_file_id(cur_group)) < 0)
+ goto error;
+ if(H5Fget_intent(fid, &intent) < 0)
+ goto error;
+ if(H5Fclose(fid) < 0)
+ goto error;
+
+ if((fid = H5Fopen(file_name, intent, H5P_DEFAULT)) < 0)
goto error;
ret_value = H5Oopen(fid, obj_name, lapl_id); /* If this fails, our return value will be negative. */
if(H5Fclose(fid) < 0)