      1 ﻿
      2 /**
      3  * @name	CeL file function for Windows
      4  * @fileoverview
      5  * 本檔案包含了 Windows 的 file functions。
      6  * @since	2009/12/1
      7  */
      8
      9 /*
     10  * TODO
     11  * http://www.comsharp.com/GetKnowledge/zh-CN/It_News_K869.aspx
     12  */
     13
     14 if (typeof CeL === 'function'){
     15
     16 /**
     17  * 本 module 之 name(id)，<span style="text-decoration:line-through;">不設定時會從呼叫時之 path 取得</span>。
     18  * @type	String
     19  * @constant
     20  * @inner
     21  * @ignore
     22  */
     23 var module_name = 'IO.Windows.file';
     24
     25 //===================================================
     26 /**
     27  * 若欲 include 整個 module 時，需囊括之 code。
     28  * @type	Function
     29  * @param	{Function} library_namespace	namespace of library
     30  * @param	load_arguments	呼叫時之 argument(s)
     31  * @return
     32  * @name	CeL.IO.Windows.file
     33  * @constant
     34  * @inner
     35  * @ignore
     36  */
     37 var code_for_including = function(library_namespace, load_arguments) {
     38
     39
     40 /**
     41  * null module constructor
     42  * @class	Windows 下，檔案操作相關之 function。
     43  */
     44 CeL.IO.Windows.file
     45 = function() {
     46 	//	null module constructor
     47 };
     48
     49 /**
     50  * for JSDT: 有 prototype 才會將之當作 Class
     51  */
     52 CeL.IO.Windows.file
     53 .prototype = {
     54 };
     55
     56
     57
     58 /*
     59 	JScript only	-------------------------------------------------------
     60 */
     61
     62 CeL.IO.Windows.file
     63 .
     64 /**
     65  * FileSystemObject Object I/O mode enumeration
     66  * @see	<a href="http://msdn.microsoft.com/en-us/library/314cz14s%28VS.85%29.aspx" accessdate="2009/11/28 17:42" title="OpenTextFile Method">OpenTextFile Method</a>
     67  * @memberOf	CeL.IO.Windows.file
     68  */
     69 iomode = {
     70 	// * @_description <a href="#.iomode">iomode</a>: Open a file for reading only. You can't write to this file.
     71 	/**
     72 	 * Open a file for reading only. You can't write to this file.
     73 	 * @memberOf	CeL.IO.Windows.file
     74 	 */
     75 	ForReading : 1,
     76 	/**
     77 	 * Open a file for writing.
     78 	 * @memberOf	CeL.IO.Windows.file
     79 	 */
     80 	ForWriting : 2,
     81 	/**
     82 	 * Open a file and write to the end of the file.
     83 	 * @memberOf	CeL.IO.Windows.file
     84 	 */
     85 	ForAppending : 8
     86 };
     87
     88 CeL.IO.Windows.file
     89 .
     90 /**
     91  * FileSystemObject Object file open format enumeration
     92  * @see	<a href="http://msdn.microsoft.com/en-us/library/314cz14s%28VS.85%29.aspx" accessdate="2009/11/28 17:42" title="OpenTextFile Method">OpenTextFile Method</a>
     93  * @memberOf	CeL.IO.Windows.file
     94  */
     95 open_format = {
     96 	/**
     97 	 * Opens the file using the system default.
     98 	 * @memberOf	CeL.IO.Windows.file
     99 	 */
    100 	TristateUseDefault : -2,
    101 	/**
    102 	 * Opens the file as Unicode.
    103 	 * @memberOf	CeL.IO.Windows.file
    104 	 */
    105 	TristateTrue : -1,
    106 	/**
    107 	 * Opens the file as ASCII.
    108 	 * @memberOf	CeL.IO.Windows.file
    109 	 */
    110 	TristateFalse : 0
    111 };
    112
    113
    114 var path_separator = library_namespace.env.path_separator, path_separator_RegExp = library_namespace.env.path_separator_RegExp, new_line = library_namespace.env.new_line, WshShell,
    115 /**
    116  * FileSystemObject
    117  * @inner
    118  * @ignore
    119  * @see
    120  * <a href="http://msdn.microsoft.com/en-us/library/z9ty6h50%28VS.85%29.aspx" accessdate="2010/1/9 8:10">FileSystemObject Object</a>
    121  */
    122 fso = WScript.CreateObject("Scripting.FileSystemObject"),
    123 // XMLHttp,
    124 WinShell // initWScriptObj
    125 , args, ScriptHost;
    126
    127
    128 /*	↑JScript only	-------------------------------------------------------
    129 */
    130
    131
    132
    133
    134 /*
    135
    136 return {Object} report
    137 	.list	files matched
    138 	.succeed	success items
    139 	.failed	failed items
    140 	.log	log text
    141 	.undo	undo data
    142
    143 usage example:
    144 	move_file()	get file list array of current dir.
    145 	move_file(0,0,'dir')	get file list array of dir.
    146 	move_file('*.*','*.jpg','dir')	Error! Please use RegExp('.*\..*') or turnWildcardToRegExp('*.*')
    147 	move_file(/file(\d+).jpg/,0,'dir')	get file list array of dir/file(\d+).jpg
    148 	move_file(f1,move_file.f.remove)	delete f1
    149 	move_file('f1','f2')	[f1]->[f2]
    150 	move_file('f1','f2','.',move_file.f.copy|move_file.f.reverse)	copy [./f2] to [./f1]
    151 	move_file(/file(\d+).jpg/,/file ($1).jpg/,'dir')	[dir/file(\d+).jpg]->[dir/file ($1).jpg]	can't use fuzzy or reverse in this time
    152
    153 prog example:
    154 	function move_file_filter(fn){var n=fn.match(/0000(\d+)\(\d\)\.pdf/);if(!n)return true;n=n[1];if(n!=0&&n!=1&&n!=7&&n!=10&&n!=13&&n!=15&&n!=26&&n!=28)return true;try{n=fn.match(/(\d+)\(\d\)\.pdf/);FileSystemObject.MoveFile(n[1]+'('+(n[1]?vol-1:vol-2)+').pdf',n[1]+'.pdf');}catch(e){}return;}
    155 	var vol=11,doMove=move_file(new RegExp('(\\d+)\\('+vol+'\\)\\.pdf'),'$1.pdf');
    156 	write_file('move.log','-'.x(60)+new_line+doMove.log,open_format.TristateTrue,ForAppending);
    157 	write_file('move.undo.'+vol+'.txt',doMove.undo,open_format.TristateTrue),write_file('move.undo.'+vol+'.bat',doMove.undo);//bat不能用open_format.TristateTrue
    158 	alert('Done '+doMove.succeed+'/'+doMove.list.length);
    159
    160 	for Win98, turn lower case:
    161 	move_file(/^[A-Z\d.]+$/,function($0){return '_mv_tmp_'+$0.toLowerCase();},'.',move_file.f.include_folder|move_file.f.include_subfolder);
    162 	alert(move_file(/^_mv_tmp_/,'','.',move_file.f.include_folder|move_file.f.include_subfolder).log);
    163
    164
    165 for(var i=0,j,n,m;i<40;i++)
    166  if(!fso.FileExists(n='0000'+(i>9?'':'0')+i+'.pdf'))for(j=0;j<25;j++)
    167   if(fso.FileExists(m='0000'+(i>9?'':'0')+i+'('+j+').pdf')){try{fso.MoveFile(m,n);}catch(e){}break;}
    168
    169 TODO:
    170 move newer	把新檔移到目的地，舊檔移到 bak。
    171
    172 */
    173 CeL.IO.Windows.file
    174 .
    175 /**
    176  * move/rename files, ** use RegExp, but no global flag **<br/>
    177  * 可用 move_file_filter() 來排除不要的<br/>
    178  * 本函數可能暫時改變目前工作目錄！
    179  * @param {String} from	from file
    180  * @param {String} to	to file
    181  * @param {String} base_path	base path
    182  * @param flag
    183  * @param {Function} filter	可用 filter() 來排除不要的
    184  * @return	{Object} report
    185  * @since	2004/4/12 17:25
    186  * @requires	path_separator,fso,WshShell,new_line,Enumerator
    187  * @memberOf	CeL.IO.Windows.file
    188  */
    189 move_file = function move_file(from, to, base_path, flag, filter) {
    190 	var _s = move_file.f ? move_file : _.move_file, _f = _s.f,
    191 	// '.?': 一定會match
    192 	default_from = new RegExp('.?'), t, CurrentDirectory, report = {};
    193 	//library_namespace.debug(typeof from + ',' + from.constructor);
    194 	if (flag & _f.reverse)
    195 		//flag-=_f.reverse,
    196 		t = from, from = to, to = t;
    197 	if (!from)
    198 		from = default_from;
    199 	else if (typeof from !== 'string'
    200 		&& (typeof from !== 'object' || !(from instanceof RegExp)
    201 				&& !(from = '' + from)))
    202 		from = default_from;
    203 	report.list = [], report.succeed = report.failed = 0,
    204 	report.undo = report.log = '';
    205
    206 	if (!base_path)
    207 		base_path = '.' + path_separator;
    208 	else if (typeof get_folder === 'function')
    209 		base_path = get_folder(base_path);
    210
    211 	if ((base_path = '' + base_path).slice(
    212 			// -1, or try: base_path.length-path_separator.length
    213 			-1) != path_separator)
    214 		base_path += path_separator;
    215
    216 	if (typeof fso === 'undefined')
    217 		fso = new ActiveXObject("Scripting.FileSystemObject");
    218 	else if (typeof fso !== 'object')
    219 		throw new Error(1, 'FSO was already seted!');
    220 	try {
    221 		dir = fso.GetFolder(base_path);
    222 	} catch (e) {
    223 		throw new Error(e.number,
    224 				'move_file(): 基準路徑不存在\n' + e.description);
    225 	}
    226
    227 	// TODO: 對from不存在與為folder之處裡: fuzzy
    228
    229 	if (flag & _f.include_subfolder) {
    230 		CurrentDirectory = WshShell.CurrentDirectory;
    231 		for ( var i = new Enumerator(dir.SubFolders); !i.atEnd(); i
    232 		.moveNext())
    233 			_s(from, to, i.item(), flag);
    234 		if (base_path)
    235 			// 改變目前工作目錄
    236 			WshShell.CurrentDirectory = base_path;
    237 	}
    238 	// if(flag&_f.include_folder){}
    239 	var i, f = new Enumerator(dir.Files), use_exact = typeof from === 'string', overwrite = flag
    240 	& _f.overwrite, not_test = !(flag & _f.Test), func = flag
    241 	& _f.copy ? 'copy' : to === _f.remove || flag & _f.remove
    242 			&& !to ? 'delete' : from !== default_from || to ? 'move'
    243 					: 'list';
    244 	// if(func=='delete')to=_f.remove; // 反正不是用這個判別的
    245 	//library_namespace.debug('use_exact: ' + use_exact + '\nbase_path: ' + base_path + '\nfrom: ' + from);
    246 	// BUG: 這樣順序會亂掉，使得 traverse (遍歷)不完全
    247 	for (; !f.atEnd(); f.moveNext())
    248 		if (i = f.item(), use_exact && i.Name === from || !use_exact
    249 				&& from.test(i.Name)) {
    250 			report.list.push(i.Name);
    251
    252 			if (typeof filter == 'function' && !filter(i.Name))
    253 				continue;
    254 			t = func === 'copy' || func === 'move' ? i.Name.replace(from,
    255 					typeof to === 'object' ? to.source : to) : '';
    256
    257 			if (t)
    258 				try {
    259 					report.log += func + ' [' + i.Name + ']'
    260 					+ (t ? ' to [' + t + '] ' : '');
    261 					var u = '';
    262 					t = (base_path === default_from ? base_path : '')
    263 					+ t;
    264 					if (func === 'delete') {
    265 						if (not_test)
    266 							i.Delete(overwrite);
    267 					} else if (!fso.FileExists(t) || overwrite) {
    268 						if (not_test) {
    269 							if (overwrite && fso.FileExists(t))
    270 								fso.DeleteFile(t, true);
    271 							if (func === 'copy')
    272 								//	Copy() 用的是 FileSystemObject.CopyFile or FileSystemObject.CopyFolder, 亦可用萬用字元(wildcard characters)
    273 								i.Copy(t, overwrite);
    274 							else
    275 								i.Move(t);
    276 						}
    277 						u = 'move	' + t + '	' + i.Name + new_line;
    278 					} else {
    279 						report.log += ': target existing, ';
    280 						throw 1;
    281 					}
    282 					report.log += 'succeed.' + new_line,
    283 					report.undo += u, report.succeed++;
    284 				} catch (e) {
    285 					report.log += 'failed.' + new_line, report.failed++;
    286 				}
    287 				//library_namespace.debug(i.Name + ',' + t);
    288 		}
    289
    290 	if (flag & _f.include_subfolder && CurrentDirectory)
    291 		WshShell.CurrentDirectory = CurrentDirectory;
    292 	report.log += new_line + (not_test ? '' : '(test)') + func + ' ['
    293 				+ from + '] to [' + to + ']' + new_line
    294 				+ (typeof gDate === 'function' ? gDate() + '	' : '')
    295 				+ 'done ' + report.succeed + '/' + report.list.length
    296 				+ new_line;
    297 	return report;
    298 };
    299
    300 //var move_file.f;
    301 //setObjValue('move_file.f','none=0,overwrite=1,fuzzy=2,reverse=4,include_folder=8,include_subfolder=16,Test=32,copy=64,remove=128','int');
    302 CeL.IO.Windows.file
    303 .
    304 /**
    305  * <a href="#.move_file">move_file</a> 的 flag enumeration
    306  * @constant
    307  * @memberOf	CeL.IO.Windows.file
    308  */
    309 move_file.f = {
    310 		/**
    311 		 * null flag
    312 		 * @memberOf CeL.IO.Windows.file
    313 		 */
    314 		none : 0,
    315 		/**
    316 		 * overwrite target
    317 		 * @memberOf CeL.IO.Windows.file
    318 		 */
    319 		overwrite : 1,
    320 		/**
    321 		 * If source don't exist but target exist, than reverse.
    322 		 * @deprecated	TODO
    323 		 * @memberOf CeL.IO.Windows.file
    324 		 */
    325 		fuzzy : 2,
    326 		/**
    327 		 * reverse source and target
    328 		 * @memberOf CeL.IO.Windows.file
    329 		 */
    330 		reverse : 4,
    331 		/**
    332 		 * include folder
    333 		 * @memberOf CeL.IO.Windows.file
    334 		 */
    335 		include_folder : 8,
    336 		/**
    337 		 * include sub-folder
    338 		 * @memberOf CeL.IO.Windows.file
    339 		 */
    340 		include_subfolder : 16,
    341 		/**
    342 		 * Just do a test
    343 		 * @memberOf CeL.IO.Windows.file
    344 		 */
    345 		Test : 32,
    346 		/**
    347 		 * copy, instead of move the file
    348 		 * @memberOf CeL.IO.Windows.file
    349 		 */
    350 		copy : 64,
    351 		/**
    352 		 * 當 target 指定此 flag，或包含此 flag 而未指定 target 時，remove the source。
    353 		 * @memberOf CeL.IO.Windows.file
    354 		 */
    355 		remove : 128
    356 };
    357
    358 CeL.IO.Windows.file
    359 .
    360 /**
    361  * move file
    362  * @requires	fso,get_folder,get_file_name,initWScriptObj
    363  * @memberOf	CeL.IO.Windows.file
    364  */
    365 move_1_file = function(from, to, dir, only_filename, reverse) {
    366 	if (!from || !to || from === to)
    367 		return new Error(1, 'filename error.');
    368
    369 	var e;
    370 	dir = get_folder(dir);
    371
    372 	if (reverse)
    373 		e = from, from = to, to = e;
    374 	e = function(_i) {
    375 		return fso.FileExists(_i) ? _i : dir ? dir
    376 				+ (only_filename ? get_file_name(_i) : _i) : null;
    377 	};
    378
    379 	try {
    380 		//library_namespace.debug('move_1_file:\n' + dir + '\n\n' + e(from) + '\n→\n' + e(to));
    381 		fso.MoveFile(e(from), e(to));
    382 		return;
    383 	} catch (e) {
    384 		e.message = 'move_1_file:\n' + from + '\n→\n'
    385 				+ to// +'\n\n'+e.message
    386 				;
    387 		return e;
    388 	}
    389 };
    390
    391
    392 /*
    393 function mv(from,to,dir,only_filename,reverse){
    394  var e,_f,_t;
    395  dir=get_folder(dir);
    396
    397  if(reverse)e=from,from=to,to=e;
    398  _f=from;
    399  _t=to;
    400  to=0;
    401  e=function(_i){
    402   return fso.FileExists(_i)?_i:dir&&fso.FileExists(_i=dir+(only_filename?get_file_name(_i):_i))?_i:0;
    403  };
    404
    405  try{
    406   if(!(_f=e(_f)))to=1;else if(!(_t=e(_t)))to=2;
    407   else{
    408    alert('mv():\n'+dir+'\n\n'+_f+'\n→\n'+_t);
    409    fso.MoveFile(_f,_t);
    410    return;
    411   }
    412  }catch(e){return e;}
    413  return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t);
    414 }
    415
    416
    417 function mv(from,to,dir,only_filename,reverse){
    418  var e,_f,_t;
    419  dir=get_folder(dir);
    420
    421  if(reverse)e=from,from=to,to=e;
    422  _f=from,_t=to,to=e=0;
    423
    424  try{
    425   if(!fso.FileExists(_f)&&(!dir||!fso.FileExists(_f=dir+(only_filename?get_file_name(_f):_f))))to=1;
    426   else if(fso.FileExists(_t)&&(!dir||fso.FileExists(_t=dir+(only_filename?get_file_name(_t):_t))))to=2;
    427   else{
    428    alert('mv():\n'+dir+'\n'+_f+'\n→\n'+_t);
    429    //fso.MoveFile(_f,_t);
    430    return;
    431   }
    432  }catch(e){}
    433  return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t);
    434 }
    435
    436 */
    437
    438
    439 /*
    440
    441 下面一行調到檔案頭
    442 var get_file_details_items,get_file_details_get_object=-62.262;
    443 */
    444 CeL.IO.Windows.file
    445 .
    446 /**
    447  * get file details (readonly)
    448  * @example
    449  * get_file_details('path');
    450  * get_file_details('file/folder name',parentDir);
    451  * get_file_details('path',get_file_details_get_object);
    452  * @see	<a href="http://msdn.microsoft.com/en-us/library/bb787870%28VS.85%29.aspx" accessdate="2009/11/29 22:52" title="GetDetailsOf Method (Folder)">GetDetailsOf Method (Folder)</a>
    453  * @memberOf	CeL.IO.Windows.file
    454  */
    455 get_file_details = function(fileObj, parentDirObj) {
    456 	var i, n, r;
    457 	// WinShell=new ActiveXObject("Shell.Application");
    458 	if (typeof WinShell == 'undefined' || !fileObj)
    459 		return;
    460
    461 	// deal with fileObj & parentDirObj
    462 	if (parentDirObj === get_file_details_get_object)
    463 		parentDirObj = 0, n = 1;
    464 	// else n='';
    465 	if (!parentDirObj) {
    466 		// fileObj is path
    467 		if (typeof fileObj != 'string')
    468 			return;
    469 		if (i = fileObj.lastIndexOf('/') + 1)
    470 			parentDirObj = fileObj.slice(0, i - 1), fileObj = fileObj
    471 			.slice(i);
    472 		else
    473 			return;
    474 	}
    475 	if (typeof parentDirObj == 'string')
    476 		parentDirObj = WinShell.NameSpace(parentDirObj);
    477 	if (typeof fileObj == 'string' && fileObj)
    478 		fileObj = parentDirObj.ParseName(fileObj);
    479 	if (n)
    480 		// just get [(object)parentDirObj,(object)fileObj]
    481 		return [ parentDirObj, fileObj ];
    482
    483 	// get item name
    484 	if (typeof get_file_details_items != 'object') {
    485 		get_file_details_items = [];
    486 		for (i = 0, j; i < 99; i++)
    487 			// scan cols
    488 			if (n = WinShell.NameSpace(0).GetDetailsOf(null, i))
    489 				get_file_details_items[i] = n;
    490 	}
    491
    492 	// main process
    493 	//for(i=0,r=[];i<get_file_details_items.length;i++)
    494 	r = [];
    495 	for (i in get_file_details_items) {
    496 		//if(get_file_details_items[i])
    497 		r[get_file_details_items[i]] = r[i] = parentDirObj
    498 		.GetDetailsOf(fileObj, i);
    499 	}
    500
    501 	return r;
    502 };
    503
    504
    505 CeL.IO.Windows.file
    506 .
    507 /**
    508  * FileSystemObject Object Attributes Property
    509  * @see
    510  * <a href="http://msdn.microsoft.com/en-us/library/5tx15443%28VS.85%29.aspx" accessdate="2010/1/9 8:11">Attributes Property</a>
    511  * @memberOf	CeL.IO.Windows.file
    512  * @since	2010/1/9 08:33:36
    513  */
    514 fso_attributes = {
    515 	/**
    516 	 * Default. No attributes are set.
    517 	 * @memberOf	CeL.IO.Windows.file
    518 	 */
    519 	none : 0,
    520 	/**
    521 	 * Normal file. No attributes are set.
    522 	 * @memberOf	CeL.IO.Windows.file
    523 	 */
    524 	Normal : 0,
    525 	/**
    526 	 * Read-only file. Attribute is read/write.
    527 	 * @memberOf	CeL.IO.Windows.file
    528 	 */
    529 	ReadOnly : 1,
    530 	/**
    531 	 * Hidden file. Attribute is read/write.
    532 	 * @memberOf	CeL.IO.Windows.file
    533 	 */
    534 	Hidden : 2,
    535 	/**
    536 	 * System file. Attribute is read/write.
    537 	 * @memberOf	CeL.IO.Windows.file
    538 	 */
    539 	System : 4,
    540 	/**
    541 	 * Disk drive volume label. Attribute is read-only.
    542 	 * @memberOf	CeL.IO.Windows.file
    543 	 */
    544 	Volume : 8,
    545 	/**
    546 	 * Folder or directory. Attribute is read-only.
    547 	 * @memberOf	CeL.IO.Windows.file
    548 	 */
    549 	Directory : 16,
    550 	/**
    551 	 * File has changed since last backup. Attribute is read/write.
    552 	 * @memberOf	CeL.IO.Windows.file
    553 	 */
    554 	Archive : 32,
    555 	/**
    556 	 * Link or shortcut. Attribute is read-only.
    557 	 * @memberOf	CeL.IO.Windows.file
    558 	 */
    559 	Alias : 1024,
    560 	/**
    561 	 * Compressed file. Attribute is read-only.
    562 	 * @memberOf	CeL.IO.Windows.file
    563 	 */
    564 	Compressed : 2048
    565 };
    566
    567 //	reverse map
    568 _.fso_attributes_reverse=[];
    569 for (i in _.fso_attributes)
    570 	if (i !== 'none')
    571 		_.fso_attributes_reverse[_.fso_attributes[i]] = i;
    572
    573 /*
    574 TODO
    575 	未來：change_attributes(path,'-ReadOnly&-Hidden&-System')
    576
    577 下面調到檔案頭
    578 setObjValue('Attribute','Normal=0,none=0,ReadOnly=1,Hidden=2,System=4,Volume=8,Directory=16,Archive=32,Alias=64,Compressed=128','int');
    579 setObjValue('AttributeV','0=Normal,1=ReadOnly,2=Hidden,4=System,8=Volume,16=Directory,32=Archive,64=Alias,128=Compressed');
    580 */
    581 CeL.IO.Windows.file
    582 .
    583 /**
    584  * 改變檔案之屬性。
    585  * chmod @ UNIX
    586  * @param	F	file path
    587  * @param	A	attributes, 屬性
    588  * @example
    589  * change_attributes(path,'-ReadOnly');
    590  * @memberOf	CeL.IO.Windows.file
    591  */
    592 change_attributes = function(F, A) {
    593 	if (!F)
    594 		return -1;
    595
    596 	if (typeof F === 'string')
    597 		try {
    598 			F = fso.GetFile(F);
    599 		} catch (e) {
    600 			return -2;
    601 		}
    602
    603 	var a;
    604 	try {
    605 		a = F.Attributes;
    606 	} catch (e) {
    607 		return -3;
    608 	}
    609
    610 	if (typeof A === 'undefined')
    611 		A = a;
    612 	else if (A === '' || A == 'Archive')
    613 		A = 32;
    614 	else if (A == 'Normal')
    615 		A = 0;
    616 	else if (isNaN(A))
    617 		if (A.charAt(0) === 'x' || A.charAt(0) === '-')
    618 			if (A = -_.fso_attributes[A.substr(1)], A && a % (A << 2))
    619 				A = a + A;
    620 			else
    621 				A = a;
    622 		else if (A = _.fso_attributes[A], A && a % (A << 2) == 0)
    623 			A = a + A;
    624 		else
    625 			A = a;
    626 	else if (_.fso_attributes_reverse[A])
    627 		if (a % (A << 2) == 0)
    628 			A = a + A;
    629 		else
    630 			A = a;
    631 	else if (_.fso_attributes_reverse[-A])
    632 		if (a % (A << 2))
    633 			A = a + A;
    634 		else
    635 			A = a;
    636
    637 	if (a != A)
    638 		try {
    639 			F.Attributes = A;
    640 		} catch (e) {
    641 			//popErr(e);
    642 			library_namespace.err(e);
    643 			//	70：防寫（沒有使用權限）
    644 			return 70 == (e.number & 0xFFFF) ? -8 : -9;
    645 		}
    646 	return F.Attributes;
    647 };
    648
    649
    650
    651
    652
    653 CeL.IO.Windows.file
    654 .
    655 /**
    656  * 開檔處理<br/>
    657  * 測試是否已開啟資料檔之測試與重新開啟資料檔
    658  * @param FN	file name
    659  * @param NOTexist	if NOT need exist
    660  * @param io_mode	IO mode
    661  * @return
    662  * @requires	fso,WshShell,iomode
    663  * @memberOf	CeL.IO.Windows.file
    664  */
    665 openDataTest = function(FN, NOTexist, io_mode) {
    666 	if (!FN)
    667 		return 3;
    668 	if (NOTexist && !fso.FileExists(FN))
    669 		return 0;
    670 	if (!io_mode)
    671 		io_mode = _.iomode.ForAppending;
    672 	for (;;)
    673 		try {
    674 			var Fs = fso.OpenTextFile(FN, ForAppending);
    675 			Fs.Close();
    676 			break;
    677 		} catch (e) {
    678 			// 對執行時檔案已經開啟之處理
    679 			//if(typeof e=='object'&&e.number&&(e.number&0xFFFF)==70)
    680 			if ((e.number & 0xFFFF) != 70) {
    681 				return pErr(e, 0,
    682 						'開啟資料檔 [<green>' + FN + '<\/>] 時發生錯誤！'),
    683 						6 == alert(
    684 								'開啟資料檔 [' + FN + ']時發生不明錯誤，\n	是否中止執行？',
    685 								0, ScriptName + ' 測試是否已開啟資料檔：發生不明錯誤！',
    686 								4 + 48) ? 1 : 0;
    687 			}
    688 			if (2 == WshShell.Popup(
    689 					'★資料檔：\n\	' + FN + '\n	無法寫入！\n\n可能原因與解決方法：\n	①資料檔已被開啟。執行程式前請勿以其他程式開啟資料檔！\n	②資料檔被設成唯讀，請取消唯讀屬性。',
    690 					0, ScriptName + '：資料檔開啟發生錯誤！', 5 + 48))
    691 				return 2;
    692 		}
    693 	return 0;
    694 };
    695
    696 CeL.IO.Windows.file
    697 .
    698 /**
    699  *
    700  * @param FN
    701  * @param format
    702  * @param io_mode
    703  * @return
    704  */
    705 open_template = function(FN, format, io_mode) {
    706 	/**
    707 	 * file
    708 	 * @inner
    709 	 * @ignore
    710 	 */
    711 	var F,
    712 	/**
    713 	 * file streams
    714 	 * @inner
    715 	 * @ignore
    716 	 */
    717 	Fs;
    718 	if (!io_mode)
    719 		io_mode = _.iomode.ForReading;
    720 	if (!format)
    721 		//format=autodetectEncode(FN);
    722 		format = _.open_format.TristateUseDefault;// TristateTrue
    723 	try {
    724 		F = fso.GetFile(FN);
    725 		//Fs=_.open_file(FN,format,io_mode);
    726 		Fs = F.OpenAsTextStream(io_mode, format);
    727 	} catch (e) {
    728 		// 指定的檔案不存在?
    729 		pErr(e);
    730 		// quit();
    731 	}
    732 	return Fs;
    733 };
    734
    735 //var openOut.f;	//	default format
    736 function openOut(FN,io_mode,format){
    737  var OUT,OUTs,_f=openOut.f;
    738  if(!io_mode)io_mode=_.iomode.ForWriting;
    739  if(!format)format=_f=='string'&&_f?_f:_.open_format.TristateUseDefault;
    740  try{
    741   OUT=fso.GetFile(FN);
    742  }
    743  catch(e){try{
    744   //指定的檔案不存在
    745   var tmp=fso.CreateTextFile(FN,true);
    746   tmp.Close();
    747   OUT=fso.GetFile(FN);
    748  }catch(e){pErr(e);}}
    749
    750  try{OUTs=OUT.OpenAsTextStream(io_mode,format);}catch(e){pErr(e);}
    751
    752  return OUTs;
    753 };
    754
    755
    756
    757
    758
    759
    760
    761 //	2007/5/31 21:5:16
    762 compressF.tool={
    763 	WinRAR:{path:'"%ProgramFiles%\\WinRAR\\WinRAR.exe"',ext:'rar'
    764 		,c:{cL:'$path $cmd $s $archive -- $files',cmd:'a'	//	cL:command line, c:compress, s:switch
    765 			,s:'-u -dh -m5 -os -r -ts'	// -rr1p -s<N> -ap -as -ep1 -tl -x<f> -x@<lf> -z<f>  -p[p] -hp[p]	//	rar等
    766 			//,l:'-ilog logFN'
    767 		}
    768 		,u:{cL:'$path $cmd $archive $eF $eTo',cmd:'e'}	//	uncompress
    769 		,t:{cL:'$path $cmd $archive',cmd:'t'}	//	test
    770 	}
    771 	,'7-Zip':{path:'"%ProgramFiles%\\7-Zip\\7zg.exe"',ext:'7z'
    772 		,c:{cL:'$path $cmd $s $archive $files',cmd:'u',s:'-mx9 -ms -mhe -mmt -uy2'}	//	compress
    773 		,u:{cL:'$path $cmd $archive $eF $_e',cmd:'e',_e:function(fO){return fO.eTo?'-o'+fO.eTo:'';}}	//	uncompress
    774 		,t:{cL:'$path $cmd $archive',cmd:'t'}	//	test
    775 	}
    776 };
    777 /*
    778 test:
    779 var base='C:\\kanashimi\\www\\cgi-bin\\program\\misc\\';
    780 compress(base+'jit','_jit.htm',{tool:'7-Zip',s:''});
    781 uncompress(base+'jit',base,{tool:'7-Zip'});
    782
    783
    784 fO={
    785 	tool:'WinRAR'	//	or '7-Zip'
    786 	,m:'c'	//	method
    787 	,s:''	//	switch
    788 	,archive:''	//	archive file
    789 	,files=''	//	what to compress
    790 	,eTo=''	//	where to uncompress
    791 	,eF=''	//	what to uncompress
    792 	,rcL=1	//	rebuild command line
    793 }
    794 */
    795 // solid, overwrite, compressLevel, password
    796 function compressF(fO){	//	flags object
    797 	// 參數檢查: 未完全
    798 	if(!fO)fO={};
    799 	if(typeof fO!='object')return;
    800 	if(!fO.tool)fO.tool='WinRAR';
    801 	//if(!fO.m)fO.m='c';//method
    802 	if(!fO.m||!fO.archive&&(fO.m!='c'||fO.m=='c'&&!fO.files))return;
    803 	if(fO.m=='c'){
    804 		if(typeof fO.files!='object')fO.files=fO.files?[fO.files]:fO.archive.replace(/\..+$/,'');
    805 		if(!fO.archive)fO.archive=fO.files[0].replace(/[\\\/]$/,'')+_t.ext;
    806 		fO.files='"'+fO.files.join('" "')+'"';
    807 	}
    808 	var i,_t=compressF.tool[fO.tool],_m,_c;
    809 	if(!_t||!(_m=_t[fO.m]))return;
    810 	else if(!/\.[a-z]+$/.test(fO.archive))fO.archive+='.'+_t.ext;
    811 	//if(fO.bD)fO.archive=fO.bD+(/[\\\/]$/.test(fO.bD)?'':'\\')+fO.archive;	//	base directory, work directory, base folder
    812 	if(!/["']/.test(fO.archive))fO.archive='"'+fO.archive+'"';
    813 	//alert('compressF(): check OK.');
    814 	// 構築 command line
    815 	if(_m._cL&&!fO.rcL)_c=_m._cL;	//	rebuild command line
    816 	else{
    817 		_c=_m.cL.replace(/\$path/,_t.path);
    818 		for(i in _m)if(typeof fO[i]=='undefined')_c=_c.replace(new RegExp('\\$'+i),typeof _m[i]=='function'?_m[i](fO):_m[i]||'');
    819 		_m._cL=_c;
    820 		//alert('compressF():\n'+_c);
    821 	}
    822 	for(i in fO)_c=_c.replace(new RegExp('\\$'+i),fO[i]||'');
    823 	if(_c.indexOf('$')!=-1){alert('compressF() error:\n'+_c);return;}
    824 	alert('compressF() '+(_c.indexOf('$')==-1?'run':'error')+':\n'+_c);
    825 	// run
    826 	WshShell.Run(_c,0,true);
    827 };
    828 //compress[generateCode.dLK]='compressF';
    829 function compress(archive,files,fO){	//	compress file path, what to compress, flags object
    830 	if(!fO)fO={};else if(typeof fO!='object')return;
    831 	if(!fO.m)fO.m='c';
    832 	if(archive)fO.archive=archive;
    833 	if(files)fO.files=files;
    834 	return compressF(fO);
    835 };
    836 //uncompress[generateCode.dLK]='uncompressF';
    837 /**
    838  * uncompress archive
    839  * @param archive	compressed file path
    840  * @param eTo	where to uncompress/target
    841  * @param {Object} flag	flags
    842  * @returns
    843  */
    844 function uncompress(archive, eTo, flag) {
    845 	if (!flag)
    846 		flag = {};
    847 	else if (typeof flag != 'object')
    848 		return;
    849
    850 	if (!flag.m)
    851 		flag.m = 'u';
    852
    853 	if (!flag.eF)
    854 		flag.eF = '';
    855
    856 	if (archive)
    857 		flag.archive = archive;
    858
    859 	if (eTo)
    860 		flag.eTo = eTo;
    861
    862 	return compressF(flag);
    863 };
    864
    865
    866
    867
    868
    869
    870
    871 /*
    872 	轉換捷徑, 傳回shortcut的Object. true path
    873 	http://msdn2.microsoft.com/en-us/library/xk6kst2k.aspx
    874 	http://yuriken.hp.infoseek.co.jp/index3.html
    875 */
    876 var p;
    877 //dealShortcut[generateCode.dLK]='initWScriptObj';//,parseINI
    878 function dealShortcut(path,rtPath){
    879  if(typeof path!='string')path='';
    880  else if(/\.(lnk|url)$/i.test(path)){
    881   var sc=WshShell.CreateShortcut(path),p=sc.TargetPath,_i;
    882   //	檔名有可能是不被容許的字元（不一定總是有'?'），這時只有.url以文字儲存還讀得到。
    883   if(/*(''+sc).indexOf('?')!=-1*/!p&&/\.url$/i.test(path)&&typeof parseINI=='function'){
    884    p=parseINI(path,0,1);
    885    sc={_emu:p};
    886    sc.TargetPath=(p=p.InternetShortcut).URL;
    887    for(_i in p)sc[_i]=p[_i];
    888 /*
    889 URL File Format (.url)	http://www.cyanwerks.com/file-format-url.html
    890 [DEFAULT]
    891 BASEURL=http://so.7walker.net/guide.php
    892 [DOC#n(#n#n#n…)]
    893 [DOC#4#5]
    894 BASEURL=http://www.someaddress.com/frame2.html
    895 [DOC_adjustiframe]
    896 BASEURL=http://so.7walker.net/guide.php
    897 ORIGURL=http://so.7walker.net/guide.php
    898 [InternetShortcut]
    899 URL=http://so.7walker.net/guide.php
    900 Modified=50A8FD7702D1C60106
    901 WorkingDirectory=C:\WINDOWS\
    902 ShowCommand=	//	規定Internet Explorer啟動後窗口的初始狀態：7表示最小化，3表示最大化；如果沒有ShowCommand這一項的話則表示正常大小。
    903 IconIndex=1	//	IconFile和IconIndex用來為Internet快捷方式指定圖標
    904 IconFile=C:\WINDOWS\SYSTEM\url.dll
    905 Hotkey=1601
    906
    907 Hotkey:
    908 下面加起來: Fn 單獨 || (Fn || base) 擇一 + additional 擇2~3
    909 base:
    910 0=0x30(ASCII)
    911 9=0x39(ASCII)
    912 A=0x41(ASCII)
    913 Z=0x5a(ASCII)
    914 ;=0xba
    915 =
    916 ,
    917 -
    918 .
    919 /
    920 `=0xc0
    921 [=0xdb
    922 \
    923 ]
    924 '=0xde
    925
    926 Fn:
    927 F1=0x70
    928 ..
    929 F12=0x7b
    930
    931 additional:
    932 Shift=0x100
    933 Ctrl=0x200
    934 Alt=0x400
    935
    936 */
    937    p=p.URL;
    938   }
    939   if(!rtPath)return sc;
    940   path=/^file:/i.test(p)?p.replace(/^[^:]+:\/+/,'').replace(/[\/]/g,'\\'):p;	//	/\.url$/i.test(path)?'':p;
    941  }
    942  return rtPath?path:null;
    943 };
    944
    945 //filepath=OpenFileDialog();	基於安全，IE無法指定初始值或型態
    946 //OpenFileDialog[generateCode.dLK]='IEA';
    947 function OpenFileDialog() {
    948 	var IE = new IEA, o;
    949 	if (!IE.OK(1))
    950 		return null;
    951
    952 	IE.write('<input id="file" type="file"/>');// value="'+dP+'"	useless
    953
    954 	o = IE.getE('file');
    955 	o.focus();
    956 	o.click();
    957 	o = o.value || null;
    958
    959 	// IE.setDialog(200,400).show(1);
    960 	IE.quit();
    961
    962 	return o;
    963 };
    964
    965
    966 /**
    967  * 是否為檔案
    968  * @param path	file path
    969  * @param create	create if not exist
    970  * @returns
    971  */
    972 function is_file(path, create) {
    973 	if (!path)
    974 		return 0;
    975 	if (typeof fso == 'undefined')
    976 		fso = new ActiveXObject("Scripting.FileSystemObject");
    977 	if (fso.FileExists(path))
    978 		return true;
    979
    980 	//	doesn't exist
    981 	path = get_file_name(path);
    982 	if (create)
    983 		try {
    984 			create = fso.CreateTextFile(path, true);
    985 			create.Close();
    986 		} catch (e) {
    987 		}
    988 	return fso.FileExists(path);
    989 };
    990
    991 /**
    992  * 是否為目錄
    993  * @param path	file path
    994  * @param create	create if not exist
    995  * @returns	0:not folder, 1:absolute, 2:relative path
    996  */
    997 function is_folder(path, create) {
    998 	if (!path)
    999 		return 0;
    1000 	if (fso.FolderExists(path = turnToPath(path)))
    1001 		return isAbsPath(path) ? 1 : 2;
    1002 	if (create)
    1003 		try {
    1004 			fso.CreateFolder(path);
    1005 			return isAbsPath(path) ? 1 : 2;
    1006 		} catch (e) {
    1007 		}
    1008 	return 0;
    1009 };
    1010
    1011 /**
    1012  * get directory name of a path
    1013  * @param folder_path
    1014  * @param mode	0:path, 1:filename
    1015  * @returns
    1016  */
    1017 function get_folder(folder_path, mode) {
    1018 	if (typeof folder_path == 'object' && typeof folder_path.Path == 'string')
    1019 		if (typeof folder_path.IsRootFolder != 'undefined')
    1020 			return folder_path.Path;
    1021 		else
    1022 			folder_path = folder_path.Path;
    1023 	if (typeof folder_path != 'string')
    1024 		return '';
    1025 	//else if(/^[a-z]$/i.test(folder_path))folder_path+=':\\';
    1026
    1027 	// if(folder_path.slice(-1)!='\\')folder_path+='\\';
    1028 	var i = folder_path.lastIndexOf('\\');
    1029 	if (i == -1)
    1030 		i = folder_path.lastIndexOf('/');
    1031 	return i == -1 ? folder_path : mode ? folder_path.substr(i + 1) : folder_path.slice(0, i + 1);
    1032 };
    1033
    1034
    1035
    1036 /**
    1037  * 取得下一個序號的檔名，如輸入pp\aa.txt將嘗試pp\aa.txt→pp\aa[pattern].txt
    1038  * @param file_path	file path
    1039  * @param begin_serial	begin serial
    1040  * @param pattern	增添主檔名的模式，包含Ser的部分將被轉換為序號
    1041  * @returns
    1042  */
    1043 function getNextSerialFN(file_path, begin_serial, pattern) {
    1044 	if (!file_path)
    1045 		return;
    1046 	if (isNaN(begin_serial))
    1047 		if (!fso.FileExists(file_path))
    1048 			return file_path;
    1049 		else
    1050 			begin_serial = 0;
    1051
    1052 	var i = file_path.lastIndexOf('.'), base, ext, Ser = ':s:';
    1053 	if (i == -1)
    1054 		base = file_path, ext = '';
    1055 	else
    1056 		base = file_path.slice(0, i), ext = file_path.substr(i); // fso.GetBaseName(filespec);fso.GetExtensionName(path);fso.GetTempName();
    1057
    1058 	if (!pattern)
    1059 		pattern = '_' + Ser;
    1060 	i = pattern.indexOf(Ser);
    1061
    1062 	if (i == -1)
    1063 		base += pattern;
    1064 	else
    1065 		base += pattern.slice(0, i), ext = pattern.substr(i + Ser.length) + ext;
    1066
    1067 	for (i = begin_serial || 0; i < 999; i++)
    1068 		if (!fso.FileExists(base + i + ext))
    1069 			return base + i + ext;
    1070
    1071 	return;
    1072 };
    1073
    1074
    1075 CeL.IO.Windows.file
    1076 .
    1077 /**
    1078  * 轉換以 adTypeBinary 讀到的資料
    1079  * @example
    1080  * //	較安全的讀檔：
    1081  * t=translate_AdoStream_binary_data(read_file(FP,'binary'));
    1082  * write_file(FP,t,'iso-8859-1');
    1083  * @see
    1084  * <a href="http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html">Hawk's W3 Laboratory : Disposable WSH : 番外編：文字エンコーディングとADODB.Stream</a>
    1085  * @memberOf	CeL.IO.Windows.file
    1086  */
    1087 translate_AdoStream_binary_data = function translate_AdoStream_binary_data(data, len, type) {
    1088 	var _s = translate_AdoStream_binary_data,_i=0,charArray,val,DOM=_s.XMLDOM,pos,txt;
    1089  if(!DOM)
    1090   try{
    1091 	DOM=_s.XMLDOM=(new ActiveXObject("Microsoft.XMLDOM")).createElement('tmp');	//	要素名は何でも良い
    1092 	DOM.dataType='bin.hex';
    1093   }catch(e){return;}
    1094  if(data!==0)DOM.nodeTypedValue=data,txt=DOM.text,pos=0;//binary data
    1095  else pos=_s.pos,txt=_s.text;
    1096  if(isNaN(len)||len>txt.length/2)len=txt.length/2;
    1097
    1098  if(type){
    1099   for(val=0;_i<len;i++)val=0x100*val+parseInt(txt.substr(pos,2),16),pos+=2;
    1100   _s.pos=pos;
    1101   return val;
    1102  }
    1103
    1104 /*
    1105  if(!(len>0)||len!=parseInt(len))
    1106   alert(pos+','+_i+'==0~len='+len+','+txt.slice(0,8));
    1107 */
    1108  charArray=new Array(parseInt(len));	//	Error 5029 [RangeError] (facility code 10): 陣列長度必須是一有限的正整數
    1109  for(;_i<len;_i++)	//	極慢！用charString+=更慢。
    1110   try{
    1111    //if(_i%100000==0)alert(i);
    1112    //if(_i==40)alert(String.fromCharCode(parseInt(txt.substr(pos,2),16))+'\n'+charArray.join(''));
    1113    charArray.push(String.fromCharCode(parseInt(txt.substr(pos,2),16))),pos+=2;
    1114    //charArray[_i]=String.fromCharCode((t.charCodeAt(_i<<1)<<8)+t.charCodeAt((_i<<1)+1));
    1115   }catch(e){
    1116    e.description='translate_AdoStream_binary_data: 輸入了錯誤的資料:\n'+e.description;
    1117    throw e;
    1118   }
    1119  if(!data)_s.pos=pos;
    1120  return charArray.join('');
    1121 };
    1122
    1123 CeL.IO.Windows.file
    1124 .
    1125 /**
    1126  * 轉換以 adTypeBinary 讀到的資料
    1127  * @param	data	以 adTypeBinary 讀到的資料
    1128  * @param	pos	position
    1129  * @since	2007/9/19 20:58:26
    1130  * @memberOf	CeL.IO.Windows.file
    1131  */
    1132 Ado_binary = function(data, pos) {
    1133 	this.newDOM();
    1134
    1135 	if (typeof data == 'string') {
    1136 		if (!data || typeof getFP == 'function'
    1137 			&& !(data = getFP(data)))
    1138 			return;
    1139 		this.newFS(data);
    1140 		this.setPos(pos || 0);
    1141 	} else
    1142 		this.setData(data, pos);
    1143 };
    1144 CeL.IO.Windows.file
    1145 .
    1146 /**
    1147  * @memberOf	CeL.IO.Windows.file
    1148  */
    1149 Ado_binary.prototype={
    1150 /**
    1151  * 設定 data
    1152  *
    1153  * @param data	binary data
    1154  * @param pos
    1155  * @return
    1156  * @memberOf	CeL.IO.Windows.file
    1157  */
    1158 setData : function(data, pos) {
    1159 	this.DOM.nodeTypedValue = data,// binary data
    1160 	this.bt = this.DOM.text;// binary text
    1161 	if (!this.AdoS)
    1162 		this.len = this.bt.length / 2;
    1163 	this.setPos(pos || 0);
    1164 },
    1165 setPos : function(p) {
    1166 	if (!isNaN(p)) {
    1167 		if (p < 0)
    1168 			p = 0;
    1169 		else if (p > this.len)
    1170 			p = this.len;
    1171 		this.pos = p;
    1172 	}
    1173 	return this.pos;
    1174 },
    1175 testLen : function(len) {
    1176 	if (!len || len < 0)
    1177 		len = this.len;
    1178 	if (this.pos + len > this.len)
    1179 		len = this.len - this.pos;
    1180 	return len;
    1181 },
    1182 /**
    1183  * read data
    1184  * @private
    1185  * @param len	length
    1186  * @return
    1187  * @memberOf	CeL.IO.Windows.file
    1188  */
    1189 readData : function(len) {
    1190 	this.AdoS.Position = this.pos;
    1191 	var _data = this.AdoS.Read(len);
    1192 	//	讀 binary data 用 'iso-8859-1' 會 error encoding.
    1193 	this.setData(_data, this.AdoS.Position);
    1194 },
    1195 read : function(len) {
    1196 	var charArray = new Array(len = this.testLen(len)), _i = 0;
    1197 	this.readData(len);
    1198 	for (; _i < len; _i++)
    1199 		try {
    1200 			charArray.push(String.fromCharCode(parseInt(this.bt
    1201 					.substr(2 * _i, 2), 16)));
    1202 			// charArray[i]=String.fromCharCode((t.charCodeAt(i<<1)<<8)+t.charCodeAt((i<<1)+1));
    1203 		} catch (e) {
    1204 			this.retErr(e);
    1205 		}
    1206 		return charArray.join('');
    1207 },
    1208 readNum : function(len) {
    1209 	len = this.testLen(len);
    1210 	this.readData(len);
    1211 	var val = 0, _i = len;
    1212 	for (; _i > 0;)
    1213 		try {
    1214 			val = 0x100 * val
    1215 			+ parseInt(this.bt.substr(2 * (--_i), 2), 16);
    1216 		} catch (e) {
    1217 			this.retErr(e);
    1218 		}
    1219 		return val;
    1220 },
    1221 readHEX : function(len) {
    1222 	len = this.testLen(len);
    1223 	this.readData(len);
    1224 	return this.bt;
    1225 },
    1226 retErr : function(e) {
    1227 	e.description = 'translate_AdoStream_binary_data: 輸入了錯誤的資料:\n' + e.description;
    1228 	throw e;
    1229 },
    1230 /**
    1231  * @private
    1232  * @return
    1233  * @memberOf	CeL.IO.Windows.file
    1234  */
    1235 newDOM : function() {
    1236 	this.DOM = null;
    1237 	//try{
    1238 	this.DOM = (new ActiveXObject("Microsoft.XMLDOM")).createElement('tmp' + Math.random()); // 要素名は何でも良い
    1239 	//}catch(e){return;}
    1240 	this.DOM.dataType = 'bin.hex';
    1241 },
    1242 /**
    1243  * @private
    1244  * @param FP
    1245  * @return
    1246  * @memberOf	CeL.IO.Windows.file
    1247  */
    1248 newFS : function(FP) {
    1249 	if (FP)
    1250 		this.FP = FP;
    1251 	else if (!(FP = this.FP))
    1252 		return;
    1253 	var _i = _.open_file.returnADO;
    1254 	_.open_file.returnADO = true;
    1255 	this.AdoS = _.open_file(FP, 'binary');
    1256 	_.open_file.returnADO = _i;
    1257 	if (!this.AdoS)
    1258 		return;
    1259 	this.AdoS.LoadFromFile(FP);
    1260 	this.len = this.AdoS.Size;
    1261 },
    1262 /**
    1263  * 實際上沒多大效用。實用解決法：少用 AdoStream.Write()
    1264  * @return
    1265  * @memberOf	CeL.IO.Windows.file
    1266  */
    1267 renew : function() {
    1268 	this.bt = this.data = 0;
    1269 	this.newDOM();
    1270 	if (this.AdoS && this.FP) {
    1271 		this.pos = this.AdoS.Position;
    1272 		this.AdoS.Close();
    1273 		this.AdoS = null;
    1274 		this.newFS();
    1275 	}
    1276 },
    1277 destory : function(e) {
    1278 	if (this.AdoS)
    1279 		this.AdoS.Close();
    1280 	this.AdoS = this.pos = this.bt = this.data = 0;
    1281 }
    1282 }; //	Ado_binary.prototype={
    1283
    1284
    1285 /*
    1286 //	速度過慢，放棄。
    1287 //_.open_file.returnADO=true;
    1288 function dealBinary(FP,func,interval){
    1289  var t,fs=_.open_file(FP,'binary',ForReading);
    1290  if(!fs)return;
    1291  AdoStream.LoadFromFile(FP);
    1292  if(!interval)interval=1;
    1293  //alert(fs.size)
    1294  while(!fs.EOS)
    1295   if(func(translate_AdoStream_binary_data(fs.Read(interval))))return;
    1296  func();
    1297  fs.Close();
    1298 }
    1299 */
    1300
    1301 /*	配合simple系列使用
    1302 http://thor.prohosting.com/~mktaka/html/utf8.html
    1303 http://www.andrewu.co.uk/webtech/comment/?703
    1304 http://www.blueidea.com/bbs/NewsDetail.asp?id=1488978
    1305 http://www.blueidea.com/bbs/NewsDetail.asp?GroupName=WAP+%BC%BC%CA%F5%D7%A8%C0%B8&DaysPrune=5&lp=1&id=1524739
    1306 C#	http://www.gotdotnet.com/team/clr/bcl/TechArticles/TechArticles/IOFAQ/FAQ.aspx
    1307 http://www.sqlxml.org/faqs.aspx?faq=2
    1308 http://www.imasy.or.jp/~hir/hir/tech/js_tips.html
    1309
    1310 ADODB.Stream	最大問題：不能append
    1311 http://msdn2.microsoft.com/en-us/library/ms808792.aspx
    1312 http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp
    1313 http://study.99net.net/study/web/asp/1067048121.html	http://www.6to23.com/s11/s11d5/20031222114950.htm
    1314 http://blog.csdn.net/dfmz007/archive/2004/07/23/49373.aspx
    1315 */
    1316 var AdoStream,AdoEnums;	//	ADO Enumerated Constants	http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp
    1317 /*	搬到前面
    1318 setObjValue('AdoEnums','adTypeBinary=1,adTypeText=2'	//	StreamTypeEnum
    1319 +',adReadAll=-1,adReadLine=-2'	//	StreamReadEnum	http://msdn2.microsoft.com/en-us/library/ms806462.aspx
    1320 +',adSaveCreateNotExist=1,adSaveCreateOverWrite=2'	//	SaveOptionsEnum
    1321 +',adCR=13,adCRLF=-1,adLF=10'	//	LineSeparatorsEnum
    1322 ,'int');
    1323 */
    1324 AdoEnums = {
    1325 	adTypeBinary : 1,
    1326 	adTypeText : 2,
    1327 	adReadAll : -1,
    1328 	adReadLine : -2,
    1329 	adSaveCreateNotExist : 1,
    1330 	adSaveCreateOverWrite : 2,
    1331 	adCR : 13,
    1332 	adCRLF : -1,
    1333 	adLF : 10
    1334 };
    1335
    1336
    1337 //_.open_file[generateCode.dLK]='AdoEnums,simpleFileErr,ForReading,ForWriting,ForAppending,TristateUseDefault';//AdoStream
    1338 CeL.IO.Windows.file
    1339 .
    1340 /**
    1341  * 提供給 <a href="#.read_file">read_file</a>, <a href="#.write_file">write_file</a> 使用的簡易開檔函數
    1342  * @param FN	file path
    1343  * @param format	open format, e.g., open_format.TristateUseDefault
    1344  * @param io_mode	open mode, e.g., iomode.ForWriting
    1345  * @memberOf	CeL.IO.Windows.file
    1346  */
    1347 open_file = function open_file(FN, format, io_mode) {
    1348  //if(!FN||typeof isAbsPath=='function'&&typeof get_file_name=='function'&&!isAbsPath(FN)&&!(FN=get_file_name(FN)))return;
    1349  //if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return;
    1350 	var _s = open_file;
    1351  if(typeof format=='string'){
    1352   if(!_s.returnADO&&typeof AdoStream!='undefined')
    1353    try{AdoStream.Close();AdoStream=null;}catch(e){}
    1354   try{
    1355    AdoStream=new ActiveXObject("ADODB.Stream");//var objStream=Server.CreateObject("ADODB.Stream");	//	ASPの場合,Err.Number=-2147221005表不支援
    1356   }catch(e){simpleFileErr=e;AdoStream=null;}
    1357   if(AdoStream){
    1358    //AdoStream.Mode=3;	//	read write
    1359    if(format=='binary')AdoStream.Type=AdoEnums.adTypeBinary;	//	以二進位方式操作
    1360    else{
    1361     AdoStream.Type=AdoEnums.adTypeText;
    1362     try{AdoStream.Charset=format;}catch(e){throw new Error(e.number,'open_file: Error format:\n	('+typeof format+') ['+format+']\n'+e.description);}	//	UTF-8,unicode,shift_jis,Big5,GB2312,ascii=iso-8859-1,_autodetect,_autodetect_all..	HKEY_CLASSES_ROOT\MIME\Database\Charset
    1363    }
    1364    AdoStream.Open();
    1365    //AdoStream.Position=0,AdoStream.LineSeparator=AdoEnums.adLF;
    1366    if(_s.returnADO){var _A=AdoStream;AdoStream=null;return _A;}
    1367    return 0;
    1368   }
    1369   format=0;
    1370  }
    1371  var fs;
    1372  //	使用某些防毒軟體(如諾頓 Norton)時，.OpenTextFile() 可能會被攔截，因而延宕。
    1373  try{
    1374   if(io_mode==_.iomode.ForAppending&&!fso.FileExists(FN))io_mode=_.iomode.ForWriting;	//	無此檔時改 writing
    1375   fs=fso.OpenTextFile(FN,io_mode||_.iomode.ForReading,io_mode==_.iomode.ForWriting/*create*/,format||_.open_format.TristateUseDefault);
    1376  }catch(e){
    1377   simpleFileErr=e;
    1378   try{fs.Close();}catch(e){}
    1379   return -1;
    1380  }
    1381  return fs;
    1382 };
    1383 CeL.IO.Windows.file
    1384 .open_file.returnADO=false;
    1385 CeL.IO.Windows.file
    1386 .open_file.error;
    1387
    1388 //	若是僅使用普通的開檔方法（_.open_format.TristateTrue/_.open_format.TristateFalse等，不使用ADODB.Stream），直接引用下兩函數與fso段定義即可。否則還需要引入_.open_file(),setObjValue(),dQuote()
    1389 var simpleFileErr,
    1390 	//_autodetect	autodetectEncode(file)
    1391 	simpleFileAutodetectEncode=-5.4,
    1392 	simpleFileDformat=
    1393 	CeL.IO.Windows.file
    1394 	.open_format.TristateUseDefault;
    1395
    1396 //_.read_file[generateCode.dLK]=_.write_file[generateCode.dLK]='simpleFileErr,simpleFileAutodetectEncode,simpleFileDformat,initWScriptObj';//_.open_file,autodetectEncode,getFP,_.open_format.TristateUseDefault
    1397 //_.read_file[generateCode.dLK]+=',ForReading';_.write_file[generateCode.dLK]+=',ForWriting';
    1398 //_.read_file[generateCode.dLK]+=',translate_AdoStream_binary_data';	//	for _.read_file(FP,'binary')
    1399 CeL.IO.Windows.file
    1400 .
    1401 /**
    1402  * 讀取檔案
    1403  * @param FN	file path
    1404  * @param format	open encode = simpleFileDformat
    1405  * @param io_mode	open IO mode = ForReading
    1406  * @param func	do this function per line, or [func, maxsize] (TODO)
    1407  * @return {String} 檔案內容
    1408  * @memberOf	CeL.IO.Windows.file
    1409  */
    1410 read_file=function(FN,format,io_mode,func){
    1411  simpleFileErr=0;if(format==simpleFileAutodetectEncode)
    1412   format=typeof autodetectEncode=='function'?autodetectEncode(FN):simpleFileDformat;
    1413  if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return;
    1414  //var a,fs;try{fs=fso.OpenTextFile(FN,io_mode||_.iomode.ForReading,false,format||simpleFileDformat),a=fs.ReadAll(),fs.Close();}catch(e){simpleFileErr=e;return;}
    1415  var a,fs;//,i,s=0,t;
    1416  if(typeof _.open_file!='function')
    1417   //{if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return;
    1418   try{fs=fso.OpenTextFile(FN,io_mode||_.iomode.ForReading,false/*create*/,format||simpleFileDformat);}
    1419   catch(e){simpleFileErr=e;return;}
    1420  else if(fs=_.open_file(FN,format||simpleFileDformat,io_mode||_.iomode.ForReading),fs===-1)return;
    1421
    1422  //if(func instanceof Array)s=func[1],func=func[0];
    1423  if(fs!==0)try{
    1424   if(func)
    1425    while(!fs.AtEndOfStream)func(fs.ReadLine());
    1426 /*
    1427    while(!fs.AtEndOfStream){
    1428     for(t='',i=0;!fs.AtEndOfStream&&(!t||i<s);i++)
    1429      t+=fs.ReadLine();
    1430     a+=func(t);
    1431    }
    1432 */
    1433   else a=fs.ReadAll();
    1434   fs.Close();
    1435  }catch(e){simpleFileErr=e;try{fs.Close();}catch(e){}return;}
    1436  else if(typeof AdoStream!='undefined'&&AdoStream)
    1437   try{
    1438    AdoStream.LoadFromFile(FN);
    1439    if(AdoStream.Type==AdoEnums.adTypeBinary){
    1440     a=AdoStream.Read(AdoEnums.adReadAll);	//	讀 binary data 用 'iso-8859-1' 會 error encoding.
    1441     if(_.read_file.turnBinToStr&&typeof translate_AdoStream_binary_data=='function')a=translate_AdoStream_binary_data(a);
    1442    }else if(func)
    1443     while(!AdoStream.EOS)func(AdoStream.ReadText(AdoEnums.adReadLine));
    1444 /*
    1445     while(!AdoStream.EOS){
    1446      for(t='',i=0;!AdoStream.AtEndOfStream&&(!t||i<s);i++)
    1447       t+=AdoStream.ReadText(AdoEnums.adReadLine);
    1448      a+=func(t);
    1449     }
    1450 */
    1451    else a=AdoStream.ReadText(AdoEnums.adReadAll);
    1452    AdoStream.Close();
    1453   }catch(e){
    1454    simpleFileErr=e;
    1455    try{AdoStream.Close();}catch(e){}
    1456    return;
    1457   }
    1458  else simpleFileErr=new Error(1,'unknown error!'),simpleFileErr.name='unknownError';
    1459  return a;
    1460 };
    1461 CeL.IO.Windows.file
    1462 .read_file.turnBinToStr=true;
    1463
    1464
    1465 CeL.IO.Windows.file
    1466 .
    1467 /**
    1468  * 將 content 寫入 file
    1469  * ** ADODB.Stream does not support appending!
    1470  * @param FN	file path
    1471  * @param content	content to write
    1472  * @param format	open format = simpleFileDformat
    1473  * @param io_mode	write mode = ForWriting, e.g., ForAppending
    1474  * @param N_O	DO NOT overwrite
    1475  * @return error No.
    1476  * @memberOf	CeL.IO.Windows.file
    1477  */
    1478 write_file = function(FN, content, format, io_mode, N_O) {
    1479 	simpleFileErr = 0;
    1480 	if (format == simpleFileAutodetectEncode)
    1481 		format = typeof autodetectEncode == 'function' ? autodetectEncode(FN)
    1482 				: simpleFileDformat;
    1483 		if (!FN || typeof getFP == 'function' && !(FN = getFP(FN)))
    1484 			return 2;
    1485 		//var fs;try{fs=fso.OpenTextFile(FN,iomode||ForWriting,true,format||TristateUseDefault);}catch(e){return 2;}if(!fs)return 3;
    1486 		//try{fs.Write(content);}catch(e){return e.number&0xFFFF==5?5:4;}	//	5:content中有此local無法相容的字元，例如在中文中寫入日文假名
    1487 		var fs;
    1488 		if (typeof _.open_file != 'function')
    1489 			// {if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return 2;
    1490 			try {
    1491 				fs = fso.OpenTextFile(FN, io_mode || _.iomode.ForWriting,
    1492 						true/* create */, format || simpleFileDformat);
    1493 				if (!fs)
    1494 					return 3;
    1495 			} catch (e) {
    1496 				simpleFileErr = e;
    1497 				return 2;
    1498 			}
    1499 			else if (fs = _.open_file(FN, format || simpleFileDformat, io_mode
    1500 					|| _.iomode.ForWriting), fs === -1)
    1501 				return 3;
    1502 			else if (!fs && isNaN(fs))
    1503 				return 2;
    1504 		if (fs !== 0)
    1505 			try {
    1506 				fs.Write(content);
    1507 				fs.Close();
    1508 			} catch (e) {
    1509 				simpleFileErr = e;
    1510 				try {
    1511 					fs.Close();
    1512 				} catch (e) {
    1513 				}
    1514 				return simpleFileErr.number & 0xFFFF == 5 ? 5 : 4;
    1515 			}
    1516 			// AdoStream.SaveToFile()需在AdoStream.Write之後！
    1517 			else if (typeof AdoStream != 'undefined' && AdoStream)
    1518 				try {
    1519 					if (AdoStream.Type == AdoEnums.adTypeText)
    1520 						AdoStream.WriteText(content);
    1521 					else
    1522 						AdoStream.Write(content);
    1523 					AdoStream.SaveToFile(FN, io_mode
    1524 							|| AdoEnums.adSaveCreateOverWrite);
    1525 					AdoStream.Close();
    1526 				} catch (e) {
    1527 					simpleFileErr = e;
    1528 					try {
    1529 						AdoStream.Close();
    1530 					} catch (e) {
    1531 					}
    1532 					return 6;
    1533 				}
    1534 				else {
    1535 					simpleFileErr = new Error(1, 'unknown error!'),
    1536 					simpleFileErr.name = 'unknownError';
    1537 					return 1;
    1538 				}
    1539 };
    1540
    1541 //	TODO: unfinished
    1542 //simpleDealFile[generateCode.dLK]='autodetectEncode,_.read_file,_.write_file';
    1543 CeL.IO.Windows.file
    1544 .
    1545 simpleDealFile = function(inFN, func, outFN, format, io_mode, N_O) {
    1546 	if (!inFN)
    1547 		return;
    1548 	if (!outFN)
    1549 		outFN = inFN;
    1550 	var e = autodetectEncode(inFN), i = _.read_file(inFN, e), o = _.read_file(
    1551 			outFN, e), t = func(i, inFN);
    1552 	if (typeof t == 'string' && o != t)
    1553 		return _.write_file(outFN, t, e, N_O);
    1554 };
    1555
    1556 /*
    1557 var autodetectEncodeSP,autodetectEncodeCode;	//	特殊字元，各種編碼及判別所需最短長度
    1558 setObjValue('autodetectEncodeSP','3005=J,3006=J,3402=J,3447=C,3468=J,3473=C,359e=C,360e=C,361a=C,3918=C,396e=C,39cf=C,39d0=C,39df=C,3a73=C,3b4e=C,3b77=J,3c6e=C,3ce0=C,3f57=J,4056=C,415f=C,42c6=J,4302=J,4337=C,43ac=C,43b1=C,43dd=C,44be=J,44d4=J,44d6=C,464c=C,4661=C,4723=C,4729=C,477c=C,478d=C,4947=C,497a=C,497d=C,'
    1559 +'4982=C,4983=C,4985=C,4986=C,499b=C,499f=C,49b0=J,49b6=C,49b7=C,4c77=C,4c9f=C,4ca0=C,4ca1=C,4ca2=C,4ca3=C,4d13=C,4d14=C,4d15=C,4d16=C,4d17=C,4d18=C,4d19=C,4dae=C,4e12=J,4e13=C,4e1a=C,4e1b=C,4e1c=C,4e1d=C,4e24=C,4e25=C,4e27=C,4e28=J,4e2a=C,4e34=C,4e3a=C,4e3c=J,4e3d=C,4e3e=C,4e49=C,'
    1560 +'4e4c=C,4e50=C,4e54=C,4e60=C,4e61=C,4e62=J,4e66=C,4e70=C,4e71=C,4e8f=C,4e9a=C,4ea7=C,4ea9=C,4eb2=C,4eb5=C,4ebf=C,4ec5=C,4ece=C,4ed0=J,4ed1=C,4ed3=C,4eea=C,4eec=C,4f17=C,4f1b=C,4f1d=J,4f1e=C,4f1f=C,4f20=C,4f24=C,4f25=C,4f26=C,4f27=C,4f2a=C,4f65=C,4f66=J,4fa0=C,4fa1=J,4fa4=J,4fa5=C,'
    1561 +'4fa6=C,4fa7=C,4fa8=C,4fa9=C,4faa=C,4fac=C,4fb0=J,4fe3=J,4fe4=J,4fe5=J,4fe6=C,4fe7=J,4fe8=C,4fe9=C,4fea=C,4fed=C,5039=J,503a=C,503b=J,503e=C,5051=J,507b=C,507e=C,507f=C,50a5=C,50a7=C,50a8=C,50a9=C,50cd=J,50de=C,50f2=J,5170=C,5173=C,5174=C,517b=C,517d=C,5181=C,5188=C,5199=C,519b=C,'
    1562 +'519c=C,51af=C,51b2=C,51bb=C,51e4=C,51e7=J,51e9=J,51ea=J,51eb=C,51ed=C,51ee=J,51ef=C,51fb=C,51ff=C,520d=C,5218=C,5219=C,521a=C,521b=C,522b=C,522c=C,522d=C,523d=C,523f=C,5240=C,5242=C,5250=C,5251=C,5257=C,5267=C,5273=C,529d=C,529e=C,52a1=C,52a8=C,52b1=C,52b2=C,52b3=C,52bf=C,52cb=C,'
    1563 +'52da=C,5301=J,5302=J,5307=J,5326=C,532e=C,533b=C,534e=C,534f=C,5355=C,5356=C,5362=C,5364=C,536b=C,5385=C,5386=C,5389=C,538b=C,538c=C,538d=C,5395=C,53a0=C,53a3=C,53bf=C,53c2=C,53c6=C,53c7=C,53cc=C,53d1=C,53d8=C,53f6=C,53f7=C,53f9=C,53fa=J,53fd=C,540b=J,5413=C,5417=C,542f=C,544e=J,'
    1564 +'544f=J,5452=C,5453=C,5455=C,5456=C,5457=C,5458=C,545b=C,545c=C,5484=J,5491=J,5499=C,549b=C,549c=J,549d=C,54cd=C,54d1=C,54d2=C,54d3=C,54d4=C,54d5=C,54d7=C,54d8=J,54d9=C,54dd=C,54df=C,54e9=J,5500=J,551b=C,551d=C,5520=C,5521=C,5522=C,5553=C,5567=C,556c=C,556d=C,556e=C,5570=C,5578=C,'
    1565 +'55b0=J,55b7=C,55bd=C,55be=C,55eb=C,55f3=C,5624=C,5631=C,565c=C,565d=C,5678=J,567a=J,56a3=C,56c9=J,56ce=J,56e2=C,56ed=C,56f2=J,56f4=C,56f5=C,56fe=C,5706=C,5715=J,5726=J,5737=J,5738=J,5739=C,573a=C,5746=J,5757=C,575a=C,575b=C,575c=C,575d=C,575e=C,575f=C,5760=C,5784=C,5786=C,5788=J,'
    1566 +'5789=J,5792=C,57a4=J,57a6=C,57a9=C,57ab=C,57ac=J,57ad=C,57b0=J,57b2=C,57b3=J,57d6=J,57d8=C,57d9=C,57da=C,5811=C,5815=C,5840=J,5870=J,5899=C,58b8=J,58b9=J,58d7=J,58e5=J,58ee=C,58f0=C,58f3=C,58f6=C,58f8=C,5904=C,5907=C,5934=C,5939=C,593a=C,5941=C,594b=C,5956=C,5986=C,5987=C,5988=C,'
    1567 +'598b=J,599b=J,59a9=C,59aa=C,59ab=C,59c9=J,5a04=C,5a05=C,5a06=C,5a07=C,5a08=C,5a32=C,5a34=C,5a47=J,5a72=J,5a73=C,5a74=C,5a75=C,5a76=C,5aac=J,5ad2=C,5ad4=C,5af1=C,5b00=C,5b36=J,5b59=C,5b66=C,5b6a=C,5b93=J,5b9e=C,5ba0=C,5ba1=C,5baa=C,5bbd=C,5bbe=C,5bc9=J,5bdd=C,5bf9=C,5bfb=C,5bfc=C,'
    1568 +'5bff=C,5c06=C,5c14=C,5c18=C,5c1d=C,5c27=C,5c34=C,5c3d=C,5c42=C,5c5e=C,5c61=C,5c66=C,5c76=J,5c7f=C,5c81=C,5c82=C,5c96=C,5c97=C,5c98=C,5c9a=C,5c9b=C,5cbc=J,5cbd=C,5cbe=J,5cbf=C,5cc3=C,5cc4=C,5cc5=J,5ce0=J,5ce1=C,5ce3=C,5ce4=C,5ce6=C,5d02=C,5d03=C,5d10=C,5d2c=C,5d2d=C,5d58=C,5d59=J,'
    1569 +'5d5a=C,5d5d=C,5d76=J,5dc5=C,5de9=C,5def=C,5e01=C,5e05=C,5e08=C,5e0f=C,5e10=C,5e1c=C,5e26=C,5e27=C,5e2e=C,5e3b=C,5e3c=C,5e7f=C,5e83=J,5e86=C,5e90=C,5e91=C,5e93=C,5e94=C,5e99=C,5e9e=C,5e9f=C,5ebc=C,5f00=C,5f03=C,5f16=J,5f20=C,5f25=C,5f2f=C,5f39=C,5f41=J,5f45=J,5f52=C,5f53=C,5f55=C,'
    1570 +'5f7b=C,5f84=C,5f95=C,5fa4=J,5fc6=C,5fdc=J,5fe7=C,5ff0=J,5ffe=C,6001=C,6002=C,6003=C,6004=C,6005=C,6006=C,603a=J,603b=C,603c=C,603f=C,604b=C,6073=C,6076=C,6077=J,6078=C,6079=C,607a=C,607b=C,607c=C,607d=C,60ab=C,60ac=C,60ad=C,60af=C,60e7=C,60e8=C,60e9=C,60eb=C,60ec=C,60ed=C,60ee=C,'
    1571 +'60ef=C,6124=C,6126=C,6151=C,6164=C,61d1=C,61d2=C,6206=C,620b=C,620f=C,6217=C,6218=C,6256=J,6267=C,6268=J,6269=C,626a=C,626b=C,626c=C,629a=C,629f=C,62a0=C,62a1=C,62a2=C,62a4=C,62a5=C,62c5=C,62df=C,62e2=C,62e3=C,62e5=C,62e6=C,62e7=C,62e8=C,62e9=C,630a=J,6317=J,6318=J,631a=C,631b=C,'
    1572 +'631c=C,631d=C,631e=C,631f=C,6320=C,6321=C,6322=C,6324=C,6325=C,6326=C,6327=J,635e=C,635f=C,6361=C,6363=C,6364=J,6386=C,63b3=C,63b4=C,63b5=J,63b7=C,63b8=C,63ba=C,63bc=C,63fd=C,63ff=C,6400=C,6401=C,6402=C,6405=C,643e=J,6444=C,6445=C,6446=C,6448=C,644a=C,6484=C,64b5=C,64b7=C,64ba=C,'
    1573 +'64d3=C,64de=C,6512=C,654c=C,655b=C,6570=C,658b=C,6593=C,65a9=C,65ad=C,65e0=C,65e7=C,65f6=C,65f7=C,65f8=C,6619=C,663c=C,663d=C,663e=C,6653=C,6654=C,6655=C,6682=C,6683=J,66a7=C,66fb=J,6722=J,672f=C,6740=C,6741=J,6742=C,6743=C,6761=C,6762=J,6763=J,6764=J,6765=C,6766=J,6768=C,678c=J,'
    1574 +'679e=C,67a0=J,67a1=J,67a2=C,67a3=C,67a5=C,67a6=J,67a7=C,67a8=C,67a9=J,67aa=C,67ab=C,67ad=C,67d5=J,67e0=C,67fd=C,67fe=J,6802=J,6803=J,6807=C,6808=C,6809=C,680a=C,680b=C,680c=C,680d=J,680e=C,680f=C,6811=C,682c=J,6837=C,683e=C,685b=J,685c=J,685d=J,6861=C,6862=C,6863=C,6864=C,6865=C,'
    1575 +'6866=C,6867=C,6868=C,6869=C,6898=C,68a6=C,68ba=J,68bb=J,68c0=C,68c2=C,6917=J,6919=J,691a=J,691b=J,691f=C,6920=C,6921=J,6923=J,6924=C,6925=J,6926=J,6928=J,692a=J,692d=C,693f=J,697c=C,697e=J,697f=J,6980=J,6981=J,6984=C,6987=C,6988=C,6989=C,698a=J,69c7=J,69da=C,69db=C,69dd=J,69df=C,'
    1576 +'69e0=C,6a2b=J,6a2e=J,6a2f=C,6a30=J,6a31=C,6a3b=J,6a67=J,6a72=J,6a73=J,6a78=J,6a79=C,6a7c=C,6ab0=J,6ae4=J,6b1f=J,6b22=C,6b24=C,6b27=C,6b7c=C,6b87=C,6b8b=C,6b92=C,6b93=C,6b9a=C,6ba1=C,6ba8=C,6bb4=C,6bbb=C,6bc2=C,6bd5=C,6bd9=C,6bdf=J,6be1=C,6bee=J,6bf5=C,6c07=C,6c17=J,6c22=C,6c29=C,'
    1577 +'6c47=C,6c49=C,6c62=J,6c64=C,6c9f=C,6ca3=C,6ca4=C,6ca5=C,6ca6=C,6ca7=C,6ca8=C,6ca9=C,6caa=C,6cea=C,6cf7=C,6cf8=C,6cfa=C,6cfb=C,6cfc=C,6cfd=C,6cfe=C,6d43=C,6d45=C,6d46=C,6d47=C,6d48=C,6d49=C,6d4a=C,6d4b=C,6d4d=C,6d4e=C,6d4f=C,6d50=C,6d51=C,6d52=C,6d53=C,6d54=C,6d55=C,6d9b=C,6d9c=J,'
    1578 +'6d9d=C,6d9e=C,6d9f=C,6da0=C,6da1=C,6da2=C,6da4=C,6da6=C,6da7=C,6da8=C,6da9=C,6e0a=C,6e0d=C,6e0e=C,6e10=C,6e11=C,6e14=C,6e17=C,6e7e=C,6e7f=C,6e82=J,6e83=C,6e85=C,6e87=C,6ed7=C,6ede=C,6edf=C,6ee0=C,6ee1=C,6ee4=C,6ee5=C,6ee6=C,6ee8=C,6ee9=C,6eea=C,6f47=C,6f4b=C,6f4d=C,6f57=J,6f59=C,'
    1579 +'6f76=J,6f9c=C,6fbe=C,6fd1=C,6fd2=C,6ff9=J,704f=C,7067=C,706d=C,706f=C,7075=C,707e=C,707f=C,7080=C,7089=C,709c=C,709d=C,70b9=C,70bb=J,70bc=C,70bd=C,70c1=C,70c2=C,70c3=C,70db=C,70e6=C,70e7=C,70e8=C,70e9=C,70eb=C,70ec=C,70ed=C,7116=C,7118=C,7144=J,7173=J,7194=J,7195=J,71f5=J,7231=C,'
    1580 +'7232=C,7237=C,7240=C,724d=C,7275=C,727a=C,728a=C,72b6=C,72b7=C,72b8=C,72b9=C,72c6=J,72c8=C,72de=C,72ec=C,72ed=C,72ee=C,72ef=C,72f1=C,72f2=C,7303=C,730e=C,7315=C,7321=C,732b=C,732e=C,7341=C,736d=C,7391=C,739b=C,73ae=C,73af=C,73b0=C,73b1=C,73ba=C,73c6=J,73d1=C,73f2=C,740e=C,740f=C,'
    1581 +'7410=C,7411=J,743c=C,7443=J,7477=C,748e=C,74d2=C,74e7=J,74e9=J,74ea=J,74ef=C,74f0=J,74f1=J,74f2=J,74f8=J,74fc=J,7505=J,7523=C,7535=C,753b=C,753c=J,7545=C,7551=J,7560=J,7569=J,7573=J,7574=C,757d=J,7596=C,7597=C,759f=C,75a0=C,75a1=C,75ac=C,75ae=C,75af=C,75c7=J,75c8=C,75c9=C,75e8=C,'
    1582 +'75eb=C,7605=C,7606=C,7617=C,7618=C,762a=C,762b=C,762e=C,763b=C,763e=C,763f=C,764c=J,765e=C,7663=C,7667=C,766a=J,766b=C,7691=C,76b1=C,76b2=C,76cf=C,76d0=C,76d1=C,76d6=C,76d8=C,770d=C,7750=C,7751=C,7792=C,7798=C,77a9=C,77eb=C,77f6=C,77fe=C,77ff=C,7800=C,7801=C,7816=C,7817=C,781a=C,'
    1583 +'781c=C,783a=C,783b=C,783e=C,7840=C,7855=C,7856=C,7857=C,7859=C,785a=C,7872=J,7874=J,7877=C,788d=C,7897=J,789b=C,789c=C,78b5=J,78b8=C,7935=J,793c=C,794e=C,7962=C,796f=C,7977=C,7978=C,7985=C,79ef=C,79f0=C,79fd=C,7a23=C,7a2d=C,7a33=C,7a43=J,7a51=C,7a5d=J,7a77=C,7a83=C,7a8d=C,7a8e=C,'
    1584 +'7a9c=C,7a9d=C,7aa5=C,7aa6=C,7aad=C,7ac8=C,7acd=J,7acf=J,7ad3=J,7ad5=J,7ad6=C,7ade=C,7ae1=J,7aea=C,7af0=J,7b02=J,7b03=C,7b0b=C,7b14=C,7b15=C,7b39=J,7b3a=C,7b3c=C,7b3d=J,7b3e=C,7b5a=C,7b5b=C,7b79=C,7b7e=C,7b80=C,7b93=C,7ba5=J,7ba6=C,7ba7=C,7ba8=C,7ba9=C,7baa=C,7bab=C,7bcf=J,7bd1=C,'
    1585 +'7bd3=C,7bee=C,7c13=J,7c16=C,7c17=J,7c31=J,7c41=C,7c4f=J,7c74=C,7c75=J,7c7b=C,7c7e=J,7c81=J,7c82=J,7c8d=J,7c8f=J,7c90=J,7c9c=C,7c9d=C,7ca0=J,7ca8=J,7caa=C,7cab=J,7cad=J,7cae=C,7cc0=J,7cc1=C,7cce=J,7cd8=J,7d25=C,7d26=J,7d27=C,7d5d=C,7d76=C,7d77=C,7d89=C,7d9b=J,7dab=C,7db3=C,7dd1=C,'
    1586 +'7dd5=J,7dfc=C,7e05=J,7e27=C,7e28=J,7e4a=J,7e67=J,7e6e=C,7e83=J,7e90=J,7ea0=C,7ea1=C,7ea2=C,7ea3=C,7ea4=C,7ea5=C,7ea6=C,7ea7=C,7ea8=C,7ea9=C,7eaa=C,7eab=C,7eac=C,7ead=C,7eaf=C,7eb0=C,7eb1=C,7eb2=C,7eb3=C,7eb4=C,7eb5=C,7eb6=C,7eb7=C,7eb8=C,7eb9=C,7eba=C,7ebc=C,7ebd=C,7ebe=C,7ebf=C,'
    1587 +'7ec0=C,7ec1=C,7ec2=C,7ec3=C,7ec4=C,7ec5=C,7ec6=C,7ec7=C,7ec8=C,7ec9=C,7eca=C,7ecb=C,7ecc=C,7ecd=C,7ece=C,7ecf=C,7ed0=C,7ed1=C,7ed2=C,7ed3=C,7ed4=C,7ed5=C,7ed6=C,7ed7=C,7ed8=C,7ed9=C,7eda=C,7edb=C,7edc=C,7edd=C,7ede=C,7edf=C,7ee0=C,7ee1=C,7ee2=C,7ee3=C,7ee5=C,7ee6=C,7ee7=C,7ee8=C,'
    1588 +'7ee9=C,7eea=C,7eeb=C,7eed=C,7eee=C,7eef=C,7ef0=C,7ef2=C,7ef3=C,7ef4=C,7ef5=C,7ef6=C,7ef7=C,7ef8=C,7efa=C,7efb=C,7efc=C,7efd=C,7efe=C,7eff=C,7f00=C,7f01=C,7f02=C,7f03=C,7f04=C,7f05=C,7f06=C,7f07=C,7f08=C,7f09=C,7f0a=C,7f0c=C,7f0e=C,7f11=C,7f12=C,7f13=C,7f14=C,7f15=C,7f16=C,7f17=C,'
    1589 +'7f18=C,7f19=C,7f1a=C,7f1b=C,7f1c=C,7f1d=C,7f1e=C,7f1f=C,7f20=C,7f21=C,7f22=C,7f23=C,7f24=C,7f25=C,7f26=C,7f27=C,7f28=C,7f29=C,7f2a=C,7f2b=C,7f2c=C,7f2d=C,7f2e=C,7f2f=C,7f30=C,7f31=C,7f32=C,7f33=C,7f34=C,7f35=C,7f3c=J,7f42=C,7f4e=C,7f57=C,7f5a=C,7f62=C,7f74=C,7f81=C,7f9f=C,7faa=J,'
    1590 +'7fd8=C,7fda=C,8022=C,8027=C,802e=C,8038=C,8042=C,804b=C,804c=C,804d=C,8054=C,8062=J,8069=C,806a=C,8083=C,80a0=C,80a4=C,80be=C,80bf=C,80c0=C,80c1=C,80c6=C,80e7=C,80e8=C,80ea=C,80eb=C,80f1=J,80f6=C,8109=C,810d=C,810f=C,8110=C,8111=C,8113=C,8114=C,8135=J,8136=C,8138=C,8156=C,8158=C,'
    1591 +'817a=J,817b=C,817e=C,8191=C,81a4=J,81b5=J,81cd=J,81dc=C,8206=C,8220=J,822e=J,8230=C,8231=C,823b=C,8249=J,825d=J,8260=J,8270=C,8273=C,827a=C,8282=C,8297=C,829c=C,82a6=C,82c1=C,82c5=J,82c7=C,82c8=C,82cb=C,82cd=C,82cf=C,830e=C,830f=C,8311=C,8314=C,8315=C,834e=J,835a=C,835b=C,835c=C,'
    1592 +'835e=C,835f=C,8360=C,8361=C,8363=C,8364=C,8365=C,8366=C,8367=C,8368=C,8369=C,836a=C,836b=C,836c=C,836d=C,836e=C,836f=C,83b1=C,83b2=C,83b3=C,83b4=C,83b7=C,83b8=C,83b9=C,83ba=C,83bc=C,8419=J,841a=C,841d=C,8421=J,8422=J,8424=C,8425=C,8426=C,8427=C,8428=C,8429=J,8464=C,8485=J,8487=C,'
    1593 +'8489=C,848b=C,848c=C,8493=C,84d9=J,84da=J,84dc=J,84dd=C,84df=C,84e3=C,84e6=C,8534=C,8536=J,8537=C,8539=C,853a=C,853c=C,8552=C,8572=C,8574=C,85ae=C,85d3=C,85f4=C,8612=J,8630=J,8645=J,864f=C,8651=C,8672=J,867d=C,867e=C,867f=C,8680=C,8681=C,8682=C,86ab=J,86ac=C,86ca=C,86ce=C,86cf=C,'
    1594 +'86ee=C,86ef=J,86f0=C,86f1=C,86f2=C,86f3=C,86f4=C,8717=C,8747=C,8748=C,8749=C,877c=C,877e=C,87a7=J,87a8=C,87a9=J,87cf=C,87d0=J,87f5=J,8845=C,8846=C,8854=C,8865=C,886c=C,8884=C,8885=C,889c=C,88ad=C,88b0=J,88c3=J,88c4=J,88c5=C,88c6=C,88e2=C,88e3=C,88e4=C,88e5=C,8902=J,8904=J,891b=C,'
    1595 +'891c=J,8934=C,8947=C,8977=J,898e=C,89c1=C,89c2=C,89c3=C,89c4=C,89c5=C,89c6=C,89c7=C,89c8=C,89c9=C,89ca=C,89cb=C,89cc=C,89ce=C,89cf=C,89d0=C,89d1=C,89de=C,8a29=C,8a33=J,8a5f=C,8a89=C,8a8a=C,8aac=C,8aad=J,8aae=J,8ada=J,8b21=C,8b2d=C,8ba1=C,8ba2=C,8ba3=C,8ba4=C,8ba5=C,8ba6=C,8ba7=C,'
    1596 +'8ba8=C,8ba9=C,8baa=C,8bab=C,8bad=C,8bae=C,8baf=C,8bb0=C,8bb2=C,8bb3=C,8bb4=C,8bb5=C,8bb6=C,8bb7=C,8bb8=C,8bb9=C,8bba=C,8bbb=C,8bbc=C,8bbd=C,8bbe=C,8bbf=C,8bc0=C,8bc1=C,8bc2=C,8bc3=C,8bc4=C,8bc5=C,8bc6=C,8bc7=C,8bc8=C,8bc9=C,8bca=C,8bcb=C,8bcc=C,8bcd=C,8bce=C,8bcf=C,8bd1=C,8bd2=C,'
    1597 +'8bd3=C,8bd4=C,8bd5=C,8bd6=C,8bd7=C,8bd8=C,8bd9=C,8bda=C,8bdb=C,8bdd=C,8bde=C,8bdf=C,8be0=C,8be1=C,8be2=C,8be3=C,8be4=C,8be5=C,8be6=C,8be7=C,8be8=C,8be9=C,8beb=C,8bec=C,8bed=C,8bee=C,8bef=C,8bf0=C,8bf1=C,8bf2=C,8bf3=C,8bf4=C,8bf5=C,8bf6=C,8bf7=C,8bf8=C,8bf9=C,8bfa=C,8bfb=C,8bfc=C,'
    1598 +'8bfd=C,8bfe=C,8bff=C,8c00=C,8c01=C,8c02=C,8c03=C,8c04=C,8c05=C,8c06=C,8c07=C,8c08=C,8c09=C,8c0a=C,8c0b=C,8c0c=C,8c0d=C,8c0e=C,8c0f=C,8c10=C,8c11=C,8c12=C,8c13=C,8c14=C,8c15=C,8c16=C,8c17=C,8c18=C,8c19=C,8c1a=C,8c1b=C,8c1c=C,8c1d=C,8c1e=C,8c1f=C,8c20=C,8c21=C,8c22=C,8c23=C,8c24=C,'
    1599 +'8c25=C,8c26=C,8c27=C,8c28=C,8c29=C,8c2a=C,8c2b=C,8c2c=C,8c2d=C,8c2e=C,8c2f=C,8c30=C,8c31=C,8c32=C,8c33=C,8c34=C,8c35=C,8c36=C,8c6e=C,8cae=J,8ceb=C,8cec=J,8d0b=C,8d1c=C,8d1d=C,8d1e=C,8d1f=C,8d21=C,8d22=C,8d23=C,8d24=C,8d25=C,8d26=C,8d27=C,8d28=C,8d29=C,8d2a=C,8d2b=C,8d2c=C,8d2d=C,'
    1600 +'8d2e=C,8d2f=C,8d30=C,8d31=C,8d32=C,8d33=C,8d34=C,8d35=C,8d36=C,8d37=C,8d38=C,8d39=C,8d3a=C,8d3b=C,8d3c=C,8d3d=C,8d3e=C,8d3f=C,8d41=C,8d42=C,8d43=C,8d44=C,8d45=C,8d46=C,8d48=C,8d49=C,8d4a=C,8d4b=C,8d4c=C,8d4d=C,8d4e=C,8d4f=C,8d50=C,8d52=C,8d53=C,8d54=C,8d55=C,8d56=C,8d57=C,8d58=C,'
    1601 +'8d59=C,8d5a=C,8d5b=C,8d5c=C,8d5d=C,8d5e=C,8d60=C,8d61=C,8d62=C,8d63=C,8d6a=C,8d71=J,8d75=C,8d8b=C,8db1=C,8db8=C,8dc3=C,8dc4=C,8def=J,8df4=J,8df5=C,8df7=C,8df8=C,8df9=C,8dfb=C,8e0c=C,8e2c=C,8e2f=C,8e51=C,8e52=C,8e7f=C,8e8f=C,8e9c=C,8eae=J,8eaf=C,8eb5=J,8ebb=J,8ebe=J,8ec5=J,8ec8=J,'
    1602 +'8ee4=C,8ef2=C,8f4c=J,8f66=C,8f67=C,8f68=C,8f69=C,8f6b=C,8f6c=C,8f6d=C,8f6e=C,8f6f=C,8f70=C,8f71=C,8f72=C,8f73=C,8f74=C,8f76=C,8f77=C,8f78=C,8f79=C,8f7a=C,8f7b=C,8f7c=C,8f7d=C,8f7e=C,8f7f=C,8f82=C,8f83=C,8f84=C,8f85=C,8f86=C,8f87=C,8f88=C,8f89=C,8f8a=C,8f8b=C,8f8d=C,8f8e=C,8f8f=C,'
    1603 +'8f90=C,8f91=C,8f93=C,8f94=C,8f95=C,8f96=C,8f97=C,8f98=C,8f99=C,8f9a=C,8f9e=C,8fa9=C,8fab=C,8fb7=J,8fb9=C,8fbb=J,8fbc=J,8fbd=C,8fbe=C,8fc1=C,8fc7=C,8fc8=C,8fd0=C,8fd8=C,8fd9=C,8fda=J,8fdb=C,8fdc=C,8fdd=C,8fde=C,8fdf=C,8fe9=C,8ff9=C,9009=C,900a=C,9012=C,9026=C,9027=J,903b=C,9056=J,'
    1604 +'9057=C,9093=C,909d=C,90ac=C,90ae=C,90b9=C,90ba=C,90bb=C,90cf=C,90d0=C,90d1=C,90d2=J,90d3=C,90e6=C,90e7=C,90f8=C,915b=J,915d=C,9171=C,917d=C,917e=C,917f=C,9196=C,91ca=C,91d7=J,91fa=C,91fb=J,91fe=C,9208=C,920e=C,9225=J,9226=J,9228=J,9229=J,922c=J,9239=J,923e=J,9255=C,9262=C,926b=J,'
    1605 +'9274=C,9286=J,92ab=J,92ae=C,92af=J,92b1=C,92c5=J,92e5=C,92ed=C,92f2=J,9307=C,9332=C,9335=J,933a=J,933e=C,9340=C,9341=C,9344=J,9369=C,9384=C,9386=J,9387=C,93b8=C,93b9=J,93bf=C,93e5=J,93f0=C,941d=C,9420=J,9421=J,9426=C,9427=C,942f=C,9453=J,9454=C,9465=C,9479=C,9486=C,9487=C,9488=C,'
    1606 +'9489=C,948a=C,948b=C,948c=C,948d=C,948e=C,948f=C,9490=C,9492=C,9493=C,9494=C,9495=C,9496=C,9497=C,9498=C,9499=C,949a=C,949b=C,949d=C,949e=C,949f=C,94a0=C,94a1=C,94a2=C,94a4=C,94a5=C,94a6=C,94a7=C,94a8=C,94a9=C,94aa=C,94ab=C,94ac=C,94ad=C,94ae=C,94af=C,94b0=C,94b1=C,94b2=C,94b3=C,'
    1607 +'94b4=C,94b5=C,94b6=C,94b7=C,94b9=C,94ba=C,94bb=C,94bc=C,94bd=C,94be=C,94bf=C,94c0=C,94c1=C,94c2=C,94c3=C,94c4=C,94c5=C,94c6=C,94c8=C,94c9=C,94ca=C,94cb=C,94cc=C,94cd=C,94ce=C,94cf=C,94d0=C,94d1=C,94d2=C,94d3=C,94d5=C,94d7=C,94d9=C,94db=C,94dc=C,94dd=C,94de=C,94df=C,94e0=C,94e1=C,'
    1608 +'94e2=C,94e3=C,94e4=C,94e5=C,94e7=C,94e8=C,94e9=C,94ea=C,94eb=C,94ec=C,94ed=C,94ee=C,94ef=C,94f0=C,94f1=C,94f2=C,94f3=C,94f5=C,94f6=C,94f7=C,94f8=C,94f9=C,94fa=C,94fc=C,94fd=C,94fe=C,94ff=C,9500=C,9501=C,9502=C,9503=C,9504=C,9505=C,9506=C,9507=C,9508=C,9509=C,950b=C,950c=C,950e=C,'
    1609 +'950f=C,9510=C,9511=C,9512=C,9513=C,9514=C,9515=C,9517=C,9518=C,9519=C,951a=C,951b=C,951d=C,951e=C,951f=C,9521=C,9522=C,9523=C,9524=C,9525=C,9526=C,9527=C,9528=C,952b=C,952d=C,952e=C,952f=C,9530=C,9531=C,9532=C,9534=C,9535=C,9536=C,9537=C,9538=C,9539=C,953b=C,953c=C,953e=C,953f=C,'
    1610 +'9540=C,9541=C,9542=C,9543=C,9544=C,9545=C,9547=C,9549=C,954a=C,954b=C,954c=C,954d=C,954e=C,954f=C,9550=C,9551=C,9552=C,9553=C,9554=C,9556=C,9557=C,9558=C,955a=C,955b=C,955c=C,955d=C,955e=C,9562=C,9563=C,9564=C,9565=C,9566=C,9567=C,9568=C,9569=C,956a=C,956b=C,956c=C,956d=C,956e=C,'
    1611 +'956f=C,9570=C,9571=C,9572=C,9573=C,9574=C,9576=C,957f=C,9584=J,9587=J,958a=J,9596=J,95a0=J,95a7=C,95aa=J,95b2=C,95b8=J,95e6=J,95e8=C,95e9=C,95ea=C,95ed=C,95ee=C,95ef=C,95f0=C,95f1=C,95f2=C,95f4=C,95f5=C,95f7=C,95f8=C,95f9=C,95fa=C,95fb=C,95fc=C,95fd=C,95fe=C,95ff=C,9600=C,9601=C,'
    1612 +'9602=C,9603=C,9604=C,9605=C,9606=C,9608=C,9609=C,960a=C,960b=C,960c=C,960d=C,960e=C,960f=C,9610=C,9611=C,9612=C,9614=C,9615=C,9616=C,9617=C,9619=C,961a=C,961f=C,9633=C,9634=C,9635=C,9636=C,9645=C,9646=C,9647=C,9648=C,9649=C,9655=C,9668=C,9669=C,968f=C,9690=C,96b6=C,96be=C,96cf=C,'
    1613 +'96e0=C,96eb=J,96f3=C,96fe=C,9701=C,972d=C,974d=J,974e=J,974f=J,9753=C,9765=C,9779=J,9786=J,9790=J,9791=C,9792=C,979c=J,97af=C,97bd=C,97e6=C,97e7=C,97e8=C,97e9=C,97ea=C,97eb=C,97ec=C,97f5=C,983d=C,9854=C,986c=C,9875=C,9876=C,9877=C,9878=C,9879=C,987a=C,987b=C,987c=C,987d=C,987e=C,'
    1614 +'987f=C,9880=C,9881=C,9882=C,9883=C,9884=C,9885=C,9886=C,9887=C,9888=C,9889=C,988a=C,988b=C,988c=C,988d=C,988f=C,9890=C,9891=C,9893=C,9894=C,9896=C,9897=C,9898=C,9899=C,989b=C,989c=C,989d=C,989e=C,989f=C,98a0=C,98a1=C,98a2=C,98a4=C,98a5=C,98a6=C,98a7=C,98aa=J,98ce=C,98d2=C,98d3=C,'
    1615 +'98d4=C,98d5=C,98d7=C,98d8=C,98d9=C,98de=C,98e8=C,98ff=C,9904=C,990d=C,990e=C,990f=C,9919=J,991c=C,9936=C,9937=C,9942=J,994a=C,9962=C,9965=C,9966=C,9967=C,9968=C,9969=C,996a=C,996b=C,996c=C,996d=C,996e=C,996f=C,9970=C,9971=C,9972=C,9973=C,9974=C,9975=C,9976=C,9977=C,9978=C,9979=C,'
    1616 +'997a=C,997b=C,997c=C,997d=C,997f=C,9981=C,9983=C,9984=C,9985=C,9986=C,9987=C,9988=C,9989=C,998a=C,998b=C,998d=C,998e=C,998f=C,9990=C,9991=C,9992=C,9993=C,9994=C,9995=C,99e1=C,99f2=J,9a6b=J,9a6c=C,9a6d=C,9a6e=C,9a6f=C,9a70=C,9a71=C,9a73=C,9a74=C,9a75=C,9a76=C,9a77=C,9a78=C,9a79=C,'
    1617 +'9a7a=C,9a7b=C,9a7c=C,9a7d=C,9a7e=C,9a7f=C,9a80=C,9a81=C,9a82=C,9a84=C,9a85=C,9a86=C,9a87=C,9a88=C,9a8a=C,9a8b=C,9a8c=C,9a8e=C,9a8f=C,9a90=C,9a91=C,9a92=C,9a93=C,9a96=C,9a97=C,9a98=C,9a9a=C,9a9b=C,9a9c=C,9a9d=C,9a9e=C,9a9f=C,9aa0=C,9aa1=C,9aa2=C,9aa4=C,9aa5=C,9aa7=C,9ac5=C,9acb=C,'
    1618 +'9acc=C,9aea=J,9b13=C,9b47=C,9b49=C,9b5d=J,9b5e=J,9b6c=J,9b74=J,9b78=J,9b79=J,9b81=C,9b84=J,9b8d=C,9b8e=C,9b95=J,9b96=J,9b97=J,9b98=J,9b9d=C,9b9f=J,9ba3=C,9bb1=J,9bb4=J,9bba=C,9bce=J,9bcf=J,9bd0=J,9bd1=J,9bd2=J,9be1=J,9bf0=J,9bf1=J,9bf2=J,9bf3=J,9bff=C,9c02=C,9c04=J,9c0c=C,9c10=C,'
    1619 +'9c12=J,9c18=J,9c1f=C,9c21=J,9c27=C,9c2e=J,9c2f=J,9c30=J,9c35=C,9c39=J,9c45=C,9c47=J,9c48=J,9c5a=J,9c69=J,9c6a=J,9c6b=J,9c70=J,9c7c=C,9c7d=C,9c7f=C,9c81=C,9c82=C,9c85=C,9c86=C,9c87=C,9c88=C,9c8a=C,9c8b=C,9c8d=C,9c8e=C,9c8f=C,9c90=C,9c91=C,9c92=C,9c94=C,9c96=C,9c97=C,9c99=C,9c9a=C,'
    1620 +'9c9b=C,9c9c=C,9c9d=C,9c9e=C,9c9f=C,9ca0=C,9ca1=C,9ca2=C,9ca3=C,9ca4=C,9ca5=C,9ca6=C,9ca7=C,9ca8=C,9ca9=C,9cab=C,9cad=C,9cae=C,9cb0=C,9cb1=C,9cb2=C,9cb3=C,9cb5=C,9cb6=C,9cb7=C,9cb8=C,9cbb=C,9cbd=C,9cbf=C,9cc1=C,9cc3=C,9cc4=C,9cc5=C,9cc6=C,9cc7=C,9cca=C,9ccc=C,9ccd=C,9cce=C,9ccf=C,'
    1621 +'9cd1=C,9cd2=C,9cd3=C,9cd4=C,9cd5=C,9cd6=C,9cd7=C,9cd8=C,9cd9=C,9cdb=C,9cdc=C,9cdd=C,9cde=C,9cdf=C,9ce2=C,9ce3=C,9cec=C,9cf0=J,9cfe=C,9d2b=J,9d30=J,9d34=C,9d46=J,9d47=J,9d48=J,9d64=J,9d6e=C,9d93=C,9da5=C,9dab=J,9dc0=C,9dc4=C,9dc9=C,9e0a=C,9e1f=C,9e20=C,9e21=C,9e22=C,9e23=C,9e25=C,'
    1622 +'9e26=C,9e27=C,9e28=C,9e29=C,9e2a=C,9e2b=C,9e2c=C,9e2d=C,9e2e=C,9e2f=C,9e30=C,9e31=C,9e32=C,9e33=C,9e35=C,9e36=C,9e37=C,9e38=C,9e39=C,9e3a=C,9e3b=C,9e3c=C,9e3d=C,9e3e=C,9e3f=C,9e41=C,9e42=C,9e43=C,9e44=C,9e45=C,9e46=C,9e47=C,9e48=C,9e49=C,9e4a=C,9e4b=C,9e4c=C,9e4f=C,9e50=C,9e51=C,'
    1623 +'9e52=C,9e55=C,9e56=C,9e57=C,9e58=C,9e59=C,9e5a=C,9e5b=C,9e5c=C,9e5e=C,9e61=C,9e63=C,9e64=C,9e65=C,9e66=C,9e67=C,9e68=C,9e69=C,9e6a=C,9e6b=C,9e6c=C,9e6d=C,9e6f=C,9e70=C,9e73=C,9e7e=C,9e91=J,9ea6=C,9eaf=C,9eb8=C,9ebd=C,9ebf=J,9ec9=C,9ee1=C,9ee9=C,9efe=C,9f0b=C,9f0d=C,9f21=J,9f50=C,'
    1624 +'9f51=C,9f7f=C,9f80=C,9f83=C,9f84=C,9f85=C,9f86=C,9f87=C,9f88=C,9f89=C,9f8a=C,9f8b=C,9f8c=C,9f99=C,9f9a=C,9f9b=C,9f9f=C,fa0f=J,fa13=J,fa20=J,fa21=J,fa24=J,fa29=J',1,16);
    1625 //	HKEY_CLASSES_ROOT\MIME\Database\Charset
    1626 //	將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字，Big5常用字卻常常是gb中奇怪字碼與罕用字
    1627 setObjValue('autodetectEncodeCode','GB2312=3000,Big5=3000,shift_jis=900,iso-8859-1=2000',1);
    1628
    1629
    1630 TODO:
    1631 只檢測常用的幾個字，無法判別才廣泛測試。
    1632 */
    1633 //var FN='I:\\Documents and Settings\\kanashimi\\My Documents\\kanashimi\\www\\cgi-bin\\game\\sjis.txt',enc=autodetectEncode(FN);alert('['+enc+'] '+FN+'\n'+_.read_file(FN,enc).slice(0,900));
    1634 /*	自動判別檔案（或字串）之編碼	文字エンコーディング判定を行う
    1635 	http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html
    1636 	http://www.ericphelps.com/q193998/
    1637 	http://hp.vector.co.jp/authors/VA003334/ado/adostream.htm
    1638 */
    1639 //autodetectEncode[generateCode.dLK]='is_file,simpleFileDformat,_.open_file,autodetectStringEncode,autodetectHTMLEncode';
    1640 CeL.IO.Windows.file
    1641 .
    1642 autodetectEncode=function(FN,isHTML){
    1643  var t,code;
    1644  if(typeof ActiveXObject=='undefined'){alert("autodetectEncode: Can't find ActiveXObject!");return;}
    1645  //if(typeof autodetectHTMLEncode!='function')isHTML=false;
    1646  if(!is_file(FN))return FN.length<64?simpleFileDformat:(t=autodetectStringEncode(FN))?t:(isHTML||typeof isHTML=='undefined')&&(t=autodetectHTMLEncode(FN))?t:simpleFileDformat;
    1647  _.open_file(FN,'iso-8859-1');	//	讀 binary data 用 'iso-8859-1' 會 error encoding.
    1648  if(!AdoEnums||!AdoStream)return simpleFileDformat;
    1649  AdoStream.LoadFromFile(FN);
    1650  t=AdoStream.ReadText(3);//Read(3);//
    1651  //alert(FN+'\n'+t.charCodeAt(0)+','+t.charCodeAt(1)+','+t.charCodeAt(2));
    1652
    1653  //if(typeof t!='string')return simpleFileDformat;//t=''+t;	//	此時type通常是unknown，不能用+=
    1654  //	Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏，它是以FF-FE這兩個bytes表達，在BE(big endian)裏，是FEFF。而在UTF-8裏，它是以EF-BB-BF這三個bytes表達。
    1655  if(t.slice(0,2)=='\xFF\xFE')code='unicodeFFFE';
    1656  else if(t.slice(0,2)=='\xFE\xFF')code='unicode';
    1657  else if(t=='\xEF\xBB\xBF')code='UTF-8';
    1658  else{
    1659   // 即使是用OpenTextFile(_.open_format.TristateFalse)，UTF-8還是會被轉換而判別不出來。
    1660   //	from http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html
    1661   var l,codes={},reg=new RegExp(),stream=new ActiveXObject("ADODB.Stream");
    1662   codes['iso-8859-1']='[\\x09\\x0a\\x0d\\x20-\\x7e]';
    1663   codes['big5']=codes['iso-8859-1']+
    1664 	'|[\\xa4-\\xc6\\xc9-\\xf9][\\x40-\\xfe]';	//	http://www.cns11643.gov.tw/web/word/big5/index.html
    1665   codes['shift_jis']=codes['iso-8859-1']+
    1666 	'|[\\x81-\\x9f\\xe0-\\xef\\xfa-\\xfc][\\x40-\\x7e\\x80-\\xfc]|[\\xa1-\\xdf]';	//	http://hp.vector.co.jp/authors/VA013241/misc/shiftjis.html
    1667   codes['euc-jp']=codes['iso-8859-1']+
    1668 	'|\\x8f[\\xa1-\\xfe][\\xa1-\\xfe]|[\\xa1-\\xfe][\\xa1-\\xfe]|\\x8e[\\xa1-\\xdf]';
    1669   codes['utf-8']=codes['iso-8859-1']+
    1670 	'|[\\xc0-\\xdf][\\x80-\\xbf]|[\\xe0-\\xef][\\x80-\\xbf]{2}|[\\xf0-\\xf7][\\x80-\\xbf]{3}'+
    1671 	'|[\\xf8-\\xfb][\\x80-\\xbf]{4}|[\\xfc-\\xfd][\\x80-\\xbf]{5}';
    1672   codes['gb2312']=codes['iso-8859-1']+	//	GBK
    1673 	'|[\\xa1-\\xf7][\\xa1-\\xfe]';	//	http://zh.wikipedia.org/wiki/GB_18030	http://zh.wikipedia.org/wiki/GB_2312
    1674
    1675   stream.type=AdoEnums.adTypeBinary;
    1676   stream.open();
    1677   stream.loadFromFile(FN);
    1678   stream.position=0;
    1679   t=stream.read();
    1680   stream.close();
    1681   stream=null;
    1682
    1683   t=translate_AdoStream_binary_data(t,4e3);
    1684
    1685   for(var _e in codes){
    1686    reg=new RegExp('^(?:'+codes[_e]+')');
    1687    var l=0,s=t;
    1688    while(l!=s.length)l=s.length,s=s.replace(reg,"");
    1689    if(s==""){code=_e;break;}
    1690   }
    1691
    1692  }
    1693  //sl('autodetectEncode: coding: ['+code+'] in parse 1.');
    1694
    1695  //	假如是HTML檔，判斷是否有charset設定。這個判別放在unicode之後，其他自動判別之前。
    1696  if(isHTML||typeof isHTML=='undefined'&&/\.s?html?$/i.test(FN)){
    1697   if(AdoStream.Type==AdoEnums.adTypeBinary)_.open_file(FN,'iso-8859-1');
    1698   AdoStream.Position=0,AdoStream.Charset='iso-8859-1';	//	讀 binary data 用 'iso-8859-1' 會 error encoding.
    1699   if(t=autodetectHTMLEncode(AdoStream.ReadText(4e3)))code=t;
    1700  }
    1701  //sl('autodetectEncode: coding: ['+code+'] in parse 2.');
    1702
    1703  //autodetectEncodeCode.GB2312=900000;	// 4 test
    1704  if(!code)for(var i in autodetectEncodeCode){
    1705   if(AdoStream.Type==AdoEnums.adTypeBinary)_.open_file(FN,'iso-8859-1');
    1706   if(AdoStream.Position=0,i==autodetectStringEncode(AdoStream.ReadText(autodetectEncodeCode[AdoStream.Charset=i]))){code=i;break;}
    1707  }
    1708
    1709  AdoStream.Close();
    1710  return code||simpleFileDformat;	//	ascii=iso-8859-1,_autodetect,_autodetect_all
    1711 };
    1712
    1713 /**
    1714  * 判斷HTML檔是否有charset設定
    1715  * @param file_contents	file contents
    1716  * @returns
    1717  */
    1718 function autodetectHTMLEncode(file_contents) {
    1719 	var m;
    1720 	if ((m = file_contents.match(/<meta\s+([^>]+)>/i))
    1721 			&& (m = m[1].match(/content="([^"]+)"/i) || m[1].match(/content=([^\w]+)/i))
    1722 			&& (m = m[1].match(/charset=([\w-]{2,})/i))
    1723 			|| (m = file_contents.match(/<\?xml\s[^>]+\sencoding\s*=\s*["']([a-z\d\-]+)["']/i)))
    1724 		return m[1];
    1725 };
    1726
    1727 CeL.IO.Windows.file
    1728 .
    1729 /**
    1730  * 靠常用字自動判別字串之編碼	string,預設編碼
    1731  */
    1732 autodetectStringEncode=function(str){
    1733  if(typeof str!='string'||!(str=str.replace(/\s+/g,'')))return;
    1734  var len=str.length,i=0,c,a,kana=0,jianhuazi=0,halfwidthKatakana=0,Hangul=0,ascii=0,asciiHigh=0,kanji=0,kokuji=0,symbol=0,unknown=0;
    1735  //if(len>9000)len=9000;
    1736  //var unknownC='';
    1737
    1738  //	char分類
    1739  for(;i<len;i++)
    1740   if(c=str.charCodeAt(i),c<0x80)ascii++;
    1741   else if(c<0x100)asciiHigh++;
    1742   else if(c>0x3040&&c<0x30ff)kana++;
    1743   else if(c==0x30fb||c>0xff65&&c<0xff9e)halfwidthKatakana++;
    1744   else if(c>=0x1100&&c<0x11fa||c>=0xac00&&c<0xad00||c>=0xd700&&c<0xd7a4)Hangul++;
    1745   else if(c>0x4dff&&c<0x9fa6){kanji++,a=autodetectEncodeSP[c];if(a=='C')jianhuazi++;else if(a=='J')kokuji++;}
    1746   else if(c>0xfa00&&c<0xfa6b){if(autodetectEncodeSP[c]=='J')kokuji++;}
    1747   else if(c>0x2010&&c<0x2610||c>=0xfe30&&c<0xfe70||c>0xff00&&c<0xff5f)symbol++;
    1748   else if(c>=0x3000&&c<0x3400||c>0x33ff&&c<0x4db6)
    1749    if(autodetectEncodeSP[c]=='J')kokuji++;else symbol++;
    1750   else unknown++;//,unknownC+=str.charAt(i);
    1751
    1752  //alert('len='+len+'\nkana='+kana+'\nkokuji='+kokuji+'\njianhuazi='+jianhuazi+'\nhalfwidthKatakana='+halfwidthKatakana+'\nHangul='+Hangul+'\nascii='+ascii+'\nasciiHigh='+asciiHigh+'\nkanji='+kanji+'\nsymbol='+symbol+'\nunknown='+unknown);
    1753  //if(unknownC)alert('unknown:\n'+unknownC.slice(0,200));//alert(unknownC.slice(0,200)+'\n'+str.slice(0,1000));
    1754  //	依各種常用字母之條件判別
    1755  return ascii+asciiHigh==len?'iso-8859-1'
    1756 	:unknown>.05*(len-ascii)?''//unicode	//	unknown不能太多
    1757 	:kana>.2*len&&kanji+kana+symbol>3*halfwidthKatakana?'shift_jis'
    1758 	:kanji+symbol>.7*(len-ascii)&&kana<.05*(len-ascii)?	jianhuazi>.1*kanji?'GB2312':'Big5'
    1759 	:Hangul+symbol>.7*(len-ascii)?'korean'//ks_c_5601
    1760 	:kanji>.2*(len-ascii)?	jianhuazi>.1*kanji?kokuji>.02*kanji?'unicode':'GB2312':kokuji>.02*kanji?'shift_jis':'Big5'
    1761 	:'';//unicode
    1762 };
    1763
    1764 /*
    1765 http://bbs.ee.ntu.edu.tw/boards/Linux/7/9/58.html	http://libai.math.ncu.edu.tw/~shann//Chinese/big5.html	http://wiki.debian.org.tw/index.php/Big5Variants	http://leoboard.cpatch.org/cgi-bin/topic.cgi?forum=20&topic=64&changemode=1
    1766 http://www.theorem.ca/~mvcorks/cgi-bin/unicode.pl.cgi?start=F900&end=FAFF	http://homepage1.nifty.com/nomenclator/unicode/normalization.htm
    1767
    1768 Unicode的漢字大致是以康熙部首排序，不過間中有部分字排錯部首筆劃
    1769 第一批在1993年加進Unicode的，
    1770 於中國內地、台灣、南韓及日本已有字集的漢字，
    1771 編碼於U+4E00至U+9FA5，
    1772 亦有部分南韓重覆漢字被編到U+F900至U+FA0B、
    1773 兩個Big-5重覆漢字被編到U+FA0C至U+FA0D、
    1774 日本廠商漢字被編到U+FA0E至U+FA2D
    1775
    1776 全形符號（只限鍵盤上那94個）位於U+FF01至U+FF5E
    1777 中日韓專用符號放到了U+3000至U+33FF內，
    1778 其餘有部分符號放到了U+2XXX及U+FE30至U+FE6F
    1779
    1780 第二批在1999年加進Unicode的，
    1781 加進了新加坡用漢字、南韓PKS C 5700-2 1994、
    1782 部分CNS11643第三、四、十五字面等用字、
    1783 未包括在第一批字的數個GB字集用字，
    1784 被編入U+3400至U+4DB5
    1785
    1786 第三批在2001年加進Unicode的，
    1787 加進了CNS11643第三、四、五、六、七、十五字面所有字、
    1788 香港增補字集用字、四庫全書、辭海、辭源、康熙字典、
    1789 漢語大字典、漢語大詞典內的所有用字，
    1790 被編入U+20000至U+2A6D6
    1791 JIS-X0213漢字被加到U+FA30至U+FA6A
    1792 CNS11643重覆漢字被加到U+2F800至U+2FA1D
    1793
    1794 简化字总表	http://cdns.twnic.net.tw/cjktable/	http://www.sxyw.cn/YuWenGongZuo/gfzs22.htm	http://huayuqiao.org/articles/xieshiya/Simplified/6_XinJiaPoTiaoZhengJianTiZi-XP.htm	http://www.hk-place.com/vp.php?board=2&id=333-9
    1795 简化字分布似乎並無規範，只好以array判斷:
    1796
    1797 <div id="dataGB">
    1798 http://cdns.twnic.net.tw/cjktable/simtab.html
    1799 簡化字總表之 UNICODE 碼表
    1800 </div>
    1801 <div id="dataJP">
    1802 http://homepage2.nifty.com/TAB01645/ohara/index_j2.htm
    1803 JIS区点索引
    1804 </div>
    1805
    1806 <script type="text/javascript">
    1807 var i=0,c=0,autodetectEncodeSP=[],m=document.getElementById('dataGB').innerHTML.match(/\([0-9A-F]{4},\w*\)/g),t="setObjValue('autodetectEncodeSP','";
    1808 for(;i<m.length;i++)//if(m[i].indexOf('C')!=-1&&m[i].slice(m[i].indexOf(',')+1).indexOf('T')==-1)t+=m[i].substr(1,5);
    1809  if(m[i].indexOf('T')==-1)autodetectEncodeSP[parseInt(m[i].substr(1,4),16)]='C';
    1810 for(i=0,m=document.getElementById('dataJP').innerHTML.match(/【.】/g);i<m.length;i++)
    1811  autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]=autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]?0:'J';
    1812
    1813 m=[];for(i in autodetectEncodeSP)m.push(parseInt(i));m.sort();
    1814 for(i=0;i<m.length;i++)if(autodetectEncodeSP[m[i]]){t+=m[i].toString(16)+'='+autodetectEncodeSP[m[i]]+',',c++;if(c%40==0)t+="'<br/>+'";}
    1815 alert(c+'字');
    1816 document.getElementById('dataJP').innerHTML='';
    1817 document.getElementById('dataGB').innerHTML=t.slice(0,-1)+"',1,16);";
    1818 </script>
    1819
    1820
    1821 和製漢字(国字)は、和語(ﾔﾏﾄｺﾄﾊﾞ)に相当する漢字が無い場合に新規につくられたもので、奈良時代から作られた。ほとんどは訓読みしかない。魚篇や木篇が多い。
    1822 http://homepage2.nifty.com/TAB01645/ohara/index.htm
    1823 http://zh.wiktionary.org/wiki/%E8%BE%BB
    1824 http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=8fbb
    1825 http://jprs.jp/doc/rule/saisoku-1-wideusejp-furoku-4.html
    1826 http://m2000.idv.tw/informer/zhi/char-root.htm
    1827 http://www.ajisai.sakura.ne.jp/~dindi/chrc/ref/wincode2.txt
    1828 http://cs-people.bu.edu/butta1/personal/hkscs/hkscs-oct.html
    1829 http://www.nobi.or.jp/i/kotoba/kanji/wasei-kanji.html
    1830 http://www.melma.com/mag/52/m00011552/a00000066.html
    1831
    1832
    1833 韓語字母/諺文
    1834 http://www.sinica.edu.tw/~cytseng/Korean%20reader/hangul.htm
    1835 http://www.unicode.org/charts/normalization/
    1836
    1837 old:
    1838 //	自動判別檔案（或字串）之編碼
    1839 function autodetectEncode(FN){
    1840  if(!is_file(FN))return FN.length>64?autodetectStringEncode(FN):simpleFileDformat;
    1841  _.open_file(FN,'iso-8859-1');
    1842  if(!AdoEnums)return simpleFileDformat;
    1843  //AdoStream.Type=AdoEnums.adTypeBinary;
    1844  AdoStream.LoadFromFile(FN);
    1845  var t=AdoStream.ReadText(3),code;
    1846  //	Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏，它是以FF-FE這兩個bytes表達，在BE(big endian)裏，是FEFF。而在UTF-8裏，它是以EF-BB-BF這三個bytes表達。
    1847  if(t.slice(0,2)=='\xFF\xFE')code='unicodeFFFE';
    1848  if(t.slice(0,2)=='\xFE\xFF')code='unicode';
    1849  if(t=='\xEF\xBB\xBF')code='UTF-8';
    1850  if(code){AdoStream.Close();return code;}
    1851
    1852  if(!code)with(AdoStream){
    1853   //	將sjis排在gb與Big5前面是因為sjis常符合gb，且sjis之判定相當嚴。
    1854   if(!code)Position=0,Charset='shift_jis',code=autodetectStringEncode(ReadText(900),Charset);
    1855   //	將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字，Big5常用字卻常常是gb中奇怪字碼與罕用字
    1856   if(!code)Position=0,Charset='GB2312',code=autodetectStringEncode(ReadText(2000),Charset);
    1857   if(!code)Position=0,Charset='Big5',code=autodetectStringEncode(ReadText(2000),Charset);
    1858  }
    1859
    1860  AdoStream.Close();
    1861  return code||simpleFileDformat;	//	ascii=iso-8859-1,_autodetect,_autodetect_all
    1862 }
    1863 //	靠常用字自動判別字串之編碼	string,預設編碼
    1864 function autodetectStringEncode(str,dcode){
    1865  var code;
    1866  if(str.length>9000)str=str.slice(0,9000);
    1867
    1868  //	將sjis排在gb與Big5前面是因為sjis常符合gb，且sjis之判定相當嚴。
    1869  if(dcode=='shift_jis'||!dcode&&!code){
    1870   //	http://www.asahi-net.or.jp/~hc3j-tkg/unicode/	http://www.unicode.org/Public/UNIDATA/DerivedCoreProperties.txt
    1871   var i=0,c,k=0,u=0,h=0;//h_=u_=k_='';
    1872   for(;i<str.length;i++)if(c=str.charCodeAt(i),c>0xFF)
    1873 	if(c==0x30FB||c>0xFF65&&c<0xFF9E)h++;//,h_+=str.charAt(i);//||c==0xE134	//	HALFWIDTH KATAKANA LETTER等可能不是日文文件中會出現的char
    1874 	else if(c>0x3040&&c<0x30FF)k++;//,k_+=str.charAt(i);	//	kana
    1875 	else u++;//,u_+=str.charAt(i);	//	unknown kanji
    1876   //alert(k+','+u+','+h+'\n*'+k_+'\n*'+u_+'\n*'+h_);//alert(u_.charCodeAt(2));
    1877   if(k+u>2*h)code='shift_jis';	//	HALFWIDTH KATAKANA LETTER數目比漢字少時判別為shift_jis
    1878  }
    1879
    1880 //	將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字，Big5常用字卻常常是gb中奇怪字碼與罕用字
    1881  if(dcode=='Big5'||dcode=='GB2312'||!dcode&&!code){
    1882   var i=0,c,k=0,u=0;//k_=u_='';
    1883   for(;i<str.length;i++)if(c=str.charCodeAt(i),c>0xFF)
    1884 	if(c>0x4DFF&&c<0x9FA6||c>0xFF00&&c<0xFF5F||c>0x33ff&&c<0x4DB6||c==0x2605||c==0x2606)k++;//,k_+=str.charAt(i);	//	2605,6:★☆
    1885 	else u++;//,u_+=str.charAt(i);
    1886   //alert(k+','+u+'\n'+k_+'\n*'+u_);
    1887   if(k>5*u)code=dcode||'Big5';	//	漢字比不認識的字多時判定
    1888  }
    1889
    1890  if(dcode=='iso-8859-1'||dcode=='ascii'||!dcode&&!code){
    1891  }
    1892
    1893  return code;
    1894 }
    1895 */
    1896
    1897
    1898 /*	將 iso-8859-1 轉成utf-8
    1899 To use:
    1900 ..
    1901 translated=turnBinStr(original);
    1902 ..
    1903 translated=turnBinStr();	//	delete temp file
    1904 */
    1905 turnBinStr.temp_file = 'turnBinStr.tmp'; // temp file name
    1906 function turnBinStr(t, _enc) {
    1907 	if (typeof t != 'undefined') {
    1908 		if (!turnBinStr.tmpF)
    1909 			turnBinStr.tmpF = getFP(turnBinStr.temp_file, 1);
    1910
    1911 	//t+='';
    1912 	//if(t.replace(/[^\x00-\x7f]+/g,''))return t;
    1913 	//var _q=t.replace(/[^?]+/g,'').length,_t,_j=0;
    1914 	_.write_file(turnBinStr.tmpF,''+t,'iso-8859-1');
    1915 	//alert(turnBinStr.tmpF+'\n'+simpleFileErr.description+'\n'+t+'\n'+_.read_file(turnBinStr.tmpF,'utf-8'));
    1916 	return _.read_file(turnBinStr.tmpF,'utf-8');
    1917 /*
    1918   if(!_enc)_enc='utf-8,Big5,shift_jis,euc-jp,GB2312'.split(',');
    1919   else if(!(_enc instanceof Array))_enc=[_enc];
    1920   for(;_j<_enc.length;_j++)
    1921    if((_t=_.read_file(turnBinStr.tmpF,_enc[_j])).replace(/[^?]+/g,'').length==_q)
    1922     return _t;//'['+_enc[_j]+']'+
    1923   return t;
    1924 */
    1925 	}
    1926 	// 有時會出錯
    1927 	try {
    1928 		fso.DeleteFile(turnBinStr.tmpF);
    1929 	} catch (e) {
    1930 	}
    1931 }
    1932
    1933
    1934
    1935
    1936
    1937 //folder_info[generateCode.dLK]='initWScriptObj';
    1938 //	需同時修改if(traverseSubDirectory==folder_info.f.noNewObj)段落之return!
    1939
    1940 //setObjValue('folder_info.f','noNewObj=-1,files,dirs,fsize,size,Tsize=3,Tfiles,Tdirs',1);
    1941 CeL.IO.Windows.file
    1942 .
    1943 /**
    1944  * Get the infomation of folder
    1945  * @param folder_path	folder path
    1946  * @param file_filter
    1947  * @param traverseSubDirectory
    1948  * @return
    1949  * @example
    1950  * var finfo=new folder_info(path or folder object,extFilter,0/1);
    1951  * @deprecated	以 <a href="#.traverse_file_system">traverse_file_system</a> 代替
    1952  * @memberOf	CeL.IO.Windows.file
    1953  */
    1954 folder_info=function(folder_path,file_filter,traverseSubDirectory){
    1955  var dir,filesCount,subDirectorysCount,total_size_of_files,total_size_of_this_folder,total_filesCount,total_subDirectorysCount;
    1956  filesCount=subDirectorysCount=total_size_of_files=total_size_of_this_folder=total_filesCount=total_subDirectorysCount=0;
    1957  if(typeof traverseSubDirectory=='undefined')traverseSubDirectory=1;
    1958
    1959  if(typeof folder_path=='object')dir=folder_path;
    1960  else if(folder_path){
    1961   if(!folder_path.slice(-1)!=path_separator)folder_path+=path_separator;
    1962   try{dir=fso.GetFolder(folder_path);}catch(e){dir=0;}
    1963  }
    1964
    1965  if(dir){
    1966   total_subDirectorysCount=subDirectorysCount=dir.SubFolders.Count;
    1967   var i,t,f=new Enumerator(dir.SubFolders);
    1968   if(traverseSubDirectory||traverseSubDirectory==folder_info.f.noNewObj)for(;!f.atEnd();f.moveNext()){
    1969    i=f.item();
    1970    t=folder_info(i,file_filter,folder_info.f.noNewObj);
    1971    //alert(i.path+'\n'+t[folder_info.f.size]+','+t[folder_info.f.Tfiles]+','+t[folder_info.f.Tdirs]);
    1972    total_size_of_this_folder+=t[folder_info.f.size];
    1973    total_filesCount+=t[folder_info.f.Tfiles];
    1974    total_subDirectorysCount+=(t[folder_info.f.Tdirs]||0);
    1975   }
    1976
    1977   //alert(dir.files.Count+'\n'+total_filesCount);
    1978   total_filesCount+=(filesCount=dir.files.Count);
    1979   f=new Enumerator(dir.files);
    1980   for(;!f.atEnd();f.moveNext()){
    1981    i=f.item();
    1982    if(file_filter&&!file_filter.test(i.name))continue;
    1983    //if(traverseSubDirectory!=folder_info.f.noNewObj)alert(i.name+': '+i.size+' / '+total_size_of_files);
    1984    total_size_of_files+=i.size;
    1985   }
    1986
    1987   total_size_of_this_folder+=total_size_of_files;
    1988  }
    1989
    1990  //alert(dir.path+'\nfile filter: '+file_filter+'\n'+filesCount+','+subDirectorysCount+','+total_size_of_files+','+total_size_of_this_folder+','+total_filesCount+','+total_subDirectorysCount);
    1991  if(traverseSubDirectory==folder_info.f.noNewObj)
    1992   return [filesCount,subDirectorysCount,total_size_of_files,total_size_of_this_folder,total_filesCount,total_subDirectorysCount];
    1993
    1994  this.files=this[folder_info.f.files]=filesCount;
    1995  this.dirs=this[folder_info.f.dirs]=subDirectorysCount;
    1996  this.fsize=this[folder_info.f.fsize]=total_size_of_files;
    1997  this.size=this[folder_info.f.size]=total_size_of_this_folder;
    1998  this.Tfiles=this[folder_info.f.Tfiles]=total_filesCount;
    1999  this.Tdirs=this[folder_info.f.Tdirs]=total_subDirectorysCount;
    2000  return this;
    2001 };
    2002 CeL.IO.Windows.file
    2003 .
    2004 /**
    2005  * <a href="#.folder_info">folder_info</a> 的 flag enumeration
    2006  * @memberOf	CeL.IO.Windows.file
    2007  * @constant
    2008  */
    2009 folder_info.f = {
    2010 		noNewObj : -1,
    2011 		files : 0,
    2012 		dirs : 1,
    2013 		fsize : 2,
    2014 		size : 3,
    2015 		Tsize : 3,
    2016 		Tfiles : 4,
    2017 		Tdirs : 5
    2018 };
    2019
    2020
    2021 /*	list files of folder	改編自 folder_info()
    2022 	var files=new listFile(path or folder object,extFilter,flag);
    2023
    2024 */
    2025 //listFile[generateCode.dLK]='initWScriptObj';
    2026 //	需同時修改if(flag==listFile.f.noNewObj)段落之return!
    2027
    2028 //setObjValue('listFile.f','ignoreCase=1',1);
    2029 listFile.f={
    2030 	ignoreCase:1
    2031 };
    2032
    2033 function listFile(folder_path, file_filter, flag) {
    2034 	var files = [];
    2035 	if (typeof flag == 'undefined')
    2036 		flag = 0;
    2037
    2038 	if (typeof folder_path == 'object')
    2039 		dir = folder_path;
    2040 	else if (folder_path) {
    2041 		if (!folder_path.slice(-1) != path_separator)
    2042 			folder_path += path_separator;
    2043 		try {
    2044 			dir = fso.GetFolder(folder_path);
    2045 		} catch (e) {
    2046 			dir = 0;
    2047 		}
    2048 	}
    2049
    2050 	if (dir) {
    2051 		var i, f = new Enumerator(dir.files);
    2052 		for (; !f.atEnd(); f.moveNext()) {
    2053 			i = f.item();
    2054 			if (file_filter && !file_filter.test(i.name))
    2055 				continue;
    2056 			files.push(i.name);
    2057 		}
    2058 	}
    2059
    2060 	return files;
    2061 };
    2062
    2063
    2064
    2065
    2066
    2067
    2068 /*
    2069 in UNIX:
    2070 iconv -l
    2071 iconv -c -f UTF-16 -t BIG5-HKSCS function.js
    2072
    2073 */
    2074 CeL.IO.Windows.file
    2075 .
    2076 /**
    2077  * 將編碼為fromCode之檔案fileName中所有不合編碼toCode之char以encodeFunction轉換
    2078  * @param fileName
    2079  * @param toCode
    2080  * @param fromCode
    2081  * @param encodeFunction
    2082  * @return
    2083  * @memberOf	CeL.IO.Windows.file
    2084  */
    2085 iconv_file = function(fileName, toCode, fromCode, encodeFunction) {
    2086 	return iconv(_.read_file(fileName, fromCode), toCode,
    2087 			encodeFunction);
    2088 };
    2089
    2090 CeL.IO.Windows.file
    2091 .
    2092 /*	將string text中所有不合編碼toCode之char以encodeFunction轉換
    2093 convert string encoding<br/>
    2094
    2095 CeL.iconv('測試每個字元 abc あaいiうuえeおo','Big5')
    2096
    2097 TODO:
    2098 一次寫入多 bytes
    2099 */
    2100 //var iconvError=[];
    2101 iconv=function(text, toCode, encodeFunction) {
    2102 	if (!text)
    2103 		return '';
    2104
    2105 	// alert('iconv: ['+toCode+']\n'+text.slice(0,200));
    2106 	if (/utf-?(8|16([bl]e)?)/i.test(toCode))
    2107 		//	skip Unicode
    2108 		return HTMLToUnicode(text, 1);
    2109
    2110 	if (_.open_file(0, toCode || simpleFileDformat) !== 0){
    2111 		//	error occurred
    2112 		iconvError = simpleFileErr;
    2113 		CeL.log(iconvError.message);
    2114 		return text;
    2115 	}
    2116
    2117 	// AdoStream.Type=AdoEnums.adTypeText;
    2118 	if (!encodeFunction)
    2119 		encodeFunction =
    2120 			// typeof toHTML ==='function' ? totoHTML:
    2121 			function(t) {
    2122 				return '\\u' + t.charCodeAt(0);
    2123 			};
    2124 	// iconvError=[];
    2125
    2126 	var charToSet, i = 0, t = '';
    2127 	//	測試每個字元
    2128 	for (; i < text.length; i++)
    2129 		try {
    2130 			charToSet = text.charAt(i);
    2131 			if (charToSet.charCodeAt(0) < 256) {
    2132 				//	對於 code 過小的，直接匯入以增加速度。
    2133 				t += charToSet;
    2134 				continue;
    2135 			}
    2136 			AdoStream.Position = 0;
    2137 			AdoStream.WriteText(charToSet);
    2138 			AdoStream.Position = 0;
    2139 			t += charToSet == AdoStream.ReadText(AdoEnums.adReadAll) ? charToSet
    2140 					: encodeFunction(charToSet);
    2141 		} catch (e) {
    2142 			//iconvError.push(e.description);
    2143 			t += encodeFunction(charToSet);
    2144 		}
    2145
    2146 	try {
    2147 		AdoStream.Close();
    2148 	} catch (e) {
    2149 	}
    2150 	return t;
    2151 };
    2152
    2153
    2154
    2155 //---------------------------------------------------
    2156
    2157
    2158 /*
    2159 var driverProperty,folderProperty,fileProperty;
    2160 setObjValue('driverProperty','AvailableSpace,DriveLetter,DriveType,FileSystem,FreeSpace,IsReady,Path,RootFolder,SerialNumber,ShareName,TotalSize,VolumeName',1,setObjValueFlag.array);
    2161 setObjValue('folderProperty','Attributes,DateCreated,DateLastAccessed,DateLastModified,Drive,Name,ParentFolder,Path,ShortName,ShortPath,Size,Type,Files,IsRootFolder,SubFolders',1,setObjValueFlag.array);//Files起為Folder property
    2162 fileProperty=folderProperty.slice(0,12);//folderProperty.sort();
    2163 */
    2164
    2165
    2166 //var kkk='';_.traverse_file_system(function(fileItem,itemType){kkk+=(itemType==_.traverse_file_system.f.driver?fileItem.DriveLetter+':('+fileItem.VolumeName+')':fileItem.Name+(itemType==_.traverse_file_system.f.folder?path_separator:''))+'\n';},'I:\\Documents and Settings\\kanashimi\\My Documents\\kanashimi\\www\\cgi-bin\\program');_.write_file('tmp.txt',kkk,'unicode');
    2167 /*
    2168
    2169 _.traverse_file_system(FS_function_array)	省略path會當作所有Drives
    2170 _.traverse_file_system(FS_function_array,'c:')	c:→c:\→sub dir of c:\
    2171 _.traverse_file_system(FS_function_array,'c:\\')	c:\→sub dir of c:\
    2172 _.traverse_file_system(FS_function_array,'c:\\cc')	c:\cc,cc為dir→sub dir of c:\cc\
    2173 _.traverse_file_system(FS_function_array,'c:\\cc\\')	c:\cc\→sub dir of c:\cc\
    2174 _.traverse_file_system(FS_function_array,['c:\\cc\\','d:\\dd'])	c:\cc\→sub dir of c:\cc\→d:\dd→sub dir of d:\dd
    2175 _.traverse_file_system([,folderFunction],'.');
    2176
    2177
    2178 _.traverse_file_system([,folderFunction],basePath);
    2179 function folderFunction(folderItem){
    2180  t=folderItem.Path.slice(same_length(basePath,folderItem.Path));
    2181  //if(t==folderItem.Name)	//	僅單層subdir次目錄
    2182  //if(t.indexOf(path_separator)==t.lastIndexOf(path_separator))	//	僅單層及次層subdir次目錄
    2183  if(t.replace(new RegExp('[^'+path_separator_RegExp+']','g'),'').length<3)	//	僅3層subdir以下
    2184   ;
    2185 }
    2186
    2187
    2188 //	itemType=0:file/1:folder/2:driver
    2189 function fsoFunction(fsi,itemType){if(!itemType){}}
    2190 function fileFunction(fileItem){}
    2191 function folderFunction(folderItem){}
    2192 function driverFunction(driverItem){}
    2193
    2194 filter:
    2195 	file_filter	僅單一 filter 時預設當作 file_filter, should has NO global flag.
    2196 	[file_filter,folder_filter]
    2197 file_filter	篩選檔案, should has NO global flag.
    2198 folder_filter	篩選資料夾, should has NO global flag.
    2199
    2200
    2201 tip:
    2202 使用相對路徑，如'..'開頭時需用getFP()調整過。
    2203 用folder.Size==0可判別是否為empty folder
    2204
    2205 TODO:
    2206 限定traverse深度幾層,sort=8,preOrder=0,widthFirst=0,postOrder=16,depthFirst=16
    2207 */
    2208 //_.traverse_file_system.stop=false;
    2209
    2210 //_.traverse_file_system[generateCode.dLK]='initWScriptObj';
    2211 CeL.IO.Windows.file
    2212 .
    2213 /**
    2214  * 巡覽 file system 的公用函數
    2215  * @param FS_function_array	file system handle function array
    2216  * @param path	target path
    2217  * @param filter	filter
    2218  * @param flag	see <a href="#.traverse_file_system.f">flag</a>
    2219  * @return
    2220  * @memberOf	CeL.IO.Windows.file
    2221  * @see	<a href="http://msdn.microsoft.com/library/en-us/script56/html/0fa93e5b-b657-408d-9dd3-a43846037a0e.asp">FileSystemObject</a>
    2222  */
    2223 traverse_file_system = function traverse_file_system(FS_function_array, path, filter, flag) {
    2224 	var _s = _.traverse_file_system, _f = _s.f;
    2225
    2226 	// initial
    2227 	// 預設 flag
    2228 	// if(isNaN(flag))flag=_f.traverse;
    2229
    2230 	//library_namespace.log('traverse_file_system:\n[' + path + ']');
    2231 	if (FS_function_array === _f.get_object)
    2232 		// or FS_function_array=[,,]:	可以使用 Array 常值中的空白元素來建立零星稀疏的陣列。
    2233 		FS_function_array = new Array(_f.func_length),
    2234 		flag = _f.get_object;
    2235 	else {
    2236 		/*
    2237 		if (FS_function_array instanceof Array && FS_function_array.length == 1)
    2238 			FS_function_array = FS_function_array[0];
    2239 		*/
    2240 		if (typeof FS_function_array === 'function') {
    2241 			var i = FS_function_array;
    2242 			FS_function_array = [ i, i, i ];
    2243 		}
    2244 	}
    2245 	//library_namespace.log('traverse_file_system: fso:\n[' + fso + ']');
    2246 	if (typeof fso !== 'object' || !(FS_function_array instanceof Array)
    2247 			|| !FS_function_array.length)
    2248 		return;
    2249 	//library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']');
    2250 	if (!filter)
    2251 		filter = [];
    2252 	else if (filter instanceof RegExp)
    2253 		// filter=[filter,filter]; 通常我們輸入的只會指定 file filter
    2254 		filter = [ filter, ];
    2255 	else if (typeof filter !== 'object')
    2256 		filter = [ filter, ];
    2257
    2258 	//library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']');
    2259 	var item, iType, fc, i, traverse = !(flag & _f.no_traverse), objBuf = [], typeBuf = [], folder_filter = filter[1], testFilter = function(
    2260 			f) {
    2261 		try {
    2262 			// f instanceof RegExp
    2263 			f.test('');
    2264 		}
    2265 		catch (e) {
    2266 			// throw new Error(e.number,'traverse_file_system: 錯誤的 filter:\n'+f+'\n'+e.description);
    2267 			e.description = 'traverse_file_system: 錯誤的 filter:\n' + f + '\n'
    2268 			+ e.description;
    2269 			throw e;
    2270 		}
    2271 	};
    2272 	if (filter = filter[0])
    2273 		if (typeof filter === 'string')
    2274 			filter = new RegExp(filter);
    2275 		else
    2276 			testFilter(filter);
    2277 	if (folder_filter)
    2278 		if (typeof folder_filter === 'string')
    2279 			folder_filter = new RegExp(folder_filter);
    2280 		else
    2281 			testFilter(folder_filter);
    2282 	// if(flag!=_f.get_object)alert(filter+'\n'+folder_filter);
    2283 	// 至此 filter 代表 file_filter, vs. folder_filter
    2284
    2285
    2286 	// 轉換輸入之各項成fso object
    2287 	if (!path) { // 取得各個driver code
    2288 		if (flag === _f.get_object)
    2289 			return;
    2290 		for ( var drivers = new Enumerator(fso.Drives); !drivers.atEnd(); drivers
    2291 		.moveNext())
    2292 			objBuf.push(drivers.item()), typeBuf
    2293 			.push(_f.driver);
    2294 		objBuf.reverse(), typeBuf.reverse();
    2295 	} else if (typeof path === 'object')
    2296 		if (path.length) {
    2297 			for (i = 0; i < path.length; i++)
    2298 				if (item = _s(_f.get_object,
    2299 						'' + path[i], filter, flag))
    2300 					objBuf.push(item[0]), typeBuf.push(item[1]);
    2301 		} else {
    2302 			item = typeof path.IsReady !== 'undefined' ? _f.driver
    2303 					: typeof path.IsRootFolder !== 'undefined' ? _f.folder
    2304 							: typeof path.Path !== 'undefined' ? _f.file
    2305 									: _f.NULL;
    2306 			if (_f.NULL != -1)
    2307 				objBuf.push(path), typeBuf.push(item);
    2308 		}
    2309 	else {
    2310 		i = true; // fault
    2311 		if (i)
    2312 			try {
    2313 				objBuf.push(fso.GetFolder(path)), typeBuf
    2314 				.push(_f.folder), i = false;
    2315 			} catch (e) {
    2316 			}// fso.FolderExists()
    2317 			if (i)
    2318 				try {
    2319 					objBuf.push(fso.GetFile(path)), typeBuf
    2320 					.push(_f.file), i = false;
    2321 				} catch (e) {
    2322 				}// fso.FileExists()
    2323 				if (i && path == fso.GetDriveName(path))
    2324 					try {
    2325 						objBuf.push(fso.GetDrive(path)), typeBuf
    2326 						.push(_f.driver), i = false;
    2327 					} catch (e) {
    2328 					}
    2329 	}
    2330 	if (flag == _f.get_object)
    2331 		return objBuf[0] ? [ objBuf[0], typeBuf[0] ] : 0;
    2332
    2333 		// FS_function_array.length=_f.func_length;
    2334 		for (i = 0; i < _f.func_length; i++)
    2335 			// 可以安排僅對folder或是file作用之function
    2336 			if (typeof FS_function_array[i] !== 'function')
    2337 				FS_function_array[i] = function() {};
    2338 			//alert(objBuf.length+','+typeBuf.length+'\n'+typeBuf);
    2339 			// main loop
    2340 			while (!_s.stop && objBuf.length)
    2341 				if (item = objBuf.pop()) // fsoFunction執行途中可能將此項目刪除
    2342 					switch (iType = typeBuf.pop()) {
    2343 					case _f.folder:
    2344 						if (!folder_filter || folder_filter.test(item.Name))
    2345 							FS_function_array[iType](item, iType);
    2346 						// if(traverse||traverse!==0){
    2347 						// if(!traverse)traverse=0; // 加上次一層: 會連這次一層之檔案都加上去。
    2348 						if (traverse)
    2349 							for (fc = new Enumerator(item.SubFolders); !fc.atEnd(); fc
    2350 							.moveNext())
    2351 								if (i = fc.item(), !folder_filter
    2352 										|| folder_filter.test(i.Name))
    2353 									objBuf.push(i), typeBuf
    2354 									.push(_f.folder);
    2355 						// }
    2356 						// try 以防item已經被刪除
    2357 						try {
    2358 							fc = new Enumerator(item.Files);
    2359 						} catch (e) {
    2360 							fc = 0;
    2361 						}
    2362 						if (fc) {
    2363 							// for(;!fc.atEnd();fc.moveNext())if(i=fc.item(),!filter||filter.test(i.Name))FS_function_array[_f.file](i,_f.file);
    2364 							// 因為檔案可能因改名等改變順序，因此用.moveNext()的方法可能有些重複，有些漏掉未處理。
    2365 							for (item = []; !fc.atEnd(); fc.moveNext())
    2366 								item.push(fc.item());
    2367 							for (i in item)
    2368 								if (i = item[i], !filter || filter.test(i.Name))
    2369 									FS_function_array[_f.file](i,
    2370 											_f.file);
    2371 						}
    2372 						break;
    2373 					case _f.file:
    2374 						if (!filter || filter.test(item.Name))
    2375 							FS_function_array[iType](item, iType);
    2376 						break;
    2377 					case _f.driver:
    2378 						if (!item.IsReady)
    2379 							break;
    2380 						FS_function_array[iType](item, iType);
    2381 						if (traverse)
    2382 							objBuf.push(item.RootFolder), typeBuf
    2383 							.push(_f.folder);
    2384 						// break;
    2385 						//default:break;
    2386 					}
    2387
    2388 };
    2389
    2390
    2391 //setObjValue('traverse_file_system.f','get_object=-2,NULL=-1,file,folder,driver,func_length,traverse=0,no_traverse=4',1);//,sort=8,preOrder=0,widthFirst=0,postOrder=16,depthFirst=16
    2392 CeL.IO.Windows.file
    2393 .
    2394 /**
    2395  * <a href="#.traverse_file_system">traverse_file_system</a> 的 flag enumeration
    2396  * @memberOf	CeL.IO.Windows.file
    2397  * @constant
    2398  */
    2399 traverse_file_system.f =
    2400 traverse_file_system.f = {
    2401 		/**
    2402 		 * return object
    2403 		 * @memberOf	CeL.IO.Windows.file
    2404 		 */
    2405 		get_object : -2,
    2406 		/**
    2407 		 * null flag
    2408 		 * @private
    2409 		 * @memberOf	CeL.IO.Windows.file
    2410 		 */
    2411 		NULL : -1,
    2412 		/**
    2413 		 * 用於指示 file
    2414 		 * @private
    2415 		 * @memberOf	CeL.IO.Windows.file
    2416 		 */
    2417 		file : 0,
    2418 		/**
    2419 		 * 用於指示 folder
    2420 		 * @private
    2421 		 * @memberOf	CeL.IO.Windows.file
    2422 		 */
    2423 		folder : 1,
    2424 		/**
    2425 		 * 用於指示 driver
    2426 		 * @private
    2427 		 * @memberOf	CeL.IO.Windows.file
    2428 		 */
    2429 		driver : 2,
    2430 		/**
    2431 		 * handle function 應有的長度
    2432 		 * @private
    2433 		 * @memberOf	CeL.IO.Windows.file
    2434 		 */
    2435 		func_length : 3,
    2436 		/**
    2437 		 * 深入下層子目錄及檔案
    2438 		 * @memberOf	CeL.IO.Windows.file
    2439 		 */
    2440 		traverse : 0,
    2441 		/**
    2442 		 * 不深入下層子目錄及檔案
    2443 		 * @memberOf	CeL.IO.Windows.file
    2444 		 */
    2445 		no_traverse : 4
    2446 };
    2447
    2448
    2449 return (
    2450 	CeL.IO.Windows.file
    2451 );
    2452 };
    2453
    2454 //===================================================
    2455
    2456 CeL.setup_module(module_name, code_for_including);
    2457
    2458 };
    2459