summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Lundborg <lundborg.magnus@gmail.com>2013-12-05 16:20:53 (GMT)
committerMagnus Lundborg <lundborg.magnus@gmail.com>2013-12-05 16:20:53 (GMT)
commit4c75bb0f7f7bc465fe8fc01113a44fea3fe92a0a (patch)
tree15e2bcf917992411fa5a1f41c5381d3db665d8f8
parentc6443b9491b17a09e82a9972c26418d52e187514 (diff)
Added function tng_util_prepare_append_after_frame()
-rw-r--r--include/tng_io.h14
-rw-r--r--src/lib/tng_io.c26
2 files changed, 40 insertions, 0 deletions
diff --git a/include/tng_io.h b/include/tng_io.h
index 292700f..7ecbcaa 100644
--- a/include/tng_io.h
+++ b/include/tng_io.h
@@ -4712,6 +4712,20 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat
int64_t *n_data_blocks_in_next_frame,
int64_t **data_block_ids_in_next_frame);
+/** @brief Finds the frame set of the specified frame in order to prepare for writing
+ * after it.
+ * @param tng_data is the trajectory to use.
+ * @param prev_frame is the frame after which to start appending.
+ * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
+ * must be initialised before using it.
+ * @pre \code prev_frame >= 0 \endcode The previous frame must not be negative.
+ * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
+ * has occured (such as not finding the requested frame) or TNG_CRITICAL (2)
+ * if a major error has occured.
+ */
+tng_function_status DECLSPECDLLEXPORT tng_util_prepare_append_after_frame
+ (tng_trajectory_t tng_data,
+ const int64_t prev_frame);
/** @} */ /* end of group2 */
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index 57744e8..33d58ba 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -18306,3 +18306,29 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat
return(TNG_SUCCESS);
}
+
+tng_function_status DECLSPECDLLEXPORT tng_util_prepare_append_after_frame
+ (tng_trajectory_t tng_data,
+ const int64_t prev_frame)
+{
+ tng_function_status stat;
+ FILE *temp = tng_data->input_file;
+
+ TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
+ TNG_ASSERT(prev_frame >= 0, "TNG library: The previous frame must not be negative.");
+
+ tng_data->input_file = tng_data->output_file;
+
+ stat = tng_frame_set_of_frame_find(tng_data, prev_frame);
+ if(stat != TNG_SUCCESS)
+ {
+ return(stat);
+ }
+
+ tng_data->current_trajectory_frame_set_output_file_pos =
+ tng_data->current_trajectory_frame_set_input_file_pos;
+
+ tng_data->input_file = temp;
+
+ return(TNG_SUCCESS);
+}
contact: Jan Huwald // Impressum