NAME

Win32::DriveInfo - drives on Win32 systems


SYNOPSIS

    use Win32::DriveInfo; 

    ($SectorsPerCluster,      $BytesPerSector,      $NumberOfFreeClusters,      $TotalNumberOfClusters,      $FreeBytesAvailableToCaller,      $TotalNumberOfBytes,      $TotalNumberOfFreeBytes) = Win32::DriveInfo::DriveSpace('f'); 

     $TotalNumberOfFreeBytes = (Win32::DriveInfo::DriveSpace('c:'))[6]; 

     $TotalNumberOfBytes = (Win32::DriveInfo::DriveSpace("\\\\serv\\share"))[5]; 

     @drives = Win32::DriveInfo::DrivesInUse(); 

     @freelet = Win32::DriveInfo::FreeDriveLetters(); 

     $type = Win32::DriveInfo::DriveType('a'); 

     ($VolumeName,       $VolumeSerialNumber,       $MaximumComponentLength,       $FileSystemName, @attr) = Win32::DriveInfo::VolumeInfo('g'); 

     ($MajorVersion, $MinorVersion, $BuildNumber,       $PlatformId, $BuildStr) = Win32::DriveInfo::GetVersionEx(); 


ABSTRACT

With this module you can get total/free space on Win32 drives, volume names, architecture, filesystem type, drive attributes, list of all available drives and free drive-letters. Additional function to determine Windows version info.

The intention was to have a part of Dave Roth's Win32::AdminMisc functionality on Win95/98.

The current version of Win32::DriveInfo is available at:

  http://www.dux.ru/guest/fno/perl/ 


DESCRIPTION

Module provides few functions:

DriveSpace ( drive )
($SectorsPerCluster, $BytesPerSector, $NumberOfFreeClusters, $TotalNumberOfClusters, $FreeBytesAvailableToCaller, $TotalNumberOfBytes, $TotalNumberOfFreeBytes) = Win32::DriveInfo::DriveSpace( drive );

   drive - drive-letter in either 'c' or 'c:' or 'c:\\' form or UNC path            in either "\\\\server\\share" or "\\\\server\\share\\" form.    $SectorsPerCluster          - number of sectors per cluster.    $BytesPerSector             - number of bytes per sector.    $NumberOfFreeClusters       - total number of free clusters on the disk.    $TotalNumberOfClusters      - total number of clusters on the disk.    $FreeBytesAvailableToCaller - total number of free bytes on the disk that                                  are available to the user associated with the                                  calling thread, b.    $TotalNumberOfBytes         - total number of bytes on the disk, b.    $TotalNumberOfFreeBytes     - total number of free bytes on the disk, b. 

Note: in case that UNC path was given first 4 values are undef.

Win 95 note: Win32 API GetDiskFreeSpaceEx() function that is realized by internal (not intended for users) GetDiskFreeSpaceEx() subroutine is available on Windows 95 OSR2 (OEM Service Release 2) only. This means build numbers ( $BuildNumber in GetVersionEx ( ) function, described here later) greater then 1000.

On lower Win95 builds $FreeBytesAvailableToCaller, $TotalNumberOfBytes, $TotalNumberOfFreeBytes are realized through the internal GetDiskFreeSpace() function that is claimed less trustworthy in Win32 SDK documentation.

That's why on lower Win 95 builds this function will return 7 undef's for UNC drives.

To say in short: don't use DriveSpace ( ) for UNC paths on early Win 95! Where possible use

  net use * \\server\share 

and then usual '\w:' syntax.

DrivesInUse ( )
Returns sorted array of all drive-letters in use.

FreeDriveLetters ( )
Returns sorted array of all drive-letters that are available for allocation. версия для печати

DriveType ( drive )
Returns integer value:

   0     - the drive type cannot be determined.    1     - the root directory does not exist.    2     - the drive can be removed from the drive (removable).    3     - the disk cannot be removed from the drive (fixed).    4     - the drive is a remote (network) drive.    5     - the drive is a CD-ROM drive.    6     - the drive is a RAM disk.      drive - drive-letter in either 'c' or 'c:' or 'c:\\' form or UNC path            in either "\\\\server\\share" or "\\\\server\\share\\" form. 

In case of UNC path 4 will be returned that means that networked drive is available (1 - if not available).

VolumeInfo ( drive )
($VolumeName, $VolumeSerialNumber, $MaximumComponentLength, $FileSystemName, @attr) = Win32::DriveInfo::VolumeInfo ( drive );

   drive - drive-letter in either 'c' or 'c:' or 'c:\\' form. 

   $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 or NTFS).    @attr                   - array of integers 1-6      1 - file system preserves the case of filenames      2 - file system supports case-sensitive filenames      3 - file system supports Unicode in filenames as they appear on disk      4 - file system preserves and enforces ACLs (access-control lists).          For example, NTFS preserves and enforces ACLs, and FAT does not.      5 - file system supports file-based compression      6 - specified volume is a compressed volume; for ex., a DoubleSpace volume 

GetVersionEx ( )
This function provides version of the OS in use.

($MajorVersion, $MinorVersion, $BuildNumber, $PlatformId, $BuildStr) = Win32::DriveInfo::GetVersionEx ( );

   $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. 

   $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. 

You need Win32::API.pm by Aldo Calpini to use this module.

Nothing is exported by default. All functions return undef on errors.


INSTALLATION

As this is just a plain module no special installation is needed. Just put it into /Win32 subdir somewhere in your @INC.


CAVEATS

This module has been created and tested in a Win95 environment on GS port of Perl 5.004_02. As it uses Win32::API module I expect it would work fine with other ports like ActiveState if Win32::API (API.dll) is compiled for this port.


CHANGES

 0.02 - Austin Durbin <adurbin@earthlink.net> tested module on Win NT         and discovered small bug in UNC paths handling. Fixed.         Thanks Austin!   . 

 0.03 - fixed bug that returned incorrect values for volumes that are         larger than 0xffffffff bytes (4GB). Approved on Win98 with FAT32. 


BUGS

Please report.


VERSION

This man page documents Win32::DriveInfo.pm version 0.03.

April 6, 1999.


AUTHOR

Mike Blazer <blazer@mail.nevalink.ru>


COPYRIGHT

Copyright (C) 1998, 1999 by Mike Blazer. All rights reserved.


LICENSE

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.