⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mas.fs.js

📁 Full ARM920T S3C2443 ( Magellan Maestro 4245/4250 ) WinCE FileBackup of stored "Windows" path. Hope
💻 JS
📖 第 1 页 / 共 2 页
字号:
		}
	}
}

// Copy file(s).
function _fs_copyFile (strFiles, strDest, bOverwrite)
{
	FSO.CopyFile (strFiles, strDest, bOverwrite);
}

// Move file(s).
function _fs_moveFile (strFiles, strDest)
{
	FSO.MoveFile (strFiles, strDest);
}

// Delete file(s).
function _fs_deleteFile (strFiles, bForce)
{
	FSO.DeleteFile (strFiles, bForce);
}

// Create a new folder.
function _fs_createFolder (strFolder)
{
	FSO.CreateFolder (strFolder);
}

// Delete folder(s).
function _fs_deleteFolder (strFolder, bForce)
{
	FSO.DeleteFolder (strFolder, bForce);
}

// Helper function for the _fs_tree function, generate tree view for one folder depth.
function _fs_tree_node (folder, glyphs, prefix, output)
{
	var strNode = "";
	var sf = new Enumerator(folder.SubFolders);
	
	// if we have results to process
	if (!sf.atEnd())
	{
		// get this item
		var item = sf.item();
		do
		{
			// move to next, reference stays on the previous until end of processing
			sf.moveNext();
			
			// process this item, sf collection already point on next
			// one to allow the use of .atEnd() to know if it's the last item.
			
			if (!sf.atEnd())
			{
				output.push(prefix + glyphs[0] + item.name);
				_fs_tree_node (item, glyphs, prefix+glyphs[1], output);
			}
			else
			{
				output.push(prefix + glyphs[2] + item.name);
				_fs_tree_node (item, glyphs, prefix+glyphs[3], output);
			}
			
			// update item to next
			item = sf.item();
		}
		while (!sf.atEnd())
	}
	
	return strNode;
}

// Display the subfolders tree in a text-based visual representation.
function _fs_tree ()
{
	var folder = FSO.GetFolder(MAS.Location);
	output = new Array();
	var glyphs = ["|-", "| ", "'-", "  "];
	output.push(folder.Name + "  ("+ folder.Path +")");
	_fs_tree_node (folder, glyphs, "", output);
	
	// crop the tree to console number of columns to prevent tree items spanning several display lines.
	output = MAS.Crop(output.join("\r\n"), "", MAS.Cols,0,true);
	// display result page by page.
	MAS.echo(MAS.paginate(output));
}

// Display drive volume name and serial number.
function _fs_label (strDriveSpec)
{
	// Drive letter
	var strDrive;
	if (strDriveSpec != undefined)
		strDrive = FSO.GetDriveName(strDriveSpec);
	else
		strDrive = FSO.GetDriveName(MAS.Location);
	var drive = FSO.GetDrive(strDrive);
	MAS.echo("Volume in drive "+ strDrive);
	
	// Volume Label
	var strLbl = drive.VolumeName;
	if (strLbl!="")
		MAS.echo("Volume label is "+ strLbl);
	else
		MAS.echo("Volume has no name");
	
	// Serial Number
	var strSN;
	if (drive.SerialNumber < 0)
		strSN = (0x100000000+drive.SerialNumber).toString(16).toUpperCase();
	else
		strSN = drive.SerialNumber.toString(16).toUpperCase();
	strSN = RightAlignString(strSN,8,'0');
	MAS.echo("Volume Serial Number is "+ strSN.substr(0,4)+"-"+strSN.substr(4,4));
}

// Helper for _fs_search function, search for files containing specific text in a single folder depth.
function _fs_searchInFolder (fsoFolder, filespec, strText, bSearchSubFolders)
{
	Echo();
	Echo("Folder \""+ fsoFolder.Path +"\".");
	
	var strTextUpperCase = strText.toUpperCase();

	// Files
	var f = new Enumerator(fsoFolder.Files);
	for (f.moveFirst() ; !f.atEnd() ; f.moveNext() )
	{
		var file = f.item();
		if (file.Name.toUpperCase().match(filespec) != null)
		{
			// search file as ASCII
			var txtstream = file.openAsTextStream(1, 0);
			var iLine = 1;
			// read file line by line
			while (!txtstream.atEndOfStream)
			{
				var s = txtstream.readLine();
				// check if searched string is in this line
				var iIndex = s.toUpperCase().indexOf(strTextUpperCase);
				if (iIndex != -1)
				{
					var iStart = iIndex-10;
					if (iStart < 0) iStart = 0;
					var iEnd = iIndex + strText.length + 10;
					if (iEnd > s.length) iEnd = s.length;
					
					Echo("\""+ file.Name +"\" at "+ iLine.toString() +","+ (iIndex+1).toString() +" : \""+ (iStart!=0?"...":"") + s.substring(iStart,iEnd) + (iEnd!=s.length?"...":"") +"\"");
				}
				iLine++;
			}
			txtstream.close();
			
			// search file as Unicode
			txtstream = file.openAsTextStream(1, -1);
			iLine = 1;
			// read file line by line
			while (!txtstream.atEndOfStream)
			{
				var s = txtstream.readLine();
				// check if searched string is in this line
				var iIndex = s.indexOf(strText);
				if (iIndex != -1)
				{
					var iStart = iIndex-10;
					if (iStart < 0) iStart = 0;
					var iEnd = iIndex + strText.length + 10;
					if (iEnd > s.length) iEnd = s.length;
					
					Echo("\""+ file.Name +"\" (Unicode) at "+ iLine.toString() +","+ (iIndex+1).toString() +" : \""+ (iStart!=0?"...":"") + s.substring(iStart,iEnd) + (iEnd!=s.length?"...":"") +"\"");
				}
				iLine++;
			}
			txtstream.close();
		}
	}
	
	// Subfolders
	if (bSearchSubFolders)
	{
		var sf = new Enumerator(fsoFolder.SubFolders);
		for (sf.moveFirst() ; !sf.atEnd() ; sf.moveNext() )
		{
			var folder = sf.item();
			_fs_searchInFolder (folder, filespec, strText, bSearchSubFolders);
		}
	}
}

// Search for files containing specific text.
function _fs_search(strFileSpec, strText, bSearchSubFolders)
{
	var folder = FSO.GetFolder(MAS.Location);
	var filespec = FileSpec2RegExp(strFileSpec);
	_fs_searchInFolder (folder, filespec, strText, bSearchSubFolders);
	Echo();
}

function _fs_cd(strFolder)
{
	MAS.Location.Set(strFolder);
}

function _fs_pushd(strFolder)
{
	MAS.Location.Push(strFolder);
}

function _fs_popd()
{
	MAS.Location.Pop();
}

// Shows all volumes and their used / free capacities
function _fs_driveschart()
{
	echo();
	echo("Volumes sizes and uses");
	echo("----------------------");
	var d = FSO.getDrive("\\");
	echo( "Object Store (\\) : "+ d.freeSpace.toByteSizeString() +" / "+ d.totalSize.toByteSizeString() +" ("+ Math.round(100-d.freeSpace*100/d.totalSize) +"% used)" );
	var e = new Enumerator(FSO.drives);
	for (e.moveFirst();!e.atEnd();e.moveNext())
	{
		d = e.item();
		try
		{
			echo( d.name +" : "+ d.freeSpace.toByteSizeString() +" / "+ d.totalSize.toByteSizeString() +" ("+ Math.round(100-d.freeSpace*100/d.totalSize) +"% used)" );
		}
		catch(ex)
		{
			echo( d.name +" : Unknown use" );
		}
	}
	echo();
}

// Declare the FS constructor
function fsobject()
{
	this.ver = _fs_ver;
	this.prompt = _fs_prompt;
	this.getFolder = _fs_get_folder;
	this.getFiles = _fs_get_files;
	this.getFolders = _fs_get_folders;
	this.dir = _fs_dir;
	this.ls = _fs_dir;
	this.attrib = _fs_attrib;
	this.call = _fs_call;
	this.copy = _fs_copyFile;
	this.move = _fs_moveFile;
//	this.delete = _fs_deleteFile;	// delete cannot be used because it is a reserved keyword
	this.erase = _fs_deleteFile;
	this.mkdir = _fs_createFolder;
	this.md = _fs_createFolder;
	this.rmdir = _fs_deleteFolder;
	this.rd = _fs_deleteFolder;
	this.tree = _fs_tree;
	this.label = _fs_label;
	this.search = _fs_search;
	this.cd = _fs_cd;
	this.pushd = _fs_pushd;
	this.popd = _fs_popd;
	this.driveschart = _fs_driveschart;
}
// Create the fs object
var fs = new fsobject();

// Set MASX prompt to fs.prompt,
// only if FSO is available to avoid errors on prompts
if (FSO != null)
	new function prompt(){ return fs.prompt(); }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -