[Win32utils-devel] [ANN] win32-driveinfo in CVS

Berger, Daniel Daniel.Berger at qwest.com
Tue Feb 8 09:14:57 EST 2005


Hi Heesob,

I have a couple problems with this.

First, I guess I didn't tell you, but I'm opposed to using Ruby/DL for
any of our packages.  It's just not stable, and has 64-bit issues that
are effectively unresolvable.  This could be a problem very soon with
64-bit Windows on the horizon.  You can read about Jamis Buck's negative
experience with Ruby/DL at
http://www.jamisbuck.org/jamis/blog.cgi/programming/ruby/Disappointments
%20in%20Ruby%20Land_20041230165456.tx

Contrary to whatever Matz has said about Win32API being deprecated, I am
officially declaring Ruby/DL dead for Win32Utils development and
Win32API to be the preferred choice for any pure Ruby development.  If
the Win32API package is ever removed from core Ruby, I will fork Ruby.

This is not an attack on you Heesob.  I should have mentioned this on
the list sooner, so it's my fault.  I hedged for a while on the issue
because I wasn't sure what the future held with regards to Win32API vs.
Ruby/DL.  Now that Ruby/DL has proven to be unreliable, I can be more
confident in sticking with Win32API.

That being said, I won't force you to rewrite it.  Just keep in mind
that all bugs, feature requests, etc, will be directed to *you*. :)

Second, I was hoping to keep the API similar to Mike Hall's "filesystem"
package.  Did you determine that it just wasn't feasible?  I made a
comment about it on the Feature Request.  If we can't make it
compatible, that's fine, but I thought we should at least try.

Regards,

Dan


> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org 
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of 
> Park Heesob
> Sent: Sunday, February 06, 2005 11:08 PM
> To: win32utils-devel at rubyforge.org
> Subject: [Win32utils-devel] [ANN] win32-driveinfo in CVS
> 
> 
> Hi all,
> 
> I committed win32-driveinfo 0.1.0 to CVS.
> 
> What is it?
> ===========
>  A class for  getting information of drives
>   
> Synopsis
> ========
>   include Win32::DriveInfo
> 
>     (sectorsPerCluster,
>      bytesPerSector,
>      numberOfFreeClusters,
>      totalNumberOfClusters,
>      freeBytesAvailableToCaller,
>      totalNumberOfBytes,
>      totalNumberOfFreeBytes) = getDriveSpace('c').to_a
>      
>      totalNumberOfFreeBytes = 
> getDriveSpace('c').TotalNumberOfFreeBytes
> 
>      totalNumberOfBytes = 
> getDriveSpace("\\\\serv\\share").TotalNumberOfBytes
> 
>      drives = getDrivesInUse()
> 
>      freelet = getFreeDriveLetters()
> 
>      drivetype = getDriveType('a')
>      
> 
>      (volumeName,
>       volumeSerialNumber,
>       maximumComponentLength,
>       fileSystemName, attr) = getVolumeInfo('g').to_a
>       
> 
>      (majorVersion, minorVersion, buildNumber,
>       platformId, buildStr) = getVersionEx().to_a
>    
>      # check is your CD-ROM loaded
>      aCDROM = getDrivesInUse().select {|x| getDriveType(x) == 
> "CDROM" }[0]
>      
>      aCD_inside = isReady(aCDROM)
>  
> Constants
> =========
> DriveInfo::VERSION
>  The current version of this package.
> DriveInfo::FS_CASE_IS_PRESERVED       
> DriveInfo::FS_CASE_SENSITIVE         
> DriveInfo::FS_UNICODE_STORED_ON_DISK 
> DriveInfo::FS_PERSISTENT_ACLS         
> DriveInfo::FS_VOL_IS_COMPRESSED       
> DriveInfo::FS_FILE_COMPRESSION       
>  
> Module Methods
> =====
> DriveInfo#getDriveSpace( drive )
>  Returns a structure that contains drivespace information 
> such as SectorsPerCluster, BytesPerSector, 
> NumberOfFreeClusters,TotalNumberOfClusters 
>    and FreeBytesAvailable, :TotalNumberOfBytes, 
> :TotalNumberOfFreeBytes
>   drive is drive-letter in either 'c' or 'c:' or 'c:\\' form 
> or UNC path
>            in either "\\\\server\\share" or 
> "\\\\server\\share\\" form.
> 
> DriveInfo#getDrivesInUse()
>  Returns sorted array of all drive-letters in use.
> 
> DriveInfo#getFreeDriveLetters()
>  Returns sorted array of all drive-letters that are available 
> for allocation.
> 
> DriveInfo#getDriveType(drive)
>  Returns string value:
>      "unknown"       - the drive type cannot be determined.   
>               
>      "no root dir"   - the root directory does not exist.     
>               
>      "Removable"     - the drive can be removed from the 
> drive (removable). 
>      "Fixed"         - the disk cannot be removed from the 
> drive (fixed).   
>      "Remote"        - the drive is a remote (network) drive. 
>               
>      "CDROM"         - the drive is a CD-ROM drive.           
>               
>      "RAM"         - the drive is a RAM disk.                 
>             
>      
>   drive is drive-letter in either 'c' or 'c:' or 'c:\\' form 
> or UNC path
>            in either "\\\\server\\share" or 
> "\\\\server\\share\\" form.
> 
> DriveInfo#isReady(drive)
>  Returns TRUE if root of the drive is accessible, otherwise 
> FALSE.  This one isn't really something cool - the function 
> just tries to  chdir to the drive's root. This takes time and 
> produces unpleasant  sound in case the removable drive is not 
> loaded. If somebody knows  some better way to determine is 
> there something inside your CD-ROM  or FDD - please let me 
> know (in fact CD-ROMs, RAM drives and network  drives return 
> their status fast,  may be some other devices make problem, dunno).
> 
>   drive is drive-letter in either 'c' or 'c:' or 'c:\\' form 
> or UNC path
>            in either "\\\\server\\share" or 
> "\\\\server\\share\\" form.
> 
> DriveInfo#getVolumeInfo(drive)
>  Returns a structure that contains Volume information such as
> 
>    VolumeName             - name of the specified volume.
>    VolumeSerialNumber     - volume serial number.
>    MaximumComponentLength -
>         filename component supported by the specified file system.
>         A filename component is that portion of a filename 
> between backslashes.
>         Indicate that long names are supported by the 
> specified file system.
>         For a FAT file system supporting long names, the 
> function stores
>         the value 255, rather than the previous 8.3 
> indicator. Long names can
>         also be supported on systems that use the New 
> Technology file system
>         (NTFS).
>    FileSystemName         - name of the file system (such as 
> FAT, FAT32, CDFS or NTFS).
>    attr                   - array of constants
>      FS_CASE_IS_PRESERVED - file system preserves the case of 
> filenames
>      FS_CASE_SENSITIVE - file system supports case-sensitive filenames
>      FS_UNICODE_STORED_ON_DISK - file system supports Unicode 
> in filenames as they appear on disk
>      FS_PERSISTENT_ACLS - file system preserves and enforces 
> ACLs (access-control lists).
>          For example, NTFS preserves and enforces ACLs, and 
> FAT does not.
>      FS_VOL_IS_COMPRESSED - file system supports file-based 
> compression
>      FS_FILE_COMPRESSION - specified volume is a compressed 
> volume; for ex., a DoubleSpace volume
>   drive is drive-letter in either 'c' or 'c:' or 'c:\\' form.
> 
> DriveInfo#getVersionEx(drive)
>   Returns a structure that contains Version information such as     
>    MajorVersion - major version number of the operating 
> system. For Windows NT
>                    version 3.51, it's 3; for Windows NT 
> version 4.0, it's 4; for Windows XP, Windows 2000 and 
>                    Windows 2003, it's 5.
> 
>    MinorVersion - minor version number of the operating 
> system. For Windows NT
>                    version 3.51, it's 51; for Windows NT 
> version 4.0, it's 0.
>    BuildNumber  - build number of the operating system.
>    PlatformId   - 0 for Win32s, 1 for Win95/98, 2 for Win NT
>    BuildStr     - Windows NT: Contains string, such as 
> "Service Pack 3".
>                    Indicates the latest Service Pack 
> installed on the system.
>                    If no Service Pack has been installed, the 
> string is empty.
>                    Windows 95: Contains a null-terminated 
> string that provides
>                    arbitrary additional information about the 
> operating system.
> 
> It is pure ruby implementation using Ruby/dl.
>  
> Regards,
> 
> Park Heesob
> 
> _______________________________________________
> win32utils-devel mailing list
> win32utils-devel at rubyforge.org 
> http://rubyforge.org/mailman/listinfo/win32utils-devel
> 
> 



More information about the win32utils-devel mailing list