473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Disk space exception ?

Is there any exception related to disk space ?
If not how else can we check the availability of the disk space in a
c++ program. I know ostream helps a bit. When we try to open a file
when there's no disk space ostream::rdstate() returns badbit.

Jul 23 '05 #1
2 3186
Sagar Choudhary wrote:
Is there any exception related to disk space ?
If not how else can we check the availability of the disk space in a
c++ program. I know ostream helps a bit. When we try to open a file
when there's no disk space ostream::rdstate() returns badbit.


IIRC, that's a platform specific thing that you'll want to look into the
platform documentation for. I'm not aware of any standard C++ way of
finding how much space is free (apart from the ostream being writable
and it... not being writable or, as you pointed out, returning an error).

For example, the Microsoft Windows PlatformSDK offers:

BOOL GetDiskFreeSpace(
LPCTSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters,
LPDWORD lpTotalNumberOfClusters
);

(include windows.h)

http://msdn.microsoft.com/library/de...kfreespace.asp


--
Peter MacMillan
e-mail/msn: pe***@writeopen.com
icq: 1-874-927

GCS/IT/L d-(-)>-pu s():(-) a- C+++(++++)>$ UL>$ P++ L+ E-(-) W++(+++)>$
N o w++>$ O !M- V PS PE Y+ t++ 5 X R* tv- b++(+) DI D+(++)>$ G e++ h r--
y(--)
Jul 23 '05 #2
Sagar Choudhary wrote:
Is there any exception related to disk space ?
If not how else can we check the availability of the disk space in a
c++ program. I know ostream helps a bit. When we try to open a file
when there's no disk space ostream::rdstate() returns badbit.

Wrong, or let us clarify. The rdstate() method returns
badbit when there is problem writing to the stream. We
don't have a clue as to which problem(s) are associated
with the "badbit". For example, one could not distinguish
faulty media, missing media or full media by using the
"badbit". All we know is that there was an error. The
details are up to the implementation or the platform.

As for availability of disk space, the best course of
action is to use some platform specific functions since
C++ has no support for this.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When...
12
by: New World Order Pigs | last post by:
Is there no way in .net to get disk space remaining for a given drive??? I can't believe it and yet is seems to be so. If someone knows of a way to do this in the .net libraries I'd be very much...
5
by: Karl | last post by:
Hi, I have some code that will save the contents of a Rich Text Box in either a Text or Rich Text Format file. The code is using the SaveFileDialog and is working correctly. I have been...
1
by: Peter | last post by:
Hi, I am getting really weird error, when I try to load one of my ASP.NET website pages: Server Error in '/' Application. -----------------------------------------------------------...
0
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When...
1
by: simon | last post by:
I have encountered this error message, do anyone know what is happening?? Thanks. Description: An unhandled exception occurred during compilation using the CodeDomProvider...
2
by: Dan | last post by:
I've written a short function to return the amount of free disk space on a specified drive (for example c:) and it works fine on my development platform. In production, however, I am getting an...
2
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. I have 35 Gigs of disk space free. It doesn't happen...
6
by: Christine | last post by:
erver Error in '/test' Application. -------------------------------------------------------------------------------- There is not enough space on the disk. Description: An unhandled exception...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.