Thread: getting file size from FILE* struct

  1. #1
    duck-billed platypus
    Guest

    getting file size from FILE* struct

    Is there a quick way to get the file size of a file from an initialized file handle (FILE *)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    fseek( fp, 0, SEEK_END);
    length = ftell( fp );

  3. #3
    duck-billed platypus
    Guest
    I thought of that, but it seems to me that there must be a faster way considering when you do one of the various findfile funcitons, the file size is in the struct that is used. Does the OS open the file-seek to the end-close the file just to determine the file size? Would it be quicker just to use findfile and get the size from that?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    There are quicker ways, but they dont involve a FILE*, and they are OS specific.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  2. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  3. Error with a vector
    By Tropicalia in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2006, 07:45 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM