C Program to calculate the FILE Size Sytem in Unix

This is a discussion on C Program to calculate the FILE Size Sytem in Unix within the C Programming forums, part of the General Programming Boards category; Hi All, I am trying to write a C program to calculate the Unix FILE System Size and Free Size ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    22

    Lightbulb C Program to calculate the FILE Size Sytem in Unix

    Hi All,
    I am trying to write a C program to calculate the Unix FILE System Size and Free Size available in Unix
    i am not able to finish program..

    is it anyone have any idea or any thought.

    please share with me.

    Thanks in Advance,

    Anwar

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    file size is pretty easy -- use stat() function. Don't know about getting amount of free disk space.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    22

    Lightbulb

    Hi

    THanks for response. i have tried with stat and fstat also.
    but basically my req. is like that

    i want to know the following directory

    free space and size of the directory sturcture

    for example output should be like that
    i mean user input is directory path or name
    and out put is
    directroy - /countrys/rakeshs/download -
    free size - 2325345456
    total space - 344354567

    pls let me know how will proceed.
    coz fstat will calcuate only file size.

    regards,
    Anwar

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    to get the sum of the file sizes in a directory, call opendir() and readdir(). Call fstat() or stat() for each filename retrieved by readdir. see man pages or google for info about those functions.

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    22

    Lightbulb

    Hi
    Thanks for reply.But i want total size of directory.
    i mean free space size also.

    is it any way to calculate that.



    Thanks
    ANwar

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    I don't think you can set the max size of a directory. I know you can set the max disk space that any user can use, but I don't think it can be done by directory.

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    the freespace of a directory is the freespace of the filesystem it sits on (normally) unless you use a quota system (something I haven't delt with myself yet).
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 05:27 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM
  3. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 09:04 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM

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