Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: OS call to get file size
« on: October 29, 2005, 10:45:27 PM »
dos.library/Examine

See dos/dos.h 'struct FileInfoBlock', fib_Size holds the size.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: OS call to get file size
« Reply #1 on: January 28, 2006, 09:58:10 PM »
@DariusB

I left that method out for a reason: It's ultraslow with ffs and large files. It should be avoided.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: OS call to get file size
« Reply #2 on: January 28, 2006, 10:10:09 PM »
@Castellen
Code: [Select]

#include <sys/stat.h>
#include <stdio.h>

  struct stat stat_info;

  if (lstat(&quot;filename&quot;, &stat_info) != -1)
  {
    printf(&quot;The file is %d bytes in size\n&quot;, stat_info.st_size);
  }
  else
  {
    perror(&quot;lstat&quot;);
  }