1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-22 20:35:44 +01:00

remove append mode

This commit is contained in:
q-posev 2021-06-02 14:40:23 +02:00
parent f5542571d1
commit 7a9d078859
2 changed files with 2 additions and 10 deletions

View File

@ -451,7 +451,6 @@ struct trexio_back_end_s {
2) ~mode~ - character containing open mode (see below)
- ~'w'~ - (write) creates a new file as READWRITE (overwrite existing file)
- ~'r'~ - (read) opens existing file as READONLY
- ~'a'~ - (append) either opens file in READWRITE mode if it already exists or creates a new one
3) ~back_end~ - integer number (or the corresponding global parameter) specifying the back end
- ~TREXIO_HDF5~ - for HDF5 back end (integer alternative: 0)
- ~TREXIO_TEXT~ - for TEXT back end (integer alternative: 1)
@ -482,7 +481,7 @@ trexio_open(const char* file_name, const char mode,
if (back_end < 0) return NULL;
if (back_end >= TREXIO_INVALID_BACK_END) return NULL;
if (mode != 'r' && mode != 'w' && mode != 'a') return NULL;
if (mode != 'r' && mode != 'w') return NULL;
trexio_t* result = NULL;
void* result_tmp = NULL;

View File

@ -97,10 +97,6 @@ trexio_hdf5_init (trexio_t* const file)
// reading the existing file -> open as RDONLY
f->file_id = H5Fopen(file->file_name, H5F_ACC_RDONLY, H5P_DEFAULT);
break;
case 'a':
// appending the existing file -> open as RDWR
f->file_id = H5Fopen(file->file_name, H5F_ACC_RDWR, H5P_DEFAULT);
break;
case 'w':
// writing the existing file -> overwrite it (_TRUNC) [_EXCL | H5F_ACC_DEBUG as an alternative]
f->file_id = H5Fcreate(file->file_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@ -111,8 +107,7 @@ trexio_hdf5_init (trexio_t* const file)
switch (file->mode) {
case 'r':
case 'a':
// reading or appending non-existing file -> error
// reading non-existing file -> error
return TREXIO_FAILURE;
case 'w':
// writing non-existing file -> create it
@ -124,9 +119,7 @@ trexio_hdf5_init (trexio_t* const file)
/* Create or open groups in the hdf5 file assuming that they exist if file exists */
switch (file->mode) {
// the switch for 'r'/'a' is reached only if file exists
case 'r':
case 'a':
f->$group$_group = H5Gopen(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT);
break;
case 'w':