Welcome, Guest. Please login or register.

Author Topic: OS call to get file size  (Read 2731 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Castellen

Re: OS call to get file size
« on: January 28, 2006, 09:59:31 PM »
Or use lstat()


#include

struct stat *stat_info;

lstat("filename", stat_info);

printf("The file is %d bytes in size", stat_info->st_size);


Or something like that anyway.  I think the beers are having an adverse affect on my memory :pint:
Just noticed that original post was October last year.  I hope he's figured it out by now!
 

Offline Castellen

Re: OS call to get file size
« Reply #1 on: January 28, 2006, 10:20:57 PM »
Yep, makes sense to use it without using structure pointers like that.

Not sure if this is the most efficient way to do the job, but also in the "stat" structure are things like file date, file comments, etc, which can be useful.

It's a good general purpose "give me every information available about a file" type of function.