getting file size from FILE* struct

This is a discussion on getting file size from FILE* struct within the C++ Programming forums, part of the General Programming Boards category; Is there a quick way to get the file size of a file from an initialized file handle (FILE *)...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    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, 04: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, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21