This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: filesize function


On Sat, 10 Jul 1999, Reza Habib wrote:

> Hi.  I'm using the filesize function from io.h on mingw32 with egcs 1.1.2.
> The size reported by the function is incorrect.  The exact same line reports
> the correct value with either visual c++ or borland c++.  Is this a bug in
> the mingw32 library?  Here is the line:
> 
> FILE *datamatfile = fopen(argv[1],"rb");
> long length = filelength(fileno(datamatfile));
> 

Sorry, but a line doesn't tell me anything at all about the rest of your
code.

I tried out the following program and it gives me the same result as MSVC
and what-not. If you can provide a complete testcase showing the problem,
I'll look at it. 
  
  $ gcc -g -Wall -o file-length-test.exe file-length-test.c
  $ file-length-test file-length-test.c

and see what size you get.

== cut from here to end.
#include <io.h>
#include <stdio.h>
#include <stdlib.h>

int
main (int argc, char *argv[])
{
  const char *fname = (argc == 2) ? argv[1] : NULL;
  FILE *fp;
  long fsize;

  if (fname == NULL)
    {
      fprintf (stderr, "Usage: %s filename\n", argv[0]);
      exit (1);
    }
  
  fp = fopen (fname, "rb");
  if (fp == NULL)
    {
      perror (fname);
      exit (1);
    }
  
  fsize = filelength (fileno (fp));
  printf ("%s: size = %ld\n", fname, fsize);
  fclose (fp);

  exit (0);
}



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]