felix <ckpra...@gmail.com> writes:
> This method was written to create new Log File, when the size of the
> Log File reaches a max size defined by user [10MB in our case]. Here
> is the code snippet that does this check:
> if ( stat ( logFile, &results ) == 0 )
> if ( results.st_size > LogSize )
> CreateNewLogs = true;
> //-- Code ends here : --
> It is strange that the condition got satisfied when results.st_size =
> 2589116. And we are sure that the size of the data that is written is
> between 50 to 100 bytes in one operation. And this check is done
> before writing into the LogFile.
It's been pointed out that 1048576 is the wrong value if you want 10 MB
(more pedantically, 10 MiB). But LogSize is also the wrong type.
It should be the same type as the st_size member.
You probably want to use "const" rather than "static" in the definition
of LogSize, unless the value can change.
Neither of these is likely to be the cause of the problem you're seeing.
Since stat() is defined by POSIX, not by C, you'll likely get better
answers in comp.unix.programmer.
-- Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"