Blog

MDM Zinc – Class FileSystemManager

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

  • vossler

    Hi zeflasher

    I really appreciate the work you did! I am curious about the filesystemmanager Class, how do i apply to a really script?

    Do I have to creat a flash document? and then apply this class to it? or open zinc applicaiton to do so? could you give me a quick hint? thank a lot!

    vossler

  • vossler

    Hi zeflasher

    I really appreciate the work you did! I am curious about the filesystemmanager Class, how do i apply to a really script?

    Do I have to creat a flash document? and then apply this class to it? or open zinc applicaiton to do so? could you give me a quick hint? thank a lot!

    vossler