From 9929a6d2a45348204db9a7cf011d5a94fd26f2a4 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 6 Jun 2012 22:43:33 -0500 Subject: [PATCH] Update: add file position reset macro Define a macro because creating a function is just overkill for this. This macro should save a few lines of code when reseting the file position. --- level_0/f_file/c/file.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 063e154..16277a0 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -186,6 +186,15 @@ extern "C"{ #define f_file_mode_world_wx (S_IWOTH | S_IXOTH) #endif // _di_f_file_modes_ +#ifndef _di_f_macro_file_reset_position_ + #define f_macro_file_reset_position(position, file) \ + if (position.total_elements == 0) { \ + fseek(file.file, 0, SEEK_END); \ + position.total_elements = ftell(file.file); \ + fseek(file.file, 0, SEEK_SET); \ + } +#endif // _di_f_macro_file_reset_position_ + #ifndef _di_f_file_open_ // open a particular file and save its stream // filename = name of the file -- 1.8.3.1