star-mesh

Define and load a binary data format for meshes
git clone git://git.meso-star.fr/star-mesh.git
Log | Files | Refs | README | LICENSE

commit f22ba01ca905d20d9d38b38629190e8f71d85c65
parent 08ad8e5b0618b3185af366a79ecc7674f11b4d62
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sun, 16 Apr 2023 22:14:05 +0200

Small adjustment of the loading procedure

Do not display an error message if the first data to be read, i.e. the
page size, cannot be read because of the EOF flag. Thus, the caller can
check the EOF flag on his submitted stream and define whether he wants
to stop, for example, a loading loop without polluting the display with
unexpected messages.

Diffstat:
Msrc/smsh.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/smsh.c b/src/smsh.c @@ -253,14 +253,21 @@ load_stream(struct smsh* smsh, const struct smsh_load_stream_args* args) reset_smsh(smsh); /* Read file header */ + if(fread(&smsh->pagesize, sizeof(&smsh->pagesize), 1, args->stream) != 1) { + if(ferror(args->stream)) { + log_err(smsh, "%s: could not read the pagesize.\n", args->name); + } + res = RES_IO_ERR; + goto error; + } + #define READ(Var, N, Name) { \ if(fread((Var), sizeof(*(Var)), (N), args->stream) != (N)) { \ - log_err(smsh, "%s: could not read the %s.\n", args->name, (Name));\ + log_err(smsh, "%s: could not read the %s.\n", args->name, (Name)); \ res = RES_IO_ERR; \ goto error; \ } \ } (void)0 - READ(&smsh->pagesize, 1, "page size"); READ(&smsh->nnodes, 1, "number of nodes"); READ(&smsh->ncells, 1, "number of cells"); READ(&smsh->dnode, 1, "node dimension");