com.tuneology.avm.drive
Class Drive

java.lang.Object
  |
  +--com.tuneology.avm.drive.Drive
Direct Known Subclasses:
CDDrive, LoopbackDrive

public class Drive
extends java.lang.Object

This class implements native operations that are not otherwise available from Java.

Version:
$Id: Drive.java,v 1.16 2003/06/19 17:55:54 xnarf Exp $
Author:
Fran Taylor

Field Summary
protected  DriveEntry ent
           
protected  int refNum
          private OSX variable
static int TYPE_CDR
          value returned by getDriveType
static int TYPE_CDROM
          value returned by getDriveType
static int TYPE_CDRW
          value returned by getDriveType
static int TYPE_DVD
          value returned by getDriveType
static int TYPE_DVDR
          value returned by getDriveType
static int TYPE_DVDRAM
          value returned by getDriveType
static int TYPE_EJECTABLE
          value returned by getDriveType
static int TYPE_FIXEDDISC
          value returned by getDriveType
static int TYPE_FLOPPY
          value returned by getDriveType
static int TYPE_LOADABLE
          value returned by getDriveType
static int TYPE_LOOPBACK
          value returned by getDriveType
static int TYPE_NETWORK
          value returned by getDriveType
static int TYPE_OTHER
          value returned by getDriveType
static int TYPE_REMOVABLE
          value returned by getDriveType
 
Constructor Summary
protected Drive(DriveEntry ent)
           
 
Method Summary
static DriveEntry findDriveByDevice(java.lang.String dev)
           
static DriveEntry findDriveByScsiId(java.lang.String id)
           
static MountPoint findMountPointByDevice(java.lang.String dev)
           
static DriveEntry getDefaultCDROM()
          Returns the first CD-ROM capable device in the drive list.
 java.lang.String getDevice()
          Returns the device name.
static java.util.ArrayList getDisktoolCmd()
           
static Drive getDrive(DriveEntry ent)
          Returns a new Drive object for the specified drive.
static DriveEntry[] getDriveList()
          Returns a list of drives present on the computer.
 int getDriveType()
          Returns the type of the drive.
static int getDriveType(java.lang.String dev)
          Returns the type of the drive.
 DriveEntry getEntry()
           
static java.util.ArrayList getHdiutilCmd()
           
 java.lang.String getManufacturer()
          Returns the device's manufacturer.
 java.lang.String getModel()
          Returns the device's model name.
static MountPoint getMountPoint(java.lang.String path)
          Returns the mount point corresponding to the path If there are nested mount points, this will return the deepest nested point.
 MountPoint[] getMountPoints()
          Returns the mount point.
 int getNameMax()
          Returns the maximum number of characters in a filename for this file system.
 java.lang.String getScsiId()
          Returns the scsi ID of the drive.
static java.lang.String getScsiId(java.lang.String dev)
          returns the SCSI ID of the device
 java.lang.String getVersion()
          Returns the device's firmware revision.
static java.lang.String getVersions()
          returns the versions of the programs used.
static boolean isCDR(int typ)
          Returns true if the device type is a CD-R.
static boolean isCdrom(int typ)
          Returns true if the device type is a CD-ROM.
static void setDiscFreeCmd(java.lang.String str)
          Only needed for POSIX.
static void setDisktoolCmd(java.lang.String str)
           
static void setFstabPath(java.lang.String str)
          Only needed for POSIX.
static void setHdiutilCmd(java.lang.String str)
           
static void setMountCmd(java.lang.String str)
           
static void setUmountCmd(java.lang.String str)
           
static void touch()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ent

protected DriveEntry ent

refNum

protected int refNum
private OSX variable

TYPE_FIXEDDISC

public static final int TYPE_FIXEDDISC
value returned by getDriveType

TYPE_FLOPPY

public static final int TYPE_FLOPPY
value returned by getDriveType

TYPE_CDROM

public static final int TYPE_CDROM
value returned by getDriveType

TYPE_CDR

public static final int TYPE_CDR
value returned by getDriveType

TYPE_CDRW

public static final int TYPE_CDRW
value returned by getDriveType

TYPE_DVD

public static final int TYPE_DVD
value returned by getDriveType

TYPE_DVDR

public static final int TYPE_DVDR
value returned by getDriveType

TYPE_DVDRAM

public static final int TYPE_DVDRAM
value returned by getDriveType

TYPE_REMOVABLE

public static final int TYPE_REMOVABLE
value returned by getDriveType

TYPE_EJECTABLE

public static final int TYPE_EJECTABLE
value returned by getDriveType

TYPE_LOADABLE

public static final int TYPE_LOADABLE
value returned by getDriveType

TYPE_NETWORK

public static final int TYPE_NETWORK
value returned by getDriveType

TYPE_LOOPBACK

public static final int TYPE_LOOPBACK
value returned by getDriveType

TYPE_OTHER

public static final int TYPE_OTHER
value returned by getDriveType
Constructor Detail

