Hello…
Still my old stuff that I re-publishing.
This class will let you scan your hd.
You have optional parameters:
- forceRoot : String, force the root of the scan ( eg : C:\data\image\ ) so then eg the folder “C:\data\image\test” will be listed as “\test”
- exceptions : Array, a list of folder you don’t wanna scan. Just give push the names in this array
[as]
/*
* Class written by Xavier MARTIN (xxlm or zeflasher)
* http://dev.webbymx.net
* http://www.webbymx.net
* If you are using this class, I will be glad to receive a postcard of your place ![]()
* To do so please visit http://dev.webbymx.net and go in the about page to get my details…
*/
import net.webbymx.zinc.DateManager;
dynamic class net.webbymx.zinc.FileSystemManager {
/******************************************************************************
* VARIABLES
******************************************************************************/
// EventDisptacher
private var dispatchEvent:Function;
public var addEventListener:Function;
public var removeEventListener:Function;
// private var tmpArray:Array;
// Dispatched
public var onScanCompleted:Function;
/******************************************************************************
* CONSTRUCTOR
******************************************************************************/
public function FileSystemManager () {
mx.events.EventDispatcher.initialize(this);
addEventListener(“onScanCompleted”, this);
}
/******************************************************************************
* PRIVATE FUNCTION
******************************************************************************/
/******************************************************************************
* PUBLIC FUNCTIONS
******************************************************************************/
// arguments[2] -> force root, arguments[3] -> exception (not scanning folder in this array)
function scanFolder(scanTo:String, returnArray:Array):Void {
var rootPath:String;
var dispatch:Boolean = true;
// adding the “/” at the end of the string if not here
if (scanTo.charAt(scanTo.length-1) != “/”) scanTo += “/”;
rootPath = scanTo;
switch (arguments.length) {
case 5:
// if we are in a recursive call
if (arguments[4] != undefined && typeof(arguments[4]) == ‘boolean’) dispatch = arguments[4];
case 4:
// if we have scan exception or if we are in a recursive call
if (arguments[3] != undefined && typeof(arguments[3]) == ‘object’ && arguments[3].length > 0) var exception:Array = arguments[3];
else if (arguments[3] != undefined && typeof(arguments[3]) == ‘boolean’) dispatch = arguments[3];
case 3:
// path to the root
if (arguments[2] != undefined && typeof(arguments[2]) == ‘string’) rootPath = arguments[2];
break;
}
// get all the file of the folder
var tmpFiles:Array = mdm.FileSystem.getFileList(scanTo, “*.*”);
if (tmpFiles.length > 0) {
var tmpArray:Array = new Array();
tmpArray = tmpFiles;
tmpFiles = new Array();
for (var i:Number = 0; i
if (exception != undefined) {
for (var j:Number = 0; j
ex = true;
break;
}
}
}
if (!ex) {
var fileArray:Array = new Array();
// filename
fileArray.push(tmpArray[i]);
// Last Time Modified Time
var fileDate:Date = DateManager.fileDate(mdm.FileSystem.getFileDate(scanTo+tmpArray[i]), mdm.FileSystem.getFileTime(scanTo+tmpArray[i]));
fileArray.push(fileDate);
// File Size
var fileSize:Number = mdm.FileSystem.getFileSize(scanTo+tmpArray[i]);
fileArray.push(fileSize);
// File Attribs
var fileAttribs:Array = mdm.FileSystem.getFileAttribs(scanTo+tmpArray[i]);
fileArray.push(fileAttribs);
// pushing the fileArray
tmpFiles.push(fileArray);
}
}
returnArray.push([rootPath, tmpFiles]);
}
// get all the folder of the folder
var allFolder:Array = mdm.FileSystem.getFolderList(scanTo);
for (var fld:Number = 0; fld
var found:Boolean = false;
for (var i:Number = 0; i
}
if (!found) scanFolder(scanTo+allFolder[fld]+"/", returnArray, rootPath+allFolder[fld]+"/", exception, false);
} else scanFolder(scanTo+allFolder[fld]+"/", returnArray, rootPath+allFolder[fld]+"/", false);
}
if (dispatch) dispatchEvent({type: "onScanCompleted", target: this});
}
/******************************************************************************
* GET & SET
******************************************************************************/
public function set owner(o) {_owner = o}
public function get owner():Object {return _owner}
}
[/as]
[Download id not defined]