ftello64

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ftello64

Alessandro Capucci

Hello,
I'm usging gcc from MinGW on Windows Vista. I receive incorrect values with ftello64 function. Why ? Ther's some one that have the same problem ?
I've this compiler defines (like in linux)
-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64

My Gcc version
gcc (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Tnks,
Alessandro


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) HTML/MIME encoded mail
3) Improper quoting
4) Improper trimming
Reply | Threaded
Open this post in threaded view
|

Re: ftello64

Tor Lillqvist
> I've this compiler defines (like in linux)
> -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64

What makes you think these defines would have any effect on MinGW? The
initial underscore should tell you that that these identifiers are
platform-dependent.

... and if you are going to say "but MinGW is supposed to make
programming on Windows be like on Linux", sorry, you are wrong.

Why don't you show us a complete and minimal sample program that
behaves oddly in your opinion?

For example, the program below works fine for me on Vista. No -D
options necessary when compiling.

(Note that the DeviceIoControl call is there just so that the file is
set to be sparse (like files on Unixes). Otherwise running this
program will take ages and it most likely fills your disk as it would
create a file that occupies 1.2 TB...

#include <windows.h>
#include <winioctl.h>
#include <stdio.h>
#include <io.h>

#define ALOT 1234*1024*1024*1024LL

int
main (int argc, char **argv)
{
  FILE *f = fopen ("foo.bar", "wb");
  char bfr[5];
  DWORD bytes_returned;

  if (!DeviceIoControl ((HANDLE) _get_osfhandle (fileno (f)),
                        FSCTL_SET_SPARSE,
                        NULL, 0,
                        NULL, 0,
                        &bytes_returned, NULL))
    fprintf (stderr, "Could not set file sparse\n"), exit (1);

  fseeko64 (f, ALOT, 0);
  printf ("We are now at file offset %I64d\n", ftello64 (f));
  fprintf (f, "Hello there");
  printf ("And now at %I64d\n", ftello64 (f));
  fflush (f);

  fclose (f);

  fopen ("foo.bar", "rb");
  printf ("Seeking there again\n");
  fseeko64 (f, ALOT, 0);
  printf ("We are now at file offset %I64d\n", ftello64 (f));
  printf ("Read %d bytes\n", fread (bfr, 1, 5, f));
  printf ("\"%.5s\"\n", bfr);

  return 0;
}

--tml

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) HTML/MIME encoded mail
3) Improper quoting
4) Improper trimming