CSplitpath:GetDir CSplitpath:GetExt

CSplitpath:GetDrive


The GetDrive method returns the drive name, like C:, from a CSplitpath object.

Syntax

sDrive = CSplitpath:GetDrive()

 

    On success, this method returns a string containing the drive name.

    On failure, this method returns nil.

Example

Suppose a file exists with a full path named sPath. The following script fragment retrieves the drive name component:

 

S = CSplitpath:new()

-- create a CSplitpath object

S:SetPath(sPath)

-- Specify the path to be split

sDrive = S:GetDrive()

-- assigns the drive name component to the string sDrive.

S:delete()

-- when done with S, remove it from memory

Related Topics

CSplitpath