Get all drives in my computer?

H

HongThuyCanada

1) I want to get the list of string which contains all the drives in my
computer.
2) I want to get the current working directory.
What is the source code look like in C++.
Thnx
 
D

David

1) I want to get the list of string which contains all the drives in my
computer.
2) I want to get the current working directory.
What is the source code look like in C++.
Thnx

You'll have to read the documentation for your operating system APIs.
Standard C++ doesn't cover those concepts. It is perfectly acceptable
to write C++ for a computer that has no file system.

David
 
M

Maxim Yegorushkin

David said:
You'll have to read the documentation for your operating system APIs.
Standard C++ doesn't cover those concepts. It is perfectly acceptable
to write C++ for a computer that has no file system.

In addition to the above, modern operating systems have single-root
filesystems, in other words, they do not support drive artefact
introduced in legacy OS's.
 
M

Markus Schoder

1) I want to get the list of string which contains all the drives in my
computer.

Easy. Just read the filenames of the form hd? and sd? from the /dev
directory with the opendir, readdir, closedir family of functions.
2) I want to get the current working directory.
What is the source code look like in C++.

Use the

char *getcwd(char *buf, size_t size);

function.

Since this works on my system I guess it must work on every system ;)
 
P

Phlip

filox said:
btw, working with directories is not covered by C++ standard so it is OS
dependent...

Ah, but didn't the Standard committees adopt boost::filesystem recently?
You're never too young to have a Vietnam flashback

Those who learn history from Fox News are destined to repeat it.
 
F

filox

Ah, but didn't the Standard committees adopt boost::filesystem recently?

Wouldn't know about that one...
 
R

Rolf Magnus

Markus said:
Easy. Just read the filenames of the form hd? and sd? from the /dev
directory with the opendir, readdir, closedir family of functions.

On a newer and fancier installation, you could also get a list from the HAL
daemon via dbus. And you can let that daemon notify you automatically if
something changes.
 
P

Phlip

Rolf said:
On a newer and fancier installation, you could also get a list from the
HAL
daemon via dbus. And you can let that daemon notify you automatically if
something changes.

Thank the gods that's off topic, folks. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top