diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-06-30 08:01:13 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-06-30 08:01:59 (GMT) |
commit | f4cecda288dbc2b469d908af4f6d71c7a7c018a3 (patch) | |
tree | e6cdec4312150f3e8f8a683491eb79f0489787c5 /src/lib/tng_io.c | |
parent | ba9aea42b01c0563e0ff0a886999daeaf6b570a7 (diff) |
Fixed tng_num_frame_sets_get()
tng_num_frame_sets_get() should not fail if there are no frame sets.
Change-Id: Ie01a6b3230af7413a51ba144bd03c5fe00c25519
Diffstat (limited to 'src/lib/tng_io.c')
-rw-r--r-- | src/lib/tng_io.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 792be2e..fa4d3e5 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -11525,7 +11525,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get int64_t long_stride_length, medium_stride_length; long file_pos, orig_frame_set_file_pos; tng_trajectory_frame_set_t frame_set; - struct tng_trajectory_frame_set orig_frame_set; + struct tng_trajectory_frame_set orig_frame_set; tng_gen_block_t block; tng_function_status stat; int64_t cnt = 0; @@ -11540,6 +11540,12 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get orig_frame_set_file_pos = tng_data->current_trajectory_frame_set_input_file_pos; file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos; + if(file_pos < 0) + { + *n = tng_data->n_trajectory_frame_sets = cnt; + return(TNG_SUCCESS); + } + tng_block_init(&block); fseek(tng_data->input_file, file_pos, @@ -16903,7 +16909,12 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_open /* Read the file headers */ tng_file_headers_read(*tng_data_p, TNG_USE_HASH); - tng_num_frame_sets_get(*tng_data_p, &(*tng_data_p)->n_trajectory_frame_sets); + stat = tng_num_frame_sets_get(*tng_data_p, &(*tng_data_p)->n_trajectory_frame_sets); + + if(stat != TNG_SUCCESS) + { + return(stat); + } } if(mode == 'w') |