# List of drives?

**URL:** <https://www.ruby-forum.com/t/list-of-drives/52906>\
**Category:** Ruby\
**Created:** [January 20, 2006, 5:25am UTC](https://www.ruby-forum.com/t/list-of-drives/52906 "2006-01-20T05:25:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 20, 2006, 5:25am UTC](https://www.ruby-forum.com/t/list-of-drives/52906/1 "2006-01-20T05:25:26Z")

</div>

Is there a way in ruby with out extra libraries to get a list of drives?  
hard drives, dvd drives, network drives, …?

Becker

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 20, 2006, 11:35am UTC](https://www.ruby-forum.com/t/list-of-drives/52906/2 "2006-01-20T11:35:45Z")

</div>

On 1/20/06, ruby talk [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way in ruby with out extra libraries to get a list of drives?  
> hard drives, dvd drives, network drives, …?

No.

This is highly operating system specific, and it’s even hard to  
define, especially when you include “network drives”.

Eivind.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 22, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/list-of-drives/52906/3 "2006-01-22T17:55:39Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Friday 20 January 2006 04:47, ruby talk wrote:

> Is there a way in ruby with out extra libraries to get a list of drives?  
> hard drives, dvd drives, network drives, …?
> 
> Becker

For Unix/Linux/MacOSX it would be rather easy, just run `mount` and  
parse the  
output.

For Windows, you may just test every unit A: to Z:. You’ll need to  
access the  
Win32 API to look for volumes without an assigned mount point (unit  
letter),  
such as SAN mounted volumes.

I don’t know how to do it in Mac OS Classic, I never used those versions  
of  
Mac OS.

* * *

Pau Garcia i Quiles  
[http://www.elpauer.org](http://www.elpauer.org)  
(En general no puedo contestar antes de 10 dÃ­as)  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFD07h3/DzYv9iGJzsRAij+AKDLue7QnBIR0XjjEjHA3/BhclWKMQCeNMZ+  
XH3pA57PL6QAipj5yGPbjcA=  
=iKiS  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 23, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/list-of-drives/52906/4 "2006-01-23T17:19:05Z")

</div>

On 1/19/06, ruby talk [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way in ruby with out extra libraries to get a list of drives?  
> hard drives, dvd drives, network drives, …?

On Windows systems, you can do:  
require ‘win32ole’  
drives = []  
file\_system = WIN32OLE.new( ‘Scripting.FileSystemObject’ )  
file\_system.Drives.each { |drive| drives \<\< drive.DriveLetter }  
#drives now contains a list of existing drive letters.  
puts drives

There are other useful properties on the ‘drive’ object, including  
ShareName, which will tell you the network path, for remote volumes.