Drive

protected Drive(DriveEntry ent)
         throws java.lang.Exception
Parameters:
driveType -  
Throws:
java.lang.Exception -  
See Also:
getDrive(DriveEntry)
Method Detail

getDrive

public static Drive getDrive(DriveEntry ent)
                      throws java.lang.Exception
Returns a new Drive object for the specified drive. Automatically determines the correct type of drive.
Parameters:
path - the path of the desired drive.
Throws:
java.lang.Exception -  

getEntry

public DriveEntry getEntry()

getDriveType

public int getDriveType()
Returns the type of the drive. (see the TYPE_ constants for possible values).
Returns:
the drive type, one of

getDriveType

public static int getDriveType(java.lang.String dev)
                        throws java.lang.Exception
Returns the type of the drive. (see the TYPE_ constants for possible values)
Parameters:
dev - the path of the device.
Returns:
the type of the drive.
Throws:
java.lang.Exception -  

findMountPointByDevice

public static MountPoint findMountPointByDevice(java.lang.String dev)
                                         throws java.lang.Exception
Parameters:
dev -  
Throws:
java.lang.Exception -  

findDriveByDevice

public static DriveEntry findDriveByDevice(java.lang.String dev)
                                    throws java.lang.Exception
Parameters:
dev -  
Throws:
java.lang.Exception -  

findDriveByScsiId

public static DriveEntry findDriveByScsiId(java.lang.String id)
                                    throws java.lang.Exception
Parameters:
id -  
Throws:
java.lang.Exception -  

getDriveList

public static DriveEntry[] getDriveList()
                                 throws java.lang.Exception
Returns a list of drives present on the computer.
Returns:
an array of strings containing drive names.
Throws:
java.lang.Exception -  

getDefaultCDROM

public static DriveEntry getDefaultCDROM()
                                  throws java.lang.Exception
Returns the first CD-ROM capable device in the drive list.
Returns:
the first CD-ROM capable device in the drive list.
Throws:
java.lang.Exception -  

getScsiId

public java.lang.String getScsiId()
Returns the scsi ID of the drive.
Returns:
the scsi ID of the drive.

getMountPoints

public MountPoint[] getMountPoints()
Returns the mount point.
Returns:
the mount point.

getDevice

public java.lang.String getDevice()
Returns the device name.
Returns:
the device name

getManufacturer

public java.lang.String getManufacturer()
Returns the device's manufacturer.
Returns:
the device's manufacturer.

getModel

public java.lang.String getModel()
Returns the device's model name.
Returns:
the device's model name.

getVersion

public java.lang.String getVersion()
Returns the device's firmware revision.
Returns:
the device's firmware revision.

setDiscFreeCmd

public static void setDiscFreeCmd(java.lang.String str)
                           throws java.io.IOException
Only needed for POSIX.

setFstabPath

public static void setFstabPath(java.lang.String str)
                         throws java.io.IOException
Only needed for POSIX.

isCdrom

public static boolean isCdrom(int typ)
Returns true if the device type is a CD-ROM.

isCDR

public static boolean isCDR(int typ)
Returns true if the device type is a CD-R.

getVersions

public static java.lang.String getVersions()
returns the versions of the programs used.
Returns:
the versions of the programs used.

getNameMax

public int getNameMax()
Returns the maximum number of characters in a filename for this file system.
Returns:
the maximum number of characters in a filename for this file system.

getScsiId

public static java.lang.String getScsiId(java.lang.String dev)
returns the SCSI ID of the device
Returns:
the SCSI ID of the device as a string like "0,0,0"

setHdiutilCmd

public static void setHdiutilCmd(java.lang.String str)
                          throws java.lang.Exception
Parameters:
str -  
Throws:
java.lang.Exception -  

getHdiutilCmd

public static java.util.ArrayList getHdiutilCmd()

setDisktoolCmd

public static void setDisktoolCmd(java.lang.String str)
                           throws java.lang.Exception
Parameters:
str -  
Throws:
java.lang.Exception -  

getDisktoolCmd

public static java.util.ArrayList getDisktoolCmd()

setMountCmd

public static void setMountCmd(java.lang.String str)
                        throws java.io.IOException
Parameters:
str -  

setUmountCmd

public static void setUmountCmd(java.lang.String str)
                         throws java.io.IOException
Parameters:
str -  

getMountPoint

public static MountPoint getMountPoint(java.lang.String path)
                                throws java.lang.Exception
Returns the mount point corresponding to the path If there are nested mount points, this will return the deepest nested point. For example: Suppose your disk setup looks like this:
foo% mount

/dev/disk1 on /
/dev/disk2 on /opt/
/dev/disk3 on /opt/disk
...

Thus getMountPoint("/opt/disk/mp3/foo.mp3") will return the entry for /dev/disk3; getMountPoint("/opt/foo/") will return the entry for /dev/disk2, and getMountPoint("/usr/local/foo"); will return the entry for /.

touch

public static void touch()