943,699 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 7602
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 9th, 2007
0

fseek64()

Expand Post »
Hello there, do you have any idea where to get a good reference for the function fseek64?
Or does anyone of you here knows this function or is there really a fseek64 function? lol. Thanks!
Similar Threads
Reputation Points: 32
Solved Threads: 4
Practically a Master Poster
jaepi is offline Offline
647 posts
since Jul 2006
Oct 9th, 2007
0

Re: fseek64()

In addition, what function which is similar to stat that asks for a FILE* fildes rather than int fildes? Thanks!
Reputation Points: 32
Solved Threads: 4
Practically a Master Poster
jaepi is offline Offline
647 posts
since Jul 2006
Oct 9th, 2007
0

Re: fseek64()

fseek64 isn't a standard function, so if it exists for your compiler, the documentation will tell you where to find it and how to use it. Have you tried fgetpos and fsetpos? They're designed for large files and the implementation typically uses a 64-bit type as the base for fpos_t.

>what function which is similar to stat that asks for a FILE* fildes rather than int fildes?
There isn't one. If you want that kind of functionality, you need to step outside the standard library.
Last edited by Narue; Oct 9th, 2007 at 9:18 am.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Oct 9th, 2007
1

Re: fseek64()

I don't know anything about it, infact nothing about 64 bit programming. But a liitle google search helped me to find this.
Reputation Points: 85
Solved Threads: 42
Nearly a Posting Virtuoso
vishesh is offline Offline
1,362 posts
since Oct 2006
Oct 9th, 2007
1

Re: fseek64()

>> what function which is similar to stat that asks for a FILE* fildes rather than int fildes?
the function int fileno(FILE *stream); is part of both posix and single unix specifications. http://www.opengroup.org/onlinepubs/...ns/fileno.html
this would give the file descriptor using which you can call fstat() which also conforms to posix.
Reputation Points: 1159
Solved Threads: 285
Posting Virtuoso
vijayan121 is offline Offline
1,606 posts
since Dec 2006
Oct 9th, 2007
0

Re: fseek64()

@Narue - I have heared 'bout fsetpos but I did'nt know that it could deal with larger filetypes. I thought fsetpos64 is used. Thanks! I'll try this instead. Uhmm...have you ever encounter or use fseek64? Which is more preferable between fseek64 and fsetpos?

@vishesh - It says here that fseek64 and even fsetpos64 are new library interfaces? Do have any idea if gcc version 4.0+ supports these functions? Thanks, it really helped me, I'm keeping this document for future references.

@vijayan121 - This is exactly what I need. Thanks!

@all - Thank you very much.
Last edited by jaepi; Oct 9th, 2007 at 10:34 pm.
Reputation Points: 32
Solved Threads: 4
Practically a Master Poster
jaepi is offline Offline
647 posts
since Jul 2006
Oct 10th, 2007
1

Re: fseek64()

>I have heared 'bout fsetpos but I did'nt know that it could deal with larger filetypes.
That's what fsetpos and fgetpos are there for. fseek is limited to the size of a long integer, but because fsetpos and fgetpos rely on an opaque type (fpos_t) for representing the offset, implementations should be using a type that can handle the file size limit of the system. If your compiler doesn't do that, it's safe to assume that the rest of the standard library may be weak as well.

>Which is more preferable between fseek64 and fsetpos?
Between two functions that do the same thing, but with one being standard and the other not, choose the standard function. But make sure that they really do the same thing. If I were to implement fseek64 on my implementation it would look like this:
  1. typedef off64_t fpos_t;
  2.  
  3. off64_t fseek64 ( FILE *file, off64_t offset, int whence )
  4. {
  5. return _intern_seek ( stream, offset, whence );
  6. }
Which is identical to fseek because it uses fpos_t internally anyway. In other words, fseek64 would be a fluffy function for compatibility with existing code only. But I can't say how it's implemented on another implementation, so you'll have to do some research.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Oct 10th, 2007
0

Re: fseek64()

I'd rather use fsetpos. Uhmmm, btw, fgetpos and fsetpos come together, right? Or fsetpos may exist without fgetpos (vice-versa).
Reputation Points: 32
Solved Threads: 4
Practically a Master Poster
jaepi is offline Offline
647 posts
since Jul 2006
Oct 10th, 2007
0

Re: fseek64()

Since this is a C question and not C++ I'm moving it over to the C board.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Oct 11th, 2007
0

Re: fseek64()

>Uhmmm, btw, fgetpos and fsetpos come together, right?
They're both standard functions. A hosted compiler is required to provide them.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: sorting from a input text file
Next Thread in C Forum Timeline: Pasting together two 2d arrays into a new one





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC