[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

List of drives?

RubyTalk@gmail.com

1/20/2006 3:48:00 AM

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

Becker
5 Answers

Dave Burt

1/20/2006 4:11:00 AM

0

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

The following program uses the Windows Scripting Host's FileSystemObject,
documented here:
http://msdn.microsoft.com/library/devprods/vs6/vbasic/vbenlr98/vaobjfilesystem...

require 'win32ole'
filesys = WIN32OLE.new("Scripting.FileSystemObject")
filesys.drives.each do |drive|
puts drive.driveletter
end

Cheers,
Dave


Eivind Eklund

1/20/2006 9:58:00 AM

0

On 1/20/06, ruby talk <rubytalk@gmail.com> 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.


Gene Tani

1/20/2006 1:26:00 PM

0


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

win32:
http://rubyforge.org/cgi-bin/viewcvs.cgi/dlcookbook/win32/drives.rb?root=dlcookbook&rev=1.3&v...

Pau Garcia i Quiles

1/22/2006 4:54:00 PM

0

-----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.e...
(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-----


Wilson Bilkovich

1/23/2006 4:18:00 PM

0

On 1/19/06, ruby talk <rubytalk@gmail.com> 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.