Kleine Anpassung: Pfadangabe ist nun optional (nutzt standardmäßig das jwlg. Arbeitsverzeichnis):
/**
* retrieves directory contents (for Internet Explorer / ActiveX)
* @param {String} [path] absolute or relative path to the respective directory (using the current working directory by default)
* @param {Boolean} [hideFolders] do not include sub-folders
* @param {Boolean} [hideFiles] do not include files
* @return {array} list of folders and files (returns false on error)
* @todo return object with files'/folders' name, size and date
* @todo opionally remove full path from results
*/
function dirListIE(path, hideFolders, hideFiles) {
if(path === "") { path = "./"; }
var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists(path)) {
return false; // DEBUG: return empty array?
} else {
var dir = fso.GetFolder(path);
var list = [];
// get subfolders
if(!hideFolders) {
var folders = new Enumerator(dir.SubFolders);
for(; !folders.atEnd(); folders.moveNext()) {
list.push(folders.item());
}
}
// get files
if(!hideFiles) {
var files = new Enumerator(dir.Files);
for(; !files.atEnd(); files.moveNext()) {
list.push(files.item());
}
}
return list;
}
}