Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

C++: how to check my directory disk space

Programming


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-20-2009   -   Original Discussion by SamRoj
SamRoj's Unix or Linux Image
SamRoj SamRoj is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 18 August 2009, 5:34 AM EDT
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
C++: how to check my directory disk space

I have a directory, and I write some files in to that. How to throw the error exception when my directory is full. i.e. there is no disk space
Sponsored Links
    #2  
Old Unix and Linux 04-20-2009   -   Original Discussion by SamRoj
Gunther's Unix or Linux Image
Gunther Gunther is offline
Registered User
 
Join Date: Apr 2009
Last Activity: 1 October 2009, 8:44 PM EDT
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Whether there's sufficient space left is normally not a concern of the directory but of the whole file system. There are things like quotas, which are normally supported by default by any distributor-made standard kernel but which have to be activated first.
So, I guess a call to statvfs() should do it.
Sponsored Links
    #3  
Old Unix and Linux 04-20-2009   -   Original Discussion by SamRoj
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
 
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
From the man-page of write(2):
Quote:
Originally Posted by man(2)
[...]On success, the number of bytes written are returned (zero indicates nothing was written). On error, -1 is returned, and errno is set appropriately. If count is zero and the file descriptor refers to a regular file, 0 may be returned, or an error could be detected. For a special file, the results are not portable.
[...]
EFBIG
An attempt was made to write a file that exceeds the implementation-defined maximum file size or the process' file size limit, or to write at a position past the maximum allowed offset.
[...]
ENOSPC
The device containing the file referred to by fd has no room for the data.
[...]
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Disk space check raghu.amilineni Solaris 6 03-18-2009 06:20 PM
Script to check top 5 biggest disk space users sytemx Shell Programming and Scripting 3 10-07-2008 06:50 PM
Perl script to check free disk space susja Shell Programming and Scripting 1 06-28-2008 04:24 AM
Please help - disk space check script maddhadder71 Shell Programming and Scripting 0 05-08-2008 09:16 AM
Check directory space? lesstjm Shell Programming and Scripting 3 04-19-2002 10:10 AM



All times are GMT -4. The time now is 04:59 AM.