From 7a9d0788593560209b16c71d339b544dbd67f170 Mon Sep 17 00:00:00 2001 From: q-posev Date: Wed, 2 Jun 2021 14:40:23 +0200 Subject: [PATCH] remove append mode --- src/templates_front/templator_front.org | 3 +-- src/templates_hdf5/templator_hdf5.org | 9 +-------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index f613a49..8a217b8 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -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; diff --git a/src/templates_hdf5/templator_hdf5.org b/src/templates_hdf5/templator_hdf5.org index 1954539..cb5faa9 100644 --- a/src/templates_hdf5/templator_hdf5.org +++ b/src/templates_hdf5/templator_hdf5.org @@ -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':