Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Strange Behaviour in finding Size of a File
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Greg Martin  
View profile  
 More options Nov 9 2012, 11:59 am
Newsgroups: comp.lang.c
From: Greg Martin <g...@softsprocket.com>
Date: Fri, 09 Nov 2012 08:59:20 -0800
Local: Fri, Nov 9 2012 11:59 am
Subject: Re: Strange Behaviour in finding Size of a File
On 12-11-08 11:09 PM, felix wrote:

> 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:

> //-- Code starts here : --

> static size_t LogSize = 1048576;
> bool CreateNewLogs = false;

> 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.

> I am not sure if I am missing anything in our understanding of the stat function. Any inputs or pointers on this regard will be really Helpful.

> Thanks in advance, and please let me know if any other information is required.

> --
> Felix

I would think it strange if I knew for sure that the function got called
before the write in every place that the file was possibly being written
to and that there weren't multiple process/threads that could write to it.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.