Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Fri, 24 Jun 2005 14:17:15 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com cc: Herb Martin Subject: RE: stat file -- cygwin vs. Windows size? In-Reply-To: Message-ID: References: <20206A8F2DE2 AT mail DOT learnquick DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 24 Jun 2005, Igor Pechtchanski wrote: > On Fri, 24 Jun 2005, Herb Martin wrote: > > > > >My suspicion is that stat is counting cr-lf as two characters but the > > > >input routines are treating these as one. > > > > > > > >If the file has about 20 lines, then that's 20 missing characters??? > > > > > > Yes, this is right. And yes, this could be the cause of the > > > situation you're noticing. > > > > Is there a standard Cygwin 'idiom' or function for dealing with this > > mismatch, or should I just re-invent the wheel. > > Sure -- just force binary mode on the file (i.e., open it using O_BINARY > for the open() call, or the "rb" mode for the fopen() call). The mount > type only applies if the mode is unspecified. A clarification: force binary mode on the opened file in your program, not the actual on-disk data. Note that if you do that, you'd also need to handle the CR ('\r', or 0x0d) characters explicitly in your program. HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "The Sun will pass between the Earth and the Moon tonight for a total Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/