mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I searched without finding reference to this.

$disk(drive_letter:\path).label does not return the volume label if the path exists.
mirc.hlp says you can use $disk(path|N), but $disk(path).label does not return the volume label if the 'path' is an existing foldername longer than c:\

$disk(c:\windows\).label does not return a value if c:\windows exists.

$disk(d:\windows\).label does return the volume label if d:\windows does not exists.

In both cases, the .free property is returning the free space.

If the 'path' is a filename, the volume label is returned whether or not the file exists. The only way I can get the .label property to not return the label is when the foldername exists.

If I create folder DTEST below mirc folder, then $disk(DTEST).label is blank and $disk(DTEST).free returns the free space from C: drive.

After i delete the DTEST folder, $disk(DTEST).label returns the volume label for the D: drive and $disk(DTEST).free returns the free space on the D: drive, even though the DTEST path doesn't contain a colon.

tested with mIRC 6.16 and 6.17

Joined: Aug 2005
Posts: 128
S
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
Of course it will return null if path is deeper. A directory does not have a label, only a drive does.
You may use this:
Code:
var %path = c:\windows
noop $regex(%path,/^([a-z]:(?:\\|\/))/i)
var %drive = $regml(1)
echo 4 -a Label name of driver that has the folder %path is: $disk(%drive).label

If you wanted to get 'windows' from c:\windows, this is not the label, this is the folder name.
You may use this:
Code:
var %path = c:\windows
if ($right(%path,1) == \) var %tpath = $nopath($left(%path,-1))
else var %tpath = $nopath(%path)
echo 4 -a %path => %tpath

Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Quote:
Of course it will return null if path is deeper. A directory does not have a label, only a drive does.


But mIRC is not being consistent. $disk(c:\windows\).free and $disk(c:\windows\).type and $disk(c:\windows\).size all return the appropriate values, while $disk(c:\windows\).label is being handled differently. You could argue that a directory doesn't have a .type either, and the .size is not related to a specific directory either. If it's not returning a value because directories don't have a label, then it shouldn't return the label for non-existant folders or existing c:\path\filenames either.

I wasn't needing to get 'windows' out of c:\windows, i was using it as an example of a foldername that should exist for most people. Like lots of bugs in the past, extra scripting can be added to handle it, I just wasn't expecting that I'd need to do that since all the other .prop didn't require it.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
I could be wrong, but I dont think mIRC's $disk identifier is ment to be used the way you are trying to use it.
from the help files:
Quote:

$disk(path|N)
Returns information about the specified hard disk, where N = 0 for total available drives, and N > 0 to access each drive.

Properties: type, free, label, size, unc, path

$disk(c:) returns $true if drive c: exists, otherwise $false

The unc property returns the path for a network drive.


all it is for is mounted drives, hard disks and CDrom drives, not folder Anything.
the Path you see is relating to a Networked drive not a file path.
maybe what you want is in other identifiers
$exists(file/dir)
Returns $true if a file or dir exists and $false if it doesn't.

$exists(c:\mirc\mirc.exe) returns $true or $false.

$file(filename)
Returns information about the specified file.
Properties: size, ctime, mtime, atime, shortfn, longfn, attr

$finddir(dir,wildcard,N,depth,@window | command)
Searches the specified directory and its subdirectories for the Nth directory name matching the wildcard specification and returns the full path and directory if it is found.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Attaching to the last message only, not directly replying to it.

The use of folders in a $disk() is ment to be there because a folder within a disk DOES NOT mean it is the same disk, windows NTFS drives have the ability to attach diskdrives into folders of other disks, if you specify such a folder you recieve information relating to the attached diskdrive , not the "parent" drive that contains the folder.

example
you have a C: and D: harddisk
on the C: you create a folder "C:\program files\morespace"
next click start/control panel/administitive tools/computer management/disk management and right click on D: and select "change drive letter and paths", click add then select "mount into the following empty NTFS folder", browse to "C:\program files\morespace" then OK your way back out

$disk(C:\) well refer to C:
$disk(C:\program files\morespace) well refer to D:

For this reason i can understand why .label results in $null is subfolderswhich are not attached drives, the folder is scaned for the LABEL directory entery and one is not found so the drive label is returned as $null, in my example above should D: been labeled PHYSICAL081 this would have been returned by $disk(C:\program files\morespace).label

Last edited by DaveC; 25/03/06 11:52 PM.

Link Copied to Clipboard