Thru which C++ API can I calculate disk space?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Gh

Thru which C++ API can I calculate disk space?

Post by Gh »

Hi,

I want to calculate disk free and used space before saving a file on it. thru which c++ api can i achieve this.
I need urgent help. Any one please help me.

Regards,
Gh
nullify

Re:Thru which C++ API can I calculate disk space?

Post by nullify »

It sounds like you're asking for help at the wrong place. This forum is for OS development. (ie., generally not programming for an existing system)

If your question is about OS development, then you'll either have to port a C++ API capable of doing this to your system, or write your own. Both require some underlying support (low-level hard drive interaction and a file system) to accomplish.
Gh

Re:Thru which C++ API can I calculate disk space?

Post by Gh »

No this is the write place to ask :-) I am implementing file system now a days and in that i want to use C++ API I searched on the net but didn't find any. That's why I post the message on that forum so that if every one have ever used such an API plz refer me that API.
User avatar
Solar
Member
Member
Posts: 7632
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Thru which C++ API can I calculate disk space?

Post by Solar »

Gh wrote: I am implementing file system now a days and in that i want to use C++ API I searched on the net but didn't find any.
Repeat rule #3 of OS programming: Unless you implemented the "standard" includes yourself (or ported some standard library to your OS), there are no standard includes.

That being said, neither the C nor the C++ standard library provide any means of calculating free disk space, because this is OS dependent.
Every good solution is obvious once you've found it.
Ozguxxx

Re:Thru which C++ API can I calculate disk space?

Post by Ozguxxx »

Well I think your (referring to Gh) problem is more basic one. I think searching for how API is serviced by OPERATING SYSTEM is more meaningful to you before interfacing with fs driver, which in later stage will be written by you. Most c API is not coded in BIOS. Well, some of it might be but fs API is dependent on OPERATING SYSTEM, not bios...
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Thru which C++ API can I calculate disk space?

Post by Pype.Clicker »

Gh wrote: No this is the write place to ask :-) I am implementing file system now a days and in that i want to use C++ API I searched on the net but didn't find any. That's why I post the message on that forum so that if every one have ever used such an API plz refer me that API.
Depending on which OS you'll develop your filesystem for, the API will be different.
You're likely to use the "block device interface" if you're working for Linux, or something from the Windows Device Development Kit (internals unknown) , thus making "read block" and "write blocks". Knowing the available amount of free space basically will consist of reading the Master Boot Record (MBR) for your disk and try to locate unpartitionned / unused space.
Tim

Re:Thru which C++ API can I calculate disk space?

Post by Tim »

Gh wrote:I want to calculate disk free and used space before saving a file on it. thru which c++ api can i achieve this.
The C++ language doesn't know about "disks" and "space". Any method of determining the free space on a system which might support disks is operating system dependent. As you're writing your own OS, you will need to create your own function from scratch.
Post Reply