Xwidget does not have a function to return a list of drive volumes.
This code mimics the yahoo widget filesystem.volumes function using activeX. Dropping this code into your script.js file will provide this functionality.
Code:
//==============================================================
// this function is the ActiveX version of filesystem.volumes function;
//==============================================================
function filesystemVolumes() {
var nobj, result, n, e, x;
result = "";
nobj = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(nobj.Drives);
for (; !e.atEnd(); e.moveNext()) {
x = e.item();
result = ''+result + x.DriveLetter+':';
result += " - ";
if (x.DriveType == 3) n = x.ShareName;
else if (x.IsReady)
n = x.VolumeName;
else n = "(Not ready)"; result += n + "|";
}
// change the string to an array
result = result.split("|");
return(result);
}
//=====================
//End function
//=====================
How would you use it?
Example:
Code:
var vols = filesystemVolumes(); //var vols = filesystem.volumes;
//print (" drives = "+ drives);
//count the drive volumes, create new images for each drive
for (a in vols) {
if (vols.hasOwnProperty(a)) {
volscnt = Number(a);
//nn = vols[a].substr(0,2) ;
if (debugFlg == 1) {print ("drives available "+vols[a].substr(0,2) )};
if (preferencesMusicFolderPrefValue.text == vols[a].substr(0,2)) {
if (debugFlg == 1) {print ("restricting access to the root")};
preferencesMusicFolderPrefValue.text = "C:\\Users\\Public\\Music";
//C:\\Documents and Settings\\All Users\\Documents\\My Music";
}
}
}
Naming the new function filesystemVolumes means that any conversion of an Yahoo widget that uses the filesystem.volumes code is much easier. These type of translated functions can be added to any Xwidget and the simple removal of a '.' will make the old yahoo widget code compatible.