src/h5core/h5_attachements.c

- h5_add_attachment(): check file mode, return error if read-only
- adapted to new function 'h5priv_create_group()'
This commit is contained in:
2016-07-28 17:27:05 +02:00
parent c26d6a84e3
commit 6fb8b77baa
+2 -6
View File
@@ -31,11 +31,7 @@ h5_add_attachment (
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname);
CHECK_FILEHANDLE (f);
// allowed file modes: O_RDWR, O_WRONLY; O_APPEND
if (f->props->flags & H5_O_RDONLY) {
H5_LEAVE (
h5priv_handle_file_mode_error (f->props->flags));
}
CHECK_WRITABLE_MODE (f);
struct stat st;
if (stat (fname, &st) < 0) {
@@ -81,7 +77,7 @@ h5_add_attachment (
}
hid_t loc_id;
TRY (loc_id = h5priv_open_group (1, f->file, H5_ATTACHMENT));
TRY (loc_id = h5priv_create_group (f->file, H5_ATTACHMENT));
h5_err_t exists;
TRY (exists = hdf5_link_exists (loc_id, fname));
if (exists && (f->props->flags & H5_O_APPENDONLY)) {