From: Kevin Day Date: Thu, 7 Jun 2012 03:43:33 +0000 (-0500) Subject: Update: add file position reset macro X-Git-Tag: 0.3.0~21 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=9929a6d2a45348204db9a7cf011d5a94fd26f2a4;p=fll 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. --- 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