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 CeL.setup_module('application.OS.Windows.file', 16 function(library_namespace, load_arguments) { 17 18 // nothing required 19 20 21 /** 22 * null module constructor 23 * @class Windows 下,檔案操作相關之 function。 24 */ 25 CeL.application.OS.Windows.file 26 = function() { 27 // null module constructor 28 }; 29 30 /** 31 * for JSDT: 有 prototype 才會將之當作 Class 32 */ 33 CeL.application.OS.Windows.file 34 .prototype = { 35 }; 36 37 38 39 /* 40 JScript only ------------------------------------------------------- 41 */ 42 43 CeL.application.OS.Windows.file 44 . 45 /** 46 * FileSystemObject Object I/O mode enumeration 47 * @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> 48 * @memberOf CeL.application.OS.Windows.file 49 */ 50 iomode = { 51 // * @_description <a href="#.iomode">iomode</a>: Open a file for reading only. You can't write to this file. 52 /** 53 * Open a file for reading only. You can't write to this file. 54 * @memberOf CeL.application.OS.Windows.file 55 */ 56 ForReading : 1, 57 /** 58 * Open a file for writing. 59 * @memberOf CeL.application.OS.Windows.file 60 */ 61 ForWriting : 2, 62 /** 63 * Open a file and write to the end of the file. 64 * @memberOf CeL.application.OS.Windows.file 65 */ 66 ForAppending : 8 67 }; 68 69 CeL.application.OS.Windows.file 70 . 71 /** 72 * FileSystemObject Object file open format enumeration 73 * @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> 74 * @memberOf CeL.application.OS.Windows.file 75 */ 76 open_format = { 77 /** 78 * Opens the file using the system default. 79 * @memberOf CeL.application.OS.Windows.file 80 */ 81 TristateUseDefault : -2, 82 /** 83 * Opens the file as Unicode. 84 * @memberOf CeL.application.OS.Windows.file 85 */ 86 TristateTrue : -1, 87 /** 88 * Opens the file as ASCII. 89 * @memberOf CeL.application.OS.Windows.file 90 */ 91 TristateFalse : 0 92 }; 93 94 95 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, 96 /** 97 * FileSystemObject 98 * @inner 99 * @ignore 100 * @see 101 * <a href="http://msdn.microsoft.com/en-us/library/z9ty6h50%28VS.85%29.aspx" accessdate="2010/1/9 8:10">FileSystemObject Object</a> 102 */ 103 fso = WScript.CreateObject("Scripting.FileSystemObject"), 104 // XMLHttp, 105 WinShell // initWScriptObj 106 , args, ScriptHost; 107 108 109 /* ↑JScript only ------------------------------------------------------- 110 */ 111 112 113 114 115 /* 116 117 return {Object} report 118 .list files matched 119 .succeed success items 120 .failed failed items 121 .log log text 122 .undo undo data 123 124 usage example: 125 move_file() get file list array of current dir. 126 move_file(0,0,'dir') get file list array of dir. 127 move_file('*.*','*.jpg','dir') Error! Please use RegExp('.*\..*') or turnWildcardToRegExp('*.*') 128 move_file(/file(\d+).jpg/,0,'dir') get file list array of dir/file(\d+).jpg 129 move_file(f1,move_file.f.remove) delete f1 130 move_file('f1','f2') [f1]->[f2] 131 move_file('f1','f2','.',move_file.f.copy|move_file.f.reverse) copy [./f2] to [./f1] 132 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 133 134 prog example: 135 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;} 136 var vol=11,doMove=move_file(new RegExp('(\\d+)\\('+vol+'\\)\\.pdf'),'$1.pdf'); 137 write_file('move.log','-'.x(60)+new_line+doMove.log,open_format.TristateTrue,ForAppending); 138 write_file('move.undo.'+vol+'.txt',doMove.undo,open_format.TristateTrue),write_file('move.undo.'+vol+'.bat',doMove.undo);//bat不能用open_format.TristateTrue 139 alert('Done '+doMove.succeed+'/'+doMove.list.length); 140 141 for Win98, turn lower case: 142 move_file(/^[A-Z\d.]+$/,function($0){return '_mv_tmp_'+$0.toLowerCase();},'.',move_file.f.include_folder|move_file.f.include_subfolder); 143 alert(move_file(/^_mv_tmp_/,'','.',move_file.f.include_folder|move_file.f.include_subfolder).log); 144 145 146 for(var i=0,j,n,m;i<40;i++) 147 if(!fso.FileExists(n='0000'+(i>9?'':'0')+i+'.pdf'))for(j=0;j<25;j++) 148 if(fso.FileExists(m='0000'+(i>9?'':'0')+i+'('+j+').pdf')){try{fso.MoveFile(m,n);}catch(e){}break;} 149 150 TODO: 151 move newer 把新檔移到目的地,舊檔移到 bak。 152 153 */ 154 CeL.application.OS.Windows.file 155 . 156 /** 157 * move/rename files, ** use RegExp, but no global flag **<br/> 158 * 可用 move_file_filter() 來排除不要的<br/> 159 * 本函數可能暫時改變目前工作目錄! 160 * @param {String} from from file 161 * @param {String} to to file 162 * @param {String} base_path base path 163 * @param flag 164 * @param {Function} filter 可用 filter() 來排除不要的 165 * @return {Object} report 166 * @since 2004/4/12 17:25 167 * @requires path_separator,fso,WshShell,new_line,Enumerator 168 * @memberOf CeL.application.OS.Windows.file 169 */ 170 move_file = function move_file(from, to, base_path, flag, filter) { 171 var _s = move_file.f ? move_file : _.move_file, _f = _s.f, 172 // '.?': 一定會match 173 default_from = new RegExp('.?'), t, CurrentDirectory, report = {}; 174 //library_namespace.debug(typeof from + ',' + from.constructor); 175 if (flag & _f.reverse) 176 //flag-=_f.reverse, 177 t = from, from = to, to = t; 178 if (!from) 179 from = default_from; 180 else if (typeof from !== 'string' 181 && (typeof from !== 'object' || !(from instanceof RegExp) 182 && !(from = '' + from))) 183 from = default_from; 184 report.list = [], report.succeed = report.failed = 0, 185 report.undo = report.log = ''; 186 187 if (!base_path) 188 base_path = '.' + path_separator; 189 else if (typeof get_folder === 'function') 190 base_path = get_folder(base_path); 191 192 if ((base_path = '' + base_path).slice( 193 // -1, or try: base_path.length-path_separator.length 194 -1) != path_separator) 195 base_path += path_separator; 196 197 if (typeof fso === 'undefined') 198 fso = new ActiveXObject("Scripting.FileSystemObject"); 199 else if (typeof fso !== 'object') 200 throw new Error(1, 'FSO was already seted!'); 201 try { 202 dir = fso.GetFolder(base_path); 203 } catch (e) { 204 throw new Error(e.number, 205 'move_file(): 基準路徑不存在\n' + e.description); 206 } 207 208 // TODO: 對from不存在與為folder之處裡: fuzzy 209 210 if (flag & _f.include_subfolder) { 211 CurrentDirectory = WshShell.CurrentDirectory; 212 for ( var i = new Enumerator(dir.SubFolders); !i.atEnd(); i 213 .moveNext()) 214 _s(from, to, i.item(), flag); 215 if (base_path) 216 // 改變目前工作目錄 217 WshShell.CurrentDirectory = base_path; 218 } 219 // if(flag&_f.include_folder){} 220 var i, f = new Enumerator(dir.Files), use_exact = typeof from === 'string', overwrite = flag 221 & _f.overwrite, not_test = !(flag & _f.Test), func = flag 222 & _f.copy ? 'copy' : to === _f.remove || flag & _f.remove 223 && !to ? 'delete' : from !== default_from || to ? 'move' 224 : 'list'; 225 // if(func=='delete')to=_f.remove; // 反正不是用這個判別的 226 //library_namespace.debug('use_exact: ' + use_exact + '\nbase_path: ' + base_path + '\nfrom: ' + from); 227 // BUG: 這樣順序會亂掉,使得 traverse (遍歷)不完全 228 for (; !f.atEnd(); f.moveNext()) 229 if (i = f.item(), use_exact && i.Name === from || !use_exact 230 && from.test(i.Name)) { 231 report.list.push(i.Name); 232 233 if (typeof filter == 'function' && !filter(i.Name)) 234 continue; 235 t = func === 'copy' || func === 'move' ? i.Name.replace(from, 236 typeof to === 'object' ? to.source : to) : ''; 237 238 if (t) 239 try { 240 report.log += func + ' [' + i.Name + ']' 241 + (t ? ' to [' + t + '] ' : ''); 242 var u = ''; 243 t = (base_path === default_from ? base_path : '') 244 + t; 245 if (func === 'delete') { 246 if (not_test) 247 i.Delete(overwrite); 248 } else if (!fso.FileExists(t) || overwrite) { 249 if (not_test) { 250 if (overwrite && fso.FileExists(t)) 251 fso.DeleteFile(t, true); 252 if (func === 'copy') 253 // Copy() 用的是 FileSystemObject.CopyFile or FileSystemObject.CopyFolder, 亦可用萬用字元(wildcard characters) 254 i.Copy(t, overwrite); 255 else 256 i.Move(t); 257 } 258 u = 'move ' + t + ' ' + i.Name + new_line; 259 } else { 260 report.log += ': target existing, '; 261 throw 1; 262 } 263 report.log += 'succeed.' + new_line, 264 report.undo += u, report.succeed++; 265 } catch (e) { 266 report.log += 'failed.' + new_line, report.failed++; 267 } 268 //library_namespace.debug(i.Name + ',' + t); 269 } 270 271 if (flag & _f.include_subfolder && CurrentDirectory) 272 WshShell.CurrentDirectory = CurrentDirectory; 273 report.log += new_line + (not_test ? '' : '(test)') + func + ' [' 274 + from + '] to [' + to + ']' + new_line 275 + (typeof gDate === 'function' ? gDate() + ' ' : '') 276 + 'done ' + report.succeed + '/' + report.list.length 277 + new_line; 278 return report; 279 }; 280 281 //var move_file.f; 282 //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'); 283 CeL.application.OS.Windows.file 284 . 285 /** 286 * <a href="#.move_file">move_file</a> 的 flag enumeration 287 * @constant 288 * @memberOf CeL.application.OS.Windows.file 289 */ 290 move_file.f = { 291 /** 292 * null flag 293 * @memberOf CeL.application.OS.Windows.file 294 */ 295 none : 0, 296 /** 297 * overwrite target 298 * @memberOf CeL.application.OS.Windows.file 299 */ 300 overwrite : 1, 301 /** 302 * If source don't exist but target exist, than reverse. 303 * @deprecated TODO 304 * @memberOf CeL.application.OS.Windows.file 305 */ 306 fuzzy : 2, 307 /** 308 * reverse source and target 309 * @memberOf CeL.application.OS.Windows.file 310 */ 311 reverse : 4, 312 /** 313 * include folder 314 * @memberOf CeL.application.OS.Windows.file 315 */ 316 include_folder : 8, 317 /** 318 * include sub-folder 319 * @memberOf CeL.application.OS.Windows.file 320 */ 321 include_subfolder : 16, 322 /** 323 * Just do a test 324 * @memberOf CeL.application.OS.Windows.file 325 */ 326 Test : 32, 327 /** 328 * copy, instead of move the file 329 * @memberOf CeL.application.OS.Windows.file 330 */ 331 copy : 64, 332 /** 333 * 當 target 指定此 flag,或包含此 flag 而未指定 target 時,remove the source。 334 * @memberOf CeL.application.OS.Windows.file 335 */ 336 remove : 128 337 }; 338 339 CeL.application.OS.Windows.file 340 . 341 /** 342 * move file 343 * @requires fso,get_folder,get_file_name,initWScriptObj 344 * @memberOf CeL.application.OS.Windows.file 345 */ 346 move_1_file = function(from, to, dir, only_filename, reverse) { 347 if (!from || !to || from === to) 348 return new Error(1, 'filename error.'); 349 350 var e; 351 dir = get_folder(dir); 352 353 if (reverse) 354 e = from, from = to, to = e; 355 e = function(_i) { 356 return fso.FileExists(_i) ? _i : dir ? dir 357 + (only_filename ? get_file_name(_i) : _i) : null; 358 }; 359 360 try { 361 //library_namespace.debug('move_1_file:\n' + dir + '\n\n' + e(from) + '\n→\n' + e(to)); 362 fso.MoveFile(e(from), e(to)); 363 return; 364 } catch (e) { 365 e.message = 'move_1_file:\n' + from + '\n→\n' 366 + to// +'\n\n'+e.message 367 ; 368 return e; 369 } 370 }; 371 372 373 /* 374 function mv(from,to,dir,only_filename,reverse){ 375 var e,_f,_t; 376 dir=get_folder(dir); 377 378 if(reverse)e=from,from=to,to=e; 379 _f=from; 380 _t=to; 381 to=0; 382 e=function(_i){ 383 return fso.FileExists(_i)?_i:dir&&fso.FileExists(_i=dir+(only_filename?get_file_name(_i):_i))?_i:0; 384 }; 385 386 try{ 387 if(!(_f=e(_f)))to=1;else if(!(_t=e(_t)))to=2; 388 else{ 389 alert('mv():\n'+dir+'\n\n'+_f+'\n→\n'+_t); 390 fso.MoveFile(_f,_t); 391 return; 392 } 393 }catch(e){return e;} 394 return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t); 395 } 396 397 398 function mv(from,to,dir,only_filename,reverse){ 399 var e,_f,_t; 400 dir=get_folder(dir); 401 402 if(reverse)e=from,from=to,to=e; 403 _f=from,_t=to,to=e=0; 404 405 try{ 406 if(!fso.FileExists(_f)&&(!dir||!fso.FileExists(_f=dir+(only_filename?get_file_name(_f):_f))))to=1; 407 else if(fso.FileExists(_t)&&(!dir||fso.FileExists(_t=dir+(only_filename?get_file_name(_t):_t))))to=2; 408 else{ 409 alert('mv():\n'+dir+'\n'+_f+'\n→\n'+_t); 410 //fso.MoveFile(_f,_t); 411 return; 412 } 413 }catch(e){} 414 return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t); 415 } 416 417 */ 418 419 420 /* 421 422 下面一行調到檔案頭 423 var get_file_details_items,get_file_details_get_object=-62.262; 424 */ 425 CeL.application.OS.Windows.file 426 . 427 /** 428 * get file details (readonly) 429 * @example 430 * get_file_details('path'); 431 * get_file_details('file/folder name',parentDir); 432 * get_file_details('path',get_file_details_get_object); 433 * @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> 434 * @memberOf CeL.application.OS.Windows.file 435 */ 436 get_file_details = function(fileObj, parentDirObj) { 437 var i, n, r; 438 // WinShell=new ActiveXObject("Shell.Application"); 439 if (typeof WinShell == 'undefined' || !fileObj) 440 return; 441 442 // deal with fileObj & parentDirObj 443 if (parentDirObj === get_file_details_get_object) 444 parentDirObj = 0, n = 1; 445 // else n=''; 446 if (!parentDirObj) { 447 // fileObj is path 448 if (typeof fileObj != 'string') 449 return; 450 if (i = fileObj.lastIndexOf('/') + 1) 451 parentDirObj = fileObj.slice(0, i - 1), fileObj = fileObj 452 .slice(i); 453 else 454 return; 455 } 456 if (typeof parentDirObj == 'string') 457 parentDirObj = WinShell.NameSpace(parentDirObj); 458 if (typeof fileObj == 'string' && fileObj) 459 fileObj = parentDirObj.ParseName(fileObj); 460 if (n) 461 // just get [(object)parentDirObj,(object)fileObj] 462 return [ parentDirObj, fileObj ]; 463 464 // get item name 465 if (typeof get_file_details_items != 'object') { 466 get_file_details_items = []; 467 for (i = 0, j; i < 99; i++) 468 // scan cols 469 if (n = WinShell.NameSpace(0).GetDetailsOf(null, i)) 470 get_file_details_items[i] = n; 471 } 472 473 // main process 474 //for(i=0,r=[];i<get_file_details_items.length;i++) 475 r = []; 476 for (i in get_file_details_items) { 477 //if(get_file_details_items[i]) 478 r[get_file_details_items[i]] = r[i] = parentDirObj 479 .GetDetailsOf(fileObj, i); 480 } 481 482 return r; 483 }; 484 485 486 CeL.application.OS.Windows.file 487 . 488 /** 489 * FileSystemObject Object Attributes Property 490 * @see 491 * <a href="http://msdn.microsoft.com/en-us/library/5tx15443%28VS.85%29.aspx" accessdate="2010/1/9 8:11">Attributes Property</a> 492 * @memberOf CeL.application.OS.Windows.file 493 * @since 2010/1/9 08:33:36 494 */ 495 fso_attributes = { 496 /** 497 * Default. No attributes are set. 498 * @memberOf CeL.application.OS.Windows.file 499 */ 500 none : 0, 501 /** 502 * Normal file. No attributes are set. 503 * @memberOf CeL.application.OS.Windows.file 504 */ 505 Normal : 0, 506 /** 507 * Read-only file. Attribute is read/write. 508 * @memberOf CeL.application.OS.Windows.file 509 */ 510 ReadOnly : 1, 511 /** 512 * Hidden file. Attribute is read/write. 513 * @memberOf CeL.application.OS.Windows.file 514 */ 515 Hidden : 2, 516 /** 517 * System file. Attribute is read/write. 518 * @memberOf CeL.application.OS.Windows.file 519 */ 520 System : 4, 521 /** 522 * Disk drive volume label. Attribute is read-only. 523 * @memberOf CeL.application.OS.Windows.file 524 */ 525 Volume : 8, 526 /** 527 * Folder or directory. Attribute is read-only. 528 * @memberOf CeL.application.OS.Windows.file 529 */ 530 Directory : 16, 531 /** 532 * File has changed since last backup. Attribute is read/write. 533 * @memberOf CeL.application.OS.Windows.file 534 */ 535 Archive : 32, 536 /** 537 * Link or shortcut. Attribute is read-only. 538 * @memberOf CeL.application.OS.Windows.file 539 */ 540 Alias : 1024, 541 /** 542 * Compressed file. Attribute is read-only. 543 * @memberOf CeL.application.OS.Windows.file 544 */ 545 Compressed : 2048 546 }; 547 548 // reverse map 549 _.fso_attributes_reverse=[]; 550 for (i in _.fso_attributes) 551 if (i !== 'none') 552 _.fso_attributes_reverse[_.fso_attributes[i]] = i; 553 554 /* 555 TODO 556 未來:change_attributes(path,'-ReadOnly&-Hidden&-System') 557 558 下面調到檔案頭 559 setObjValue('Attribute','Normal=0,none=0,ReadOnly=1,Hidden=2,System=4,Volume=8,Directory=16,Archive=32,Alias=64,Compressed=128','int'); 560 setObjValue('AttributeV','0=Normal,1=ReadOnly,2=Hidden,4=System,8=Volume,16=Directory,32=Archive,64=Alias,128=Compressed'); 561 */ 562 CeL.application.OS.Windows.file 563 . 564 /** 565 * 改變檔案之屬性。 566 * chmod @ UNIX 567 * @param F file path 568 * @param A attributes, 屬性 569 * @example 570 * change_attributes(path,'-ReadOnly'); 571 * @memberOf CeL.application.OS.Windows.file 572 */ 573 change_attributes = function(F, A) { 574 if (!F) 575 return -1; 576 577 if (typeof F === 'string') 578 try { 579 F = fso.GetFile(F); 580 } catch (e) { 581 return -2; 582 } 583 584 var a; 585 try { 586 a = F.Attributes; 587 } catch (e) { 588 return -3; 589 } 590 591 if (typeof A === 'undefined') 592 A = a; 593 else if (A === '' || A == 'Archive') 594 A = 32; 595 else if (A == 'Normal') 596 A = 0; 597 else if (isNaN(A)) 598 if (A.charAt(0) === 'x' || A.charAt(0) === '-') 599 if (A = -_.fso_attributes[A.substr(1)], A && a % (A << 2)) 600 A = a + A; 601 else 602 A = a; 603 else if (A = _.fso_attributes[A], A && a % (A << 2) == 0) 604 A = a + A; 605 else 606 A = a; 607 else if (_.fso_attributes_reverse[A]) 608 if (a % (A << 2) == 0) 609 A = a + A; 610 else 611 A = a; 612 else if (_.fso_attributes_reverse[-A]) 613 if (a % (A << 2)) 614 A = a + A; 615 else 616 A = a; 617 618 if (a != A) 619 try { 620 F.Attributes = A; 621 } catch (e) { 622 //popErr(e); 623 library_namespace.err(e); 624 // 70:防寫(沒有使用權限) 625 return 70 == (e.number & 0xFFFF) ? -8 : -9; 626 } 627 return F.Attributes; 628 }; 629 630 631 632 633 634 CeL.application.OS.Windows.file 635 . 636 /** 637 * 開檔處理<br/> 638 * 測試是否已開啟資料檔之測試與重新開啟資料檔 639 * @param FN file name 640 * @param NOTexist if NOT need exist 641 * @param io_mode IO mode 642 * @return 643 * @requires fso,WshShell,iomode 644 * @memberOf CeL.application.OS.Windows.file 645 */ 646 openDataTest = function(FN, NOTexist, io_mode) { 647 if (!FN) 648 return 3; 649 if (NOTexist && !fso.FileExists(FN)) 650 return 0; 651 if (!io_mode) 652 io_mode = _.iomode.ForAppending; 653 for (;;) 654 try { 655 var Fs = fso.OpenTextFile(FN, ForAppending); 656 Fs.Close(); 657 break; 658 } catch (e) { 659 // 對執行時檔案已經開啟之處理 660 //if(typeof e=='object'&&e.number&&(e.number&0xFFFF)==70) 661 if ((e.number & 0xFFFF) != 70) { 662 return pErr(e, 0, 663 '開啟資料檔 [<green>' + FN + '<\/>] 時發生錯誤!'), 664 6 == alert( 665 '開啟資料檔 [' + FN + ']時發生不明錯誤,\n 是否中止執行?', 666 0, ScriptName + ' 測試是否已開啟資料檔:發生不明錯誤!', 667 4 + 48) ? 1 : 0; 668 } 669 if (2 == WshShell.Popup( 670 '★資料檔:\n\ ' + FN + '\n 無法寫入!\n\n可能原因與解決方法:\n ①資料檔已被開啟。執行程式前請勿以其他程式開啟資料檔!\n ②資料檔被設成唯讀,請取消唯讀屬性。', 671 0, ScriptName + ':資料檔開啟發生錯誤!', 5 + 48)) 672 return 2; 673 } 674 return 0; 675 }; 676 677 CeL.application.OS.Windows.file 678 . 679 /** 680 * 681 * @param FN 682 * @param format 683 * @param io_mode 684 * @return 685 */ 686 open_template = function(FN, format, io_mode) { 687 /** 688 * file 689 * @inner 690 * @ignore 691 */ 692 var F, 693 /** 694 * file streams 695 * @inner 696 * @ignore 697 */ 698 Fs; 699 if (!io_mode) 700 io_mode = _.iomode.ForReading; 701 if (!format) 702 //format=autodetectEncode(FN); 703 format = _.open_format.TristateUseDefault;// TristateTrue 704 try { 705 F = fso.GetFile(FN); 706 //Fs=_.open_file(FN,format,io_mode); 707 Fs = F.OpenAsTextStream(io_mode, format); 708 } catch (e) { 709 // 指定的檔案不存在? 710 pErr(e); 711 // quit(); 712 } 713 return Fs; 714 }; 715 716 //var openOut.f; // default format 717 function openOut(FN,io_mode,format){ 718 var OUT,OUTs,_f=openOut.f; 719 if(!io_mode)io_mode=_.iomode.ForWriting; 720 if(!format)format=_f=='string'&&_f?_f:_.open_format.TristateUseDefault; 721 try{ 722 OUT=fso.GetFile(FN); 723 } 724 catch(e){try{ 725 //指定的檔案不存在 726 var tmp=fso.CreateTextFile(FN,true); 727 tmp.Close(); 728 OUT=fso.GetFile(FN); 729 }catch(e){pErr(e);}} 730 731 try{OUTs=OUT.OpenAsTextStream(io_mode,format);}catch(e){pErr(e);} 732 733 return OUTs; 734 }; 735 736 737 738 739 740 741 742 // 2007/5/31 21:5:16 743 compressF.tool={ 744 WinRAR:{path:'"%ProgramFiles%\\WinRAR\\WinRAR.exe"',ext:'rar' 745 ,c:{cL:'$path $cmd $s $archive -- $files',cmd:'a' // cL:command line, c:compress, s:switch 746 ,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等 747 //,l:'-ilog logFN' 748 } 749 ,u:{cL:'$path $cmd $archive $eF $eTo',cmd:'e'} // uncompress 750 ,t:{cL:'$path $cmd $archive',cmd:'t'} // test 751 } 752 ,'7-Zip':{path:'"%ProgramFiles%\\7-Zip\\7zg.exe"',ext:'7z' 753 ,c:{cL:'$path $cmd $s $archive $files',cmd:'u',s:'-mx9 -ms -mhe -mmt -uy2'} // compress 754 ,u:{cL:'$path $cmd $archive $eF $_e',cmd:'e',_e:function(fO){return fO.eTo?'-o'+fO.eTo:'';}} // uncompress 755 ,t:{cL:'$path $cmd $archive',cmd:'t'} // test 756 } 757 }; 758 /* 759 test: 760 var base='C:\\kanashimi\\www\\cgi-bin\\program\\misc\\'; 761 compress(base+'jit','_jit.htm',{tool:'7-Zip',s:''}); 762 uncompress(base+'jit',base,{tool:'7-Zip'}); 763 764 765 fO={ 766 tool:'WinRAR' // or '7-Zip' 767 ,m:'c' // method 768 ,s:'' // switch 769 ,archive:'' // archive file 770 ,files='' // what to compress 771 ,eTo='' // where to uncompress 772 ,eF='' // what to uncompress 773 ,rcL=1 // rebuild command line 774 } 775 */ 776 // solid, overwrite, compressLevel, password 777 function compressF(fO){ // flags object 778 // 參數檢查: 未完全 779 if(!fO)fO={}; 780 if(typeof fO!='object')return; 781 if(!fO.tool)fO.tool='WinRAR'; 782 //if(!fO.m)fO.m='c';//method 783 if(!fO.m||!fO.archive&&(fO.m!='c'||fO.m=='c'&&!fO.files))return; 784 if(fO.m=='c'){ 785 if(typeof fO.files!='object')fO.files=fO.files?[fO.files]:fO.archive.replace(/\..+$/,''); 786 if(!fO.archive)fO.archive=fO.files[0].replace(/[\\\/]$/,'')+_t.ext; 787 fO.files='"'+fO.files.join('" "')+'"'; 788 } 789 var i,_t=compressF.tool[fO.tool],_m,_c; 790 if(!_t||!(_m=_t[fO.m]))return; 791 else if(!/\.[a-z]+$/.test(fO.archive))fO.archive+='.'+_t.ext; 792 //if(fO.bD)fO.archive=fO.bD+(/[\\\/]$/.test(fO.bD)?'':'\\')+fO.archive; // base directory, work directory, base folder 793 if(!/["']/.test(fO.archive))fO.archive='"'+fO.archive+'"'; 794 //alert('compressF(): check OK.'); 795 // 構築 command line 796 if(_m._cL&&!fO.rcL)_c=_m._cL; // rebuild command line 797 else{ 798 _c=_m.cL.replace(/\$path/,_t.path); 799 for(i in _m)if(typeof fO[i]=='undefined')_c=_c.replace(new RegExp('\\$'+i),typeof _m[i]=='function'?_m[i](fO):_m[i]||''); 800 _m._cL=_c; 801 //alert('compressF():\n'+_c); 802 } 803 for(i in fO)_c=_c.replace(new RegExp('\\$'+i),fO[i]||''); 804 if(_c.indexOf('$')!=-1){alert('compressF() error:\n'+_c);return;} 805 alert('compressF() '+(_c.indexOf('$')==-1?'run':'error')+':\n'+_c); 806 // run 807 WshShell.Run(_c,0,true); 808 }; 809 //compress[generateCode.dLK]='compressF'; 810 function compress(archive,files,fO){ // compress file path, what to compress, flags object 811 if(!fO)fO={};else if(typeof fO!='object')return; 812 if(!fO.m)fO.m='c'; 813 if(archive)fO.archive=archive; 814 if(files)fO.files=files; 815 return compressF(fO); 816 }; 817 //uncompress[generateCode.dLK]='uncompressF'; 818 /** 819 * uncompress archive 820 * @param archive compressed file path 821 * @param eTo where to uncompress/target 822 * @param {Object} flag flags 823 * @returns 824 */ 825 function uncompress(archive, eTo, flag) { 826 if (!flag) 827 flag = {}; 828 else if (typeof flag != 'object') 829 return; 830 831 if (!flag.m) 832 flag.m = 'u'; 833 834 if (!flag.eF) 835 flag.eF = ''; 836 837 if (archive) 838 flag.archive = archive; 839 840 if (eTo) 841 flag.eTo = eTo; 842 843 return compressF(flag); 844 }; 845 846 847 848 849 850 851 852 /* 853 轉換捷徑, 傳回shortcut的Object. true path 854 http://msdn2.microsoft.com/en-us/library/xk6kst2k.aspx 855 http://yuriken.hp.infoseek.co.jp/index3.html 856 */ 857 var p; 858 //dealShortcut[generateCode.dLK]='initWScriptObj';//,parseINI 859 function dealShortcut(path,rtPath){ 860 if(typeof path!='string')path=''; 861 else if(/\.(lnk|url)$/i.test(path)){ 862 var sc=WshShell.CreateShortcut(path),p=sc.TargetPath,_i; 863 // 檔名有可能是不被容許的字元(不一定總是有'?'),這時只有.url以文字儲存還讀得到。 864 if(/*(''+sc).indexOf('?')!=-1*/!p&&/\.url$/i.test(path)&&typeof parseINI=='function'){ 865 p=parseINI(path,0,1); 866 sc={_emu:p}; 867 sc.TargetPath=(p=p.InternetShortcut).URL; 868 for(_i in p)sc[_i]=p[_i]; 869 /* 870 URL File Format (.url) http://www.cyanwerks.com/file-format-url.html 871 [DEFAULT] 872 BASEURL=http://so.7walker.net/guide.php 873 [DOC#n(#n#n#n…)] 874 [DOC#4#5] 875 BASEURL=http://www.someaddress.com/frame2.html 876 [DOC_adjustiframe] 877 BASEURL=http://so.7walker.net/guide.php 878 ORIGURL=http://so.7walker.net/guide.php 879 [InternetShortcut] 880 URL=http://so.7walker.net/guide.php 881 Modified=50A8FD7702D1C60106 882 WorkingDirectory=C:\WINDOWS\ 883 ShowCommand= // 規定Internet Explorer啟動後窗口的初始狀態:7表示最小化,3表示最大化;如果沒有ShowCommand這一項的話則表示正常大小。 884 IconIndex=1 // IconFile和IconIndex用來為Internet快捷方式指定圖標 885 IconFile=C:\WINDOWS\SYSTEM\url.dll 886 Hotkey=1601 887 888 Hotkey: 889 下面加起來: Fn 單獨 || (Fn || base) 擇一 + additional 擇2~3 890 base: 891 0=0x30(ASCII) 892 9=0x39(ASCII) 893 A=0x41(ASCII) 894 Z=0x5a(ASCII) 895 ;=0xba 896 = 897 , 898 - 899 . 900 / 901 `=0xc0 902 [=0xdb 903 \ 904 ] 905 '=0xde 906 907 Fn: 908 F1=0x70 909 .. 910 F12=0x7b 911 912 additional: 913 Shift=0x100 914 Ctrl=0x200 915 Alt=0x400 916 917 */ 918 p=p.URL; 919 } 920 if(!rtPath)return sc; 921 path=/^file:/i.test(p)?p.replace(/^[^:]+:\/+/,'').replace(/[\/]/g,'\\'):p; // /\.url$/i.test(path)?'':p; 922 } 923 return rtPath?path:null; 924 }; 925 926 //filepath=OpenFileDialog(); 基於安全,IE無法指定初始值或型態 927 //OpenFileDialog[generateCode.dLK]='IEA'; 928 function OpenFileDialog() { 929 var IE = new IEA, o; 930 if (!IE.OK(1)) 931 return null; 932 933 IE.write('<input id="file" type="file"/>');// value="'+dP+'" useless 934 935 o = IE.getE('file'); 936 o.focus(); 937 o.click(); 938 o = o.value || null; 939 940 // IE.setDialog(200,400).show(1); 941 IE.quit(); 942 943 return o; 944 }; 945 946 947 /** 948 * 是否為檔案 949 * @param path file path 950 * @param create create if not exist 951 * @returns 952 */ 953 function is_file(path, create) { 954 if (!path) 955 return 0; 956 if (typeof fso == 'undefined') 957 fso = new ActiveXObject("Scripting.FileSystemObject"); 958 if (fso.FileExists(path)) 959 return true; 960 961 // doesn't exist 962 path = get_file_name(path); 963 if (create) 964 try { 965 create = fso.CreateTextFile(path, true); 966 create.Close(); 967 } catch (e) { 968 } 969 return fso.FileExists(path); 970 }; 971 972 /** 973 * 是否為目錄 974 * @param path file path 975 * @param create create if not exist 976 * @returns 0:not folder, 1:absolute, 2:relative path 977 */ 978 function is_folder(path, create) { 979 if (!path) 980 return 0; 981 if (fso.FolderExists(path = turnToPath(path))) 982 return isAbsPath(path) ? 1 : 2; 983 if (create) 984 try { 985 fso.CreateFolder(path); 986 return isAbsPath(path) ? 1 : 2; 987 } catch (e) { 988 } 989 return 0; 990 }; 991 992 /** 993 * get directory name of a path 994 * @param folder_path 995 * @param mode 0:path, 1:filename 996 * @returns 997 */ 998 function get_folder(folder_path, mode) { 999 if (typeof folder_path == 'object' && typeof folder_path.Path == 'string') 1000 if (typeof folder_path.IsRootFolder != 'undefined') 1001 return folder_path.Path; 1002 else 1003 folder_path = folder_path.Path; 1004 if (typeof folder_path != 'string') 1005 return ''; 1006 //else if(/^[a-z]$/i.test(folder_path))folder_path+=':\\'; 1007 1008 // if(folder_path.slice(-1)!='\\')folder_path+='\\'; 1009 var i = folder_path.lastIndexOf('\\'); 1010 if (i == -1) 1011 i = folder_path.lastIndexOf('/'); 1012 return i == -1 ? folder_path : mode ? folder_path.substr(i + 1) : folder_path.slice(0, i + 1); 1013 }; 1014 1015 1016 1017 /** 1018 * 取得下一個序號的檔名,如輸入pp\aa.txt將嘗試pp\aa.txt→pp\aa[pattern].txt 1019 * @param file_path file path 1020 * @param begin_serial begin serial 1021 * @param pattern 增添主檔名的模式,包含Ser的部分將被轉換為序號 1022 * @returns 1023 */ 1024 function getNextSerialFN(file_path, begin_serial, pattern) { 1025 if (!file_path) 1026 return; 1027 if (isNaN(begin_serial)) 1028 if (!fso.FileExists(file_path)) 1029 return file_path; 1030 else 1031 begin_serial = 0; 1032 1033 var i = file_path.lastIndexOf('.'), base, ext, Ser = ':s:'; 1034 if (i == -1) 1035 base = file_path, ext = ''; 1036 else 1037 base = file_path.slice(0, i), ext = file_path.substr(i); // fso.GetBaseName(filespec);fso.GetExtensionName(path);fso.GetTempName(); 1038 1039 if (!pattern) 1040 pattern = '_' + Ser; 1041 i = pattern.indexOf(Ser); 1042 1043 if (i == -1) 1044 base += pattern; 1045 else 1046 base += pattern.slice(0, i), ext = pattern.substr(i + Ser.length) + ext; 1047 1048 for (i = begin_serial || 0; i < 999; i++) 1049 if (!fso.FileExists(base + i + ext)) 1050 return base + i + ext; 1051 1052 return; 1053 }; 1054 1055 1056 CeL.application.OS.Windows.file 1057 . 1058 /** 1059 * 轉換以 adTypeBinary 讀到的資料 1060 * @example 1061 * // 較安全的讀檔: 1062 * t=translate_AdoStream_binary_data(read_file(FP,'binary')); 1063 * write_file(FP,t,'iso-8859-1'); 1064 * @see 1065 * <a href="http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html">Hawk's W3 Laboratory : Disposable WSH : 番外編:文字エンコーディングとADODB.Stream</a> 1066 * @memberOf CeL.application.OS.Windows.file 1067 */ 1068 translate_AdoStream_binary_data = function translate_AdoStream_binary_data(data, len, type) { 1069 var _s = translate_AdoStream_binary_data,_i=0,charArray,val,DOM=_s.XMLDOM,pos,txt; 1070 if(!DOM) 1071 try{ 1072 DOM=_s.XMLDOM=(new ActiveXObject("Microsoft.XMLDOM")).createElement('tmp'); // 要素名は何でも良い 1073 DOM.dataType='bin.hex'; 1074 }catch(e){return;} 1075 if(data!==0)DOM.nodeTypedValue=data,txt=DOM.text,pos=0;//binary data 1076 else pos=_s.pos,txt=_s.text; 1077 if(isNaN(len)||len>txt.length/2)len=txt.length/2; 1078 1079 if(type){ 1080 for(val=0;_i<len;i++)val=0x100*val+parseInt(txt.substr(pos,2),16),pos+=2; 1081 _s.pos=pos; 1082 return val; 1083 } 1084 1085 /* 1086 if(!(len>0)||len!=parseInt(len)) 1087 alert(pos+','+_i+'==0~len='+len+','+txt.slice(0,8)); 1088 */ 1089 charArray=new Array(parseInt(len)); // Error 5029 [RangeError] (facility code 10): 陣列長度必須是一有限的正整數 1090 for(;_i<len;_i++) // 極慢!用charString+=更慢。 1091 try{ 1092 //if(_i%100000==0)alert(i); 1093 //if(_i==40)alert(String.fromCharCode(parseInt(txt.substr(pos,2),16))+'\n'+charArray.join('')); 1094 charArray.push(String.fromCharCode(parseInt(txt.substr(pos,2),16))),pos+=2; 1095 //charArray[_i]=String.fromCharCode((t.charCodeAt(_i<<1)<<8)+t.charCodeAt((_i<<1)+1)); 1096 }catch(e){ 1097 e.description='translate_AdoStream_binary_data: 輸入了錯誤的資料:\n'+e.description; 1098 throw e; 1099 } 1100 if(!data)_s.pos=pos; 1101 return charArray.join(''); 1102 }; 1103 1104 CeL.application.OS.Windows.file 1105 . 1106 /** 1107 * 轉換以 adTypeBinary 讀到的資料 1108 * @param data 以 adTypeBinary 讀到的資料 1109 * @param pos position 1110 * @since 2007/9/19 20:58:26 1111 * @memberOf CeL.application.OS.Windows.file 1112 */ 1113 Ado_binary = function(data, pos) { 1114 this.newDOM(); 1115 1116 if (typeof data == 'string') { 1117 if (!data || typeof getFP == 'function' 1118 && !(data = getFP(data))) 1119 return; 1120 this.newFS(data); 1121 this.setPos(pos || 0); 1122 } else 1123 this.setData(data, pos); 1124 }; 1125 CeL.application.OS.Windows.file 1126 . 1127 /** 1128 * @memberOf CeL.application.OS.Windows.file 1129 */ 1130 Ado_binary.prototype={ 1131 /** 1132 * 設定 data 1133 * 1134 * @param data binary data 1135 * @param pos 1136 * @return 1137 * @memberOf CeL.application.OS.Windows.file 1138 */ 1139 setData : function(data, pos) { 1140 this.DOM.nodeTypedValue = data,// binary data 1141 this.bt = this.DOM.text;// binary text 1142 if (!this.AdoS) 1143 this.len = this.bt.length / 2; 1144 this.setPos(pos || 0); 1145 }, 1146 setPos : function(p) { 1147 if (!isNaN(p)) { 1148 if (p < 0) 1149 p = 0; 1150 else if (p > this.len) 1151 p = this.len; 1152 this.pos = p; 1153 } 1154 return this.pos; 1155 }, 1156 testLen : function(len) { 1157 if (!len || len < 0) 1158 len = this.len; 1159 if (this.pos + len > this.len) 1160 len = this.len - this.pos; 1161 return len; 1162 }, 1163 /** 1164 * read data 1165 * @private 1166 * @param len length 1167 * @return 1168 * @memberOf CeL.application.OS.Windows.file 1169 */ 1170 readData : function(len) { 1171 this.AdoS.Position = this.pos; 1172 var _data = this.AdoS.Read(len); 1173 // 讀 binary data 用 'iso-8859-1' 會 error encoding. 1174 this.setData(_data, this.AdoS.Position); 1175 }, 1176 read : function(len) { 1177 var charArray = new Array(len = this.testLen(len)), _i = 0; 1178 this.readData(len); 1179 for (; _i < len; _i++) 1180 try { 1181 charArray.push(String.fromCharCode(parseInt(this.bt 1182 .substr(2 * _i, 2), 16))); 1183 // charArray[i]=String.fromCharCode((t.charCodeAt(i<<1)<<8)+t.charCodeAt((i<<1)+1)); 1184 } catch (e) { 1185 this.retErr(e); 1186 } 1187 return charArray.join(''); 1188 }, 1189 readNum : function(len) { 1190 len = this.testLen(len); 1191 this.readData(len); 1192 var val = 0, _i = len; 1193 for (; _i > 0;) 1194 try { 1195 val = 0x100 * val 1196 + parseInt(this.bt.substr(2 * (--_i), 2), 16); 1197 } catch (e) { 1198 this.retErr(e); 1199 } 1200 return val; 1201 }, 1202 readHEX : function(len) { 1203 len = this.testLen(len); 1204 this.readData(len); 1205 return this.bt; 1206 }, 1207 retErr : function(e) { 1208 e.description = 'translate_AdoStream_binary_data: 輸入了錯誤的資料:\n' + e.description; 1209 throw e; 1210 }, 1211 /** 1212 * @private 1213 * @return 1214 * @memberOf CeL.application.OS.Windows.file 1215 */ 1216 newDOM : function() { 1217 this.DOM = null; 1218 //try{ 1219 this.DOM = (new ActiveXObject("Microsoft.XMLDOM")).createElement('tmp' + Math.random()); // 要素名は何でも良い 1220 //}catch(e){return;} 1221 this.DOM.dataType = 'bin.hex'; 1222 }, 1223 /** 1224 * @private 1225 * @param FP 1226 * @return 1227 * @memberOf CeL.application.OS.Windows.file 1228 */ 1229 newFS : function(FP) { 1230 if (FP) 1231 this.FP = FP; 1232 else if (!(FP = this.FP)) 1233 return; 1234 var _i = _.open_file.returnADO; 1235 _.open_file.returnADO = true; 1236 this.AdoS = _.open_file(FP, 'binary'); 1237 _.open_file.returnADO = _i; 1238 if (!this.AdoS) 1239 return; 1240 this.AdoS.LoadFromFile(FP); 1241 this.len = this.AdoS.Size; 1242 }, 1243 /** 1244 * 實際上沒多大效用。實用解決法:少用 AdoStream.Write() 1245 * @return 1246 * @memberOf CeL.application.OS.Windows.file 1247 */ 1248 renew : function() { 1249 this.bt = this.data = 0; 1250 this.newDOM(); 1251 if (this.AdoS && this.FP) { 1252 this.pos = this.AdoS.Position; 1253 this.AdoS.Close(); 1254 this.AdoS = null; 1255 this.newFS(); 1256 } 1257 }, 1258 destory : function(e) { 1259 if (this.AdoS) 1260 this.AdoS.Close(); 1261 this.AdoS = this.pos = this.bt = this.data = 0; 1262 } 1263 }; // Ado_binary.prototype={ 1264 1265 1266 /* 1267 // 速度過慢,放棄。 1268 //_.open_file.returnADO=true; 1269 function dealBinary(FP,func,interval){ 1270 var t,fs=_.open_file(FP,'binary',ForReading); 1271 if(!fs)return; 1272 AdoStream.LoadFromFile(FP); 1273 if(!interval)interval=1; 1274 //alert(fs.size) 1275 while(!fs.EOS) 1276 if(func(translate_AdoStream_binary_data(fs.Read(interval))))return; 1277 func(); 1278 fs.Close(); 1279 } 1280 */ 1281 1282 /* 配合simple系列使用 1283 http://thor.prohosting.com/~mktaka/html/utf8.html 1284 http://www.andrewu.co.uk/webtech/comment/?703 1285 http://www.blueidea.com/bbs/NewsDetail.asp?id=1488978 1286 http://www.blueidea.com/bbs/NewsDetail.asp?GroupName=WAP+%BC%BC%CA%F5%D7%A8%C0%B8&DaysPrune=5&lp=1&id=1524739 1287 C# http://www.gotdotnet.com/team/clr/bcl/TechArticles/TechArticles/IOFAQ/FAQ.aspx 1288 http://www.sqlxml.org/faqs.aspx?faq=2 1289 http://www.imasy.or.jp/~hir/hir/tech/js_tips.html 1290 1291 ADODB.Stream 最大問題:不能append 1292 http://msdn2.microsoft.com/en-us/library/ms808792.aspx 1293 http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp 1294 http://study.99net.net/study/web/asp/1067048121.html http://www.6to23.com/s11/s11d5/20031222114950.htm 1295 http://blog.csdn.net/dfmz007/archive/2004/07/23/49373.aspx 1296 */ 1297 var AdoStream,AdoEnums; // ADO Enumerated Constants http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp 1298 /* 搬到前面 1299 setObjValue('AdoEnums','adTypeBinary=1,adTypeText=2' // StreamTypeEnum 1300 +',adReadAll=-1,adReadLine=-2' // StreamReadEnum http://msdn2.microsoft.com/en-us/library/ms806462.aspx 1301 +',adSaveCreateNotExist=1,adSaveCreateOverWrite=2' // SaveOptionsEnum 1302 +',adCR=13,adCRLF=-1,adLF=10' // LineSeparatorsEnum 1303 ,'int'); 1304 */ 1305 AdoEnums = { 1306 adTypeBinary : 1, 1307 adTypeText : 2, 1308 adReadAll : -1, 1309 adReadLine : -2, 1310 adSaveCreateNotExist : 1, 1311 adSaveCreateOverWrite : 2, 1312 adCR : 13, 1313 adCRLF : -1, 1314 adLF : 10 1315 }; 1316 1317 1318 //_.open_file[generateCode.dLK]='AdoEnums,simpleFileErr,ForReading,ForWriting,ForAppending,TristateUseDefault';//AdoStream 1319 CeL.application.OS.Windows.file 1320 . 1321 /** 1322 * 提供給 <a href="#.read_file">read_file</a>, <a href="#.write_file">write_file</a> 使用的簡易開檔函數 1323 * @param FN file path 1324 * @param format open format, e.g., open_format.TristateUseDefault 1325 * @param io_mode open mode, e.g., iomode.ForWriting 1326 * @memberOf CeL.application.OS.Windows.file 1327 */ 1328 open_file = function open_file(FN, format, io_mode) { 1329 //if(!FN||typeof isAbsPath=='function'&&typeof get_file_name=='function'&&!isAbsPath(FN)&&!(FN=get_file_name(FN)))return; 1330 //if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return; 1331 var _s = open_file; 1332 if(typeof format=='string'){ 1333 if(!_s.returnADO&&typeof AdoStream!='undefined') 1334 try{AdoStream.Close();AdoStream=null;}catch(e){} 1335 try{ 1336 AdoStream=new ActiveXObject("ADODB.Stream");//var objStream=Server.CreateObject("ADODB.Stream"); // ASPの場合,Err.Number=-2147221005表不支援 1337 }catch(e){simpleFileErr=e;AdoStream=null;} 1338 if(AdoStream){ 1339 //AdoStream.Mode=3; // read write 1340 if(format=='binary')AdoStream.Type=AdoEnums.adTypeBinary; // 以二進位方式操作 1341 else{ 1342 AdoStream.Type=AdoEnums.adTypeText; 1343 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 1344 } 1345 AdoStream.Open(); 1346 //AdoStream.Position=0,AdoStream.LineSeparator=AdoEnums.adLF; 1347 if(_s.returnADO){var _A=AdoStream;AdoStream=null;return _A;} 1348 return 0; 1349 } 1350 format=0; 1351 } 1352 var fs; 1353 // 使用某些防毒軟體(如諾頓 Norton)時,.OpenTextFile() 可能會被攔截,因而延宕。 1354 try{ 1355 if(io_mode==_.iomode.ForAppending&&!fso.FileExists(FN))io_mode=_.iomode.ForWriting; // 無此檔時改 writing 1356 fs=fso.OpenTextFile(FN,io_mode||_.iomode.ForReading,io_mode==_.iomode.ForWriting/*create*/,format||_.open_format.TristateUseDefault); 1357 }catch(e){ 1358 simpleFileErr=e; 1359 try{fs.Close();}catch(e){} 1360 return -1; 1361 } 1362 return fs; 1363 }; 1364 CeL.application.OS.Windows.file 1365 .open_file.returnADO=false; 1366 CeL.application.OS.Windows.file 1367 .open_file.error; 1368 1369 // 若是僅使用普通的開檔方法(_.open_format.TristateTrue/_.open_format.TristateFalse等,不使用ADODB.Stream),直接引用下兩函數與fso段定義即可。否則還需要引入_.open_file(),setObjValue(),dQuote() 1370 var simpleFileErr, 1371 //_autodetect autodetectEncode(file) 1372 simpleFileAutodetectEncode=-5.4, 1373 simpleFileDformat= 1374 CeL.application.OS.Windows.file 1375 .open_format.TristateUseDefault; 1376 1377 //_.read_file[generateCode.dLK]=_.write_file[generateCode.dLK]='simpleFileErr,simpleFileAutodetectEncode,simpleFileDformat,initWScriptObj';//_.open_file,autodetectEncode,getFP,_.open_format.TristateUseDefault 1378 //_.read_file[generateCode.dLK]+=',ForReading';_.write_file[generateCode.dLK]+=',ForWriting'; 1379 //_.read_file[generateCode.dLK]+=',translate_AdoStream_binary_data'; // for _.read_file(FP,'binary') 1380 CeL.application.OS.Windows.file 1381 . 1382 /** 1383 * 讀取檔案 1384 * @param FN file path 1385 * @param format open encode = simpleFileDformat 1386 * @param io_mode open IO mode = ForReading 1387 * @param func do this function per line, or [func, maxsize] (TODO) 1388 * @return {String} 檔案內容 1389 * @memberOf CeL.application.OS.Windows.file 1390 */ 1391 read_file=function(FN,format,io_mode,func){ 1392 simpleFileErr=0;if(format==simpleFileAutodetectEncode) 1393 format=typeof autodetectEncode=='function'?autodetectEncode(FN):simpleFileDformat; 1394 if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return; 1395 //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;} 1396 var a,fs;//,i,s=0,t; 1397 if(typeof _.open_file!='function') 1398 //{if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return; 1399 try{fs=fso.OpenTextFile(FN,io_mode||_.iomode.ForReading,false/*create*/,format||simpleFileDformat);} 1400 catch(e){simpleFileErr=e;return;} 1401 else if(fs=_.open_file(FN,format||simpleFileDformat,io_mode||_.iomode.ForReading),fs===-1)return; 1402 1403 //if(func instanceof Array)s=func[1],func=func[0]; 1404 if(fs!==0)try{ 1405 if(func) 1406 while(!fs.AtEndOfStream)func(fs.ReadLine()); 1407 /* 1408 while(!fs.AtEndOfStream){ 1409 for(t='',i=0;!fs.AtEndOfStream&&(!t||i<s);i++) 1410 t+=fs.ReadLine(); 1411 a+=func(t); 1412 } 1413 */ 1414 else a=fs.ReadAll(); 1415 fs.Close(); 1416 }catch(e){simpleFileErr=e;try{fs.Close();}catch(e){}return;} 1417 else if(typeof AdoStream!='undefined'&&AdoStream) 1418 try{ 1419 AdoStream.LoadFromFile(FN); 1420 if(AdoStream.Type==AdoEnums.adTypeBinary){ 1421 a=AdoStream.Read(AdoEnums.adReadAll); // 讀 binary data 用 'iso-8859-1' 會 error encoding. 1422 if(_.read_file.turnBinToStr&&typeof translate_AdoStream_binary_data=='function')a=translate_AdoStream_binary_data(a); 1423 }else if(func) 1424 while(!AdoStream.EOS)func(AdoStream.ReadText(AdoEnums.adReadLine)); 1425 /* 1426 while(!AdoStream.EOS){ 1427 for(t='',i=0;!AdoStream.AtEndOfStream&&(!t||i<s);i++) 1428 t+=AdoStream.ReadText(AdoEnums.adReadLine); 1429 a+=func(t); 1430 } 1431 */ 1432 else a=AdoStream.ReadText(AdoEnums.adReadAll); 1433 AdoStream.Close(); 1434 }catch(e){ 1435 simpleFileErr=e; 1436 try{AdoStream.Close();}catch(e){} 1437 return; 1438 } 1439 else simpleFileErr=new Error(1,'unknown error!'),simpleFileErr.name='unknownError'; 1440 return a; 1441 }; 1442 CeL.application.OS.Windows.file 1443 .read_file.turnBinToStr=true; 1444 1445 1446 CeL.application.OS.Windows.file 1447 . 1448 /** 1449 * 將 content 寫入 file 1450 * ** ADODB.Stream does not support appending! 1451 * @param FN file path 1452 * @param content content to write 1453 * @param format open format = simpleFileDformat 1454 * @param io_mode write mode = ForWriting, e.g., ForAppending 1455 * @param N_O DO NOT overwrite 1456 * @return error No. 1457 * @memberOf CeL.application.OS.Windows.file 1458 */ 1459 write_file = function(FN, content, format, io_mode, N_O) { 1460 simpleFileErr = 0; 1461 if (format == simpleFileAutodetectEncode) 1462 format = typeof autodetectEncode == 'function' ? autodetectEncode(FN) 1463 : simpleFileDformat; 1464 if (!FN || typeof getFP == 'function' && !(FN = getFP(FN))) 1465 return 2; 1466 //var fs;try{fs=fso.OpenTextFile(FN,iomode||ForWriting,true,format||TristateUseDefault);}catch(e){return 2;}if(!fs)return 3; 1467 //try{fs.Write(content);}catch(e){return e.number&0xFFFF==5?5:4;} // 5:content中有此local無法相容的字元,例如在中文中寫入日文假名 1468 var fs; 1469 if (typeof _.open_file != 'function') 1470 // {if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return 2; 1471 try { 1472 fs = fso.OpenTextFile(FN, io_mode || _.iomode.ForWriting, 1473 true/* create */, format || simpleFileDformat); 1474 if (!fs) 1475 return 3; 1476 } catch (e) { 1477 simpleFileErr = e; 1478 return 2; 1479 } 1480 else if (fs = _.open_file(FN, format || simpleFileDformat, io_mode 1481 || _.iomode.ForWriting), fs === -1) 1482 return 3; 1483 else if (!fs && isNaN(fs)) 1484 return 2; 1485 if (fs !== 0) 1486 try { 1487 fs.Write(content); 1488 fs.Close(); 1489 } catch (e) { 1490 simpleFileErr = e; 1491 try { 1492 fs.Close(); 1493 } catch (e) { 1494 } 1495 return simpleFileErr.number & 0xFFFF == 5 ? 5 : 4; 1496 } 1497 // AdoStream.SaveToFile()需在AdoStream.Write之後! 1498 else if (typeof AdoStream != 'undefined' && AdoStream) 1499 try { 1500 if (AdoStream.Type == AdoEnums.adTypeText) 1501 AdoStream.WriteText(content); 1502 else 1503 AdoStream.Write(content); 1504 AdoStream.SaveToFile(FN, io_mode 1505 || AdoEnums.adSaveCreateOverWrite); 1506 AdoStream.Close(); 1507 } catch (e) { 1508 simpleFileErr = e; 1509 try { 1510 AdoStream.Close(); 1511 } catch (e) { 1512 } 1513 return 6; 1514 } 1515 else { 1516 simpleFileErr = new Error(1, 'unknown error!'), 1517 simpleFileErr.name = 'unknownError'; 1518 return 1; 1519 } 1520 }; 1521 1522 // TODO: unfinished 1523 //simpleDealFile[generateCode.dLK]='autodetectEncode,_.read_file,_.write_file'; 1524 CeL.application.OS.Windows.file 1525 . 1526 simpleDealFile = function(inFN, func, outFN, format, io_mode, N_O) { 1527 if (!inFN) 1528 return; 1529 if (!outFN) 1530 outFN = inFN; 1531 var e = autodetectEncode(inFN), i = _.read_file(inFN, e), o = _.read_file( 1532 outFN, e), t = func(i, inFN); 1533 if (typeof t == 'string' && o != t) 1534 return _.write_file(outFN, t, e, N_O); 1535 }; 1536 1537 /* 1538 var autodetectEncodeSP,autodetectEncodeCode; // 特殊字元,各種編碼及判別所需最短長度 1539 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,' 1540 +'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,' 1541 +'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,' 1542 +'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,' 1543 +'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,' 1544 +'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,' 1545 +'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,' 1546 +'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,' 1547 +'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,' 1548 +'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,' 1549 +'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,' 1550 +'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,' 1551 +'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,' 1552 +'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,' 1553 +'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,' 1554 +'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,' 1555 +'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,' 1556 +'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,' 1557 +'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,' 1558 +'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,' 1559 +'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,' 1560 +'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,' 1561 +'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,' 1562 +'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,' 1563 +'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,' 1564 +'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,' 1565 +'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,' 1566 +'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,' 1567 +'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,' 1568 +'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,' 1569 +'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,' 1570 +'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,' 1571 +'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,' 1572 +'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,' 1573 +'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,' 1574 +'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,' 1575 +'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,' 1576 +'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,' 1577 +'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,' 1578 +'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,' 1579 +'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,' 1580 +'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,' 1581 +'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,' 1582 +'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,' 1583 +'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,' 1584 +'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,' 1585 +'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,' 1586 +'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,' 1587 +'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,' 1588 +'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,' 1589 +'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,' 1590 +'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,' 1591 +'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,' 1592 +'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,' 1593 +'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,' 1594 +'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,' 1595 +'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,' 1596 +'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,' 1597 +'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,' 1598 +'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,' 1599 +'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,' 1600 +'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,' 1601 +'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,' 1602 +'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,' 1603 +'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,' 1604 +'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,' 1605 +'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); 1606 // HKEY_CLASSES_ROOT\MIME\Database\Charset 1607 // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字,Big5常用字卻常常是gb中奇怪字碼與罕用字 1608 setObjValue('autodetectEncodeCode','GB2312=3000,Big5=3000,shift_jis=900,iso-8859-1=2000',1); 1609 1610 1611 TODO: 1612 只檢測常用的幾個字,無法判別才廣泛測試。 1613 */ 1614 //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)); 1615 /* 自動判別檔案(或字串)之編碼 文字エンコーディング判定を行う 1616 http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html 1617 http://www.ericphelps.com/q193998/ 1618 http://hp.vector.co.jp/authors/VA003334/ado/adostream.htm 1619 */ 1620 //autodetectEncode[generateCode.dLK]='is_file,simpleFileDformat,_.open_file,autodetectStringEncode,autodetectHTMLEncode'; 1621 CeL.application.OS.Windows.file 1622 . 1623 autodetectEncode=function(FN,isHTML){ 1624 var t,code; 1625 if(typeof ActiveXObject=='undefined'){alert("autodetectEncode: Can't find ActiveXObject!");return;} 1626 //if(typeof autodetectHTMLEncode!='function')isHTML=false; 1627 if(!is_file(FN))return FN.length<64?simpleFileDformat:(t=autodetectStringEncode(FN))?t:(isHTML||typeof isHTML=='undefined')&&(t=autodetectHTMLEncode(FN))?t:simpleFileDformat; 1628 _.open_file(FN,'iso-8859-1'); // 讀 binary data 用 'iso-8859-1' 會 error encoding. 1629 if(!AdoEnums||!AdoStream)return simpleFileDformat; 1630 AdoStream.LoadFromFile(FN); 1631 t=AdoStream.ReadText(3);//Read(3);// 1632 //alert(FN+'\n'+t.charCodeAt(0)+','+t.charCodeAt(1)+','+t.charCodeAt(2)); 1633 1634 //if(typeof t!='string')return simpleFileDformat;//t=''+t; // 此時type通常是unknown,不能用+= 1635 // Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏,它是以FF-FE這兩個bytes表達,在BE(big endian)裏,是FEFF。而在UTF-8裏,它是以EF-BB-BF這三個bytes表達。 1636 if(t.slice(0,2)=='\xFF\xFE')code='unicodeFFFE'; 1637 else if(t.slice(0,2)=='\xFE\xFF')code='unicode'; 1638 else if(t=='\xEF\xBB\xBF')code='UTF-8'; 1639 else{ 1640 // 即使是用OpenTextFile(_.open_format.TristateFalse),UTF-8還是會被轉換而判別不出來。 1641 // from http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html 1642 var l,codes={},reg=new RegExp(),stream=new ActiveXObject("ADODB.Stream"); 1643 codes['iso-8859-1']='[\\x09\\x0a\\x0d\\x20-\\x7e]'; 1644 codes['big5']=codes['iso-8859-1']+ 1645 '|[\\xa4-\\xc6\\xc9-\\xf9][\\x40-\\xfe]'; // http://www.cns11643.gov.tw/web/word/big5/index.html 1646 codes['shift_jis']=codes['iso-8859-1']+ 1647 '|[\\x81-\\x9f\\xe0-\\xef\\xfa-\\xfc][\\x40-\\x7e\\x80-\\xfc]|[\\xa1-\\xdf]'; // http://hp.vector.co.jp/authors/VA013241/misc/shiftjis.html 1648 codes['euc-jp']=codes['iso-8859-1']+ 1649 '|\\x8f[\\xa1-\\xfe][\\xa1-\\xfe]|[\\xa1-\\xfe][\\xa1-\\xfe]|\\x8e[\\xa1-\\xdf]'; 1650 codes['utf-8']=codes['iso-8859-1']+ 1651 '|[\\xc0-\\xdf][\\x80-\\xbf]|[\\xe0-\\xef][\\x80-\\xbf]{2}|[\\xf0-\\xf7][\\x80-\\xbf]{3}'+ 1652 '|[\\xf8-\\xfb][\\x80-\\xbf]{4}|[\\xfc-\\xfd][\\x80-\\xbf]{5}'; 1653 codes['gb2312']=codes['iso-8859-1']+ // GBK 1654 '|[\\xa1-\\xf7][\\xa1-\\xfe]'; // http://zh.wikipedia.org/wiki/GB_18030 http://zh.wikipedia.org/wiki/GB_2312 1655 1656 stream.type=AdoEnums.adTypeBinary; 1657 stream.open(); 1658 stream.loadFromFile(FN); 1659 stream.position=0; 1660 t=stream.read(); 1661 stream.close(); 1662 stream=null; 1663 1664 t=translate_AdoStream_binary_data(t,4e3); 1665 1666 for(var _e in codes){ 1667 reg=new RegExp('^(?:'+codes[_e]+')'); 1668 var l=0,s=t; 1669 while(l!=s.length)l=s.length,s=s.replace(reg,""); 1670 if(s==""){code=_e;break;} 1671 } 1672 1673 } 1674 //sl('autodetectEncode: coding: ['+code+'] in parse 1.'); 1675 1676 // 假如是HTML檔,判斷是否有charset設定。這個判別放在unicode之後,其他自動判別之前。 1677 if(isHTML||typeof isHTML=='undefined'&&/\.s?html?$/i.test(FN)){ 1678 if(AdoStream.Type==AdoEnums.adTypeBinary)_.open_file(FN,'iso-8859-1'); 1679 AdoStream.Position=0,AdoStream.Charset='iso-8859-1'; // 讀 binary data 用 'iso-8859-1' 會 error encoding. 1680 if(t=autodetectHTMLEncode(AdoStream.ReadText(4e3)))code=t; 1681 } 1682 //sl('autodetectEncode: coding: ['+code+'] in parse 2.'); 1683 1684 //autodetectEncodeCode.GB2312=900000; // 4 test 1685 if(!code)for(var i in autodetectEncodeCode){ 1686 if(AdoStream.Type==AdoEnums.adTypeBinary)_.open_file(FN,'iso-8859-1'); 1687 if(AdoStream.Position=0,i==autodetectStringEncode(AdoStream.ReadText(autodetectEncodeCode[AdoStream.Charset=i]))){code=i;break;} 1688 } 1689 1690 AdoStream.Close(); 1691 return code||simpleFileDformat; // ascii=iso-8859-1,_autodetect,_autodetect_all 1692 }; 1693 1694 /** 1695 * 判斷HTML檔是否有charset設定 1696 * @param file_contents file contents 1697 * @returns 1698 */ 1699 function autodetectHTMLEncode(file_contents) { 1700 var m; 1701 if ((m = file_contents.match(/<meta\s+([^>]+)>/i)) 1702 && (m = m[1].match(/content="([^"]+)"/i) || m[1].match(/content=([^\w]+)/i)) 1703 && (m = m[1].match(/charset=([\w-]{2,})/i)) 1704 || (m = file_contents.match(/<\?xml\s[^>]+\sencoding\s*=\s*["']([a-z\d\-]+)["']/i))) 1705 return m[1]; 1706 }; 1707 1708 CeL.application.OS.Windows.file 1709 . 1710 /** 1711 * 靠常用字自動判別字串之編碼 string,預設編碼 1712 */ 1713 autodetectStringEncode=function(str){ 1714 if(typeof str!='string'||!(str=str.replace(/\s+/g,'')))return; 1715 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; 1716 //if(len>9000)len=9000; 1717 //var unknownC=''; 1718 1719 // char分類 1720 for(;i<len;i++) 1721 if(c=str.charCodeAt(i),c<0x80)ascii++; 1722 else if(c<0x100)asciiHigh++; 1723 else if(c>0x3040&&c<0x30ff)kana++; 1724 else if(c==0x30fb||c>0xff65&&c<0xff9e)halfwidthKatakana++; 1725 else if(c>=0x1100&&c<0x11fa||c>=0xac00&&c<0xad00||c>=0xd700&&c<0xd7a4)Hangul++; 1726 else if(c>0x4dff&&c<0x9fa6){kanji++,a=autodetectEncodeSP[c];if(a=='C')jianhuazi++;else if(a=='J')kokuji++;} 1727 else if(c>0xfa00&&c<0xfa6b){if(autodetectEncodeSP[c]=='J')kokuji++;} 1728 else if(c>0x2010&&c<0x2610||c>=0xfe30&&c<0xfe70||c>0xff00&&c<0xff5f)symbol++; 1729 else if(c>=0x3000&&c<0x3400||c>0x33ff&&c<0x4db6) 1730 if(autodetectEncodeSP[c]=='J')kokuji++;else symbol++; 1731 else unknown++;//,unknownC+=str.charAt(i); 1732 1733 //alert('len='+len+'\nkana='+kana+'\nkokuji='+kokuji+'\njianhuazi='+jianhuazi+'\nhalfwidthKatakana='+halfwidthKatakana+'\nHangul='+Hangul+'\nascii='+ascii+'\nasciiHigh='+asciiHigh+'\nkanji='+kanji+'\nsymbol='+symbol+'\nunknown='+unknown); 1734 //if(unknownC)alert('unknown:\n'+unknownC.slice(0,200));//alert(unknownC.slice(0,200)+'\n'+str.slice(0,1000)); 1735 // 依各種常用字母之條件判別 1736 return ascii+asciiHigh==len?'iso-8859-1' 1737 :unknown>.05*(len-ascii)?''//unicode // unknown不能太多 1738 :kana>.2*len&&kanji+kana+symbol>3*halfwidthKatakana?'shift_jis' 1739 :kanji+symbol>.7*(len-ascii)&&kana<.05*(len-ascii)? jianhuazi>.1*kanji?'GB2312':'Big5' 1740 :Hangul+symbol>.7*(len-ascii)?'korean'//ks_c_5601 1741 :kanji>.2*(len-ascii)? jianhuazi>.1*kanji?kokuji>.02*kanji?'unicode':'GB2312':kokuji>.02*kanji?'shift_jis':'Big5' 1742 :'';//unicode 1743 }; 1744 1745 /* 1746 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 1747 http://www.theorem.ca/~mvcorks/cgi-bin/unicode.pl.cgi?start=F900&end=FAFF http://homepage1.nifty.com/nomenclator/unicode/normalization.htm 1748 1749 Unicode的漢字大致是以康熙部首排序,不過間中有部分字排錯部首筆劃 1750 第一批在1993年加進Unicode的, 1751 於中國內地、台灣、南韓及日本已有字集的漢字, 1752 編碼於U+4E00至U+9FA5, 1753 亦有部分南韓重覆漢字被編到U+F900至U+FA0B、 1754 兩個Big-5重覆漢字被編到U+FA0C至U+FA0D、 1755 日本廠商漢字被編到U+FA0E至U+FA2D 1756 1757 全形符號(只限鍵盤上那94個)位於U+FF01至U+FF5E 1758 中日韓專用符號放到了U+3000至U+33FF內, 1759 其餘有部分符號放到了U+2XXX及U+FE30至U+FE6F 1760 1761 第二批在1999年加進Unicode的, 1762 加進了新加坡用漢字、南韓PKS C 5700-2 1994、 1763 部分CNS11643第三、四、十五字面等用字、 1764 未包括在第一批字的數個GB字集用字, 1765 被編入U+3400至U+4DB5 1766 1767 第三批在2001年加進Unicode的, 1768 加進了CNS11643第三、四、五、六、七、十五字面所有字、 1769 香港增補字集用字、四庫全書、辭海、辭源、康熙字典、 1770 漢語大字典、漢語大詞典內的所有用字, 1771 被編入U+20000至U+2A6D6 1772 JIS-X0213漢字被加到U+FA30至U+FA6A 1773 CNS11643重覆漢字被加到U+2F800至U+2FA1D 1774 1775 简化字总表 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 1776 简化字分布似乎並無規範,只好以array判斷: 1777 1778 <div id="dataGB"> 1779 http://cdns.twnic.net.tw/cjktable/simtab.html 1780 簡化字總表之 UNICODE 碼表 1781 </div> 1782 <div id="dataJP"> 1783 http://homepage2.nifty.com/TAB01645/ohara/index_j2.htm 1784 JIS区点索引 1785 </div> 1786 1787 <script type="text/javascript"> 1788 var i=0,c=0,autodetectEncodeSP=[],m=document.getElementById('dataGB').innerHTML.match(/\([0-9A-F]{4},\w*\)/g),t="setObjValue('autodetectEncodeSP','"; 1789 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); 1790 if(m[i].indexOf('T')==-1)autodetectEncodeSP[parseInt(m[i].substr(1,4),16)]='C'; 1791 for(i=0,m=document.getElementById('dataJP').innerHTML.match(/【.】/g);i<m.length;i++) 1792 autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]=autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]?0:'J'; 1793 1794 m=[];for(i in autodetectEncodeSP)m.push(parseInt(i));m.sort(); 1795 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/>+'";} 1796 alert(c+'字'); 1797 document.getElementById('dataJP').innerHTML=''; 1798 document.getElementById('dataGB').innerHTML=t.slice(0,-1)+"',1,16);"; 1799 </script> 1800 1801 1802 和製漢字(国字)は、和語(ヤマトコトバ)に相当する漢字が無い場合に新規につくられたもので、奈良時代から作られた。ほとんどは訓読みしかない。魚篇や木篇が多い。 1803 http://homepage2.nifty.com/TAB01645/ohara/index.htm 1804 http://zh.wiktionary.org/wiki/%E8%BE%BB 1805 http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=8fbb 1806 http://jprs.jp/doc/rule/saisoku-1-wideusejp-furoku-4.html 1807 http://m2000.idv.tw/informer/zhi/char-root.htm 1808 http://www.ajisai.sakura.ne.jp/~dindi/chrc/ref/wincode2.txt 1809 http://cs-people.bu.edu/butta1/personal/hkscs/hkscs-oct.html 1810 http://www.nobi.or.jp/i/kotoba/kanji/wasei-kanji.html 1811 http://www.melma.com/mag/52/m00011552/a00000066.html 1812 1813 1814 韓語字母/諺文 1815 http://www.sinica.edu.tw/~cytseng/Korean%20reader/hangul.htm 1816 http://www.unicode.org/charts/normalization/ 1817 1818 old: 1819 // 自動判別檔案(或字串)之編碼 1820 function autodetectEncode(FN){ 1821 if(!is_file(FN))return FN.length>64?autodetectStringEncode(FN):simpleFileDformat; 1822 _.open_file(FN,'iso-8859-1'); 1823 if(!AdoEnums)return simpleFileDformat; 1824 //AdoStream.Type=AdoEnums.adTypeBinary; 1825 AdoStream.LoadFromFile(FN); 1826 var t=AdoStream.ReadText(3),code; 1827 // Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏,它是以FF-FE這兩個bytes表達,在BE(big endian)裏,是FEFF。而在UTF-8裏,它是以EF-BB-BF這三個bytes表達。 1828 if(t.slice(0,2)=='\xFF\xFE')code='unicodeFFFE'; 1829 if(t.slice(0,2)=='\xFE\xFF')code='unicode'; 1830 if(t=='\xEF\xBB\xBF')code='UTF-8'; 1831 if(code){AdoStream.Close();return code;} 1832 1833 if(!code)with(AdoStream){ 1834 // 將sjis排在gb與Big5前面是因為sjis常符合gb,且sjis之判定相當嚴。 1835 if(!code)Position=0,Charset='shift_jis',code=autodetectStringEncode(ReadText(900),Charset); 1836 // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字,Big5常用字卻常常是gb中奇怪字碼與罕用字 1837 if(!code)Position=0,Charset='GB2312',code=autodetectStringEncode(ReadText(2000),Charset); 1838 if(!code)Position=0,Charset='Big5',code=autodetectStringEncode(ReadText(2000),Charset); 1839 } 1840 1841 AdoStream.Close(); 1842 return code||simpleFileDformat; // ascii=iso-8859-1,_autodetect,_autodetect_all 1843 } 1844 // 靠常用字自動判別字串之編碼 string,預設編碼 1845 function autodetectStringEncode(str,dcode){ 1846 var code; 1847 if(str.length>9000)str=str.slice(0,9000); 1848 1849 // 將sjis排在gb與Big5前面是因為sjis常符合gb,且sjis之判定相當嚴。 1850 if(dcode=='shift_jis'||!dcode&&!code){ 1851 // http://www.asahi-net.or.jp/~hc3j-tkg/unicode/ http://www.unicode.org/Public/UNIDATA/DerivedCoreProperties.txt 1852 var i=0,c,k=0,u=0,h=0;//h_=u_=k_=''; 1853 for(;i<str.length;i++)if(c=str.charCodeAt(i),c>0xFF) 1854 if(c==0x30FB||c>0xFF65&&c<0xFF9E)h++;//,h_+=str.charAt(i);//||c==0xE134 // HALFWIDTH KATAKANA LETTER等可能不是日文文件中會出現的char 1855 else if(c>0x3040&&c<0x30FF)k++;//,k_+=str.charAt(i); // kana 1856 else u++;//,u_+=str.charAt(i); // unknown kanji 1857 //alert(k+','+u+','+h+'\n*'+k_+'\n*'+u_+'\n*'+h_);//alert(u_.charCodeAt(2)); 1858 if(k+u>2*h)code='shift_jis'; // HALFWIDTH KATAKANA LETTER數目比漢字少時判別為shift_jis 1859 } 1860 1861 // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字,Big5常用字卻常常是gb中奇怪字碼與罕用字 1862 if(dcode=='Big5'||dcode=='GB2312'||!dcode&&!code){ 1863 var i=0,c,k=0,u=0;//k_=u_=''; 1864 for(;i<str.length;i++)if(c=str.charCodeAt(i),c>0xFF) 1865 if(c>0x4DFF&&c<0x9FA6||c>0xFF00&&c<0xFF5F||c>0x33ff&&c<0x4DB6||c==0x2605||c==0x2606)k++;//,k_+=str.charAt(i); // 2605,6:★☆ 1866 else u++;//,u_+=str.charAt(i); 1867 //alert(k+','+u+'\n'+k_+'\n*'+u_); 1868 if(k>5*u)code=dcode||'Big5'; // 漢字比不認識的字多時判定 1869 } 1870 1871 if(dcode=='iso-8859-1'||dcode=='ascii'||!dcode&&!code){ 1872 } 1873 1874 return code; 1875 } 1876 */ 1877 1878 1879 /* 將 iso-8859-1 轉成utf-8 1880 To use: 1881 .. 1882 translated=turnBinStr(original); 1883 .. 1884 translated=turnBinStr(); // delete temp file 1885 */ 1886 turnBinStr.temp_file = 'turnBinStr.tmp'; // temp file name 1887 function turnBinStr(t, _enc) { 1888 if (typeof t != 'undefined') { 1889 if (!turnBinStr.tmpF) 1890 turnBinStr.tmpF = getFP(turnBinStr.temp_file, 1); 1891 1892 //t+=''; 1893 //if(t.replace(/[^\x00-\x7f]+/g,''))return t; 1894 //var _q=t.replace(/[^?]+/g,'').length,_t,_j=0; 1895 _.write_file(turnBinStr.tmpF,''+t,'iso-8859-1'); 1896 //alert(turnBinStr.tmpF+'\n'+simpleFileErr.description+'\n'+t+'\n'+_.read_file(turnBinStr.tmpF,'utf-8')); 1897 return _.read_file(turnBinStr.tmpF,'utf-8'); 1898 /* 1899 if(!_enc)_enc='utf-8,Big5,shift_jis,euc-jp,GB2312'.split(','); 1900 else if(!(_enc instanceof Array))_enc=[_enc]; 1901 for(;_j<_enc.length;_j++) 1902 if((_t=_.read_file(turnBinStr.tmpF,_enc[_j])).replace(/[^?]+/g,'').length==_q) 1903 return _t;//'['+_enc[_j]+']'+ 1904 return t; 1905 */ 1906 } 1907 // 有時會出錯 1908 try { 1909 fso.DeleteFile(turnBinStr.tmpF); 1910 } catch (e) { 1911 } 1912 } 1913 1914 1915 1916 1917 1918 //folder_info[generateCode.dLK]='initWScriptObj'; 1919 // 需同時修改if(traverseSubDirectory==folder_info.f.noNewObj)段落之return! 1920 1921 //setObjValue('folder_info.f','noNewObj=-1,files,dirs,fsize,size,Tsize=3,Tfiles,Tdirs',1); 1922 CeL.application.OS.Windows.file 1923 . 1924 /** 1925 * Get the infomation of folder 1926 * @param folder_path folder path 1927 * @param file_filter 1928 * @param traverseSubDirectory 1929 * @return 1930 * @example 1931 * var finfo=new folder_info(path or folder object,extFilter,0/1); 1932 * @deprecated 以 <a href="#.traverse_file_system">traverse_file_system</a> 代替 1933 * @memberOf CeL.application.OS.Windows.file 1934 */ 1935 folder_info=function(folder_path,file_filter,traverseSubDirectory){ 1936 var dir,filesCount,subDirectorysCount,total_size_of_files,total_size_of_this_folder,total_filesCount,total_subDirectorysCount; 1937 filesCount=subDirectorysCount=total_size_of_files=total_size_of_this_folder=total_filesCount=total_subDirectorysCount=0; 1938 if(typeof traverseSubDirectory=='undefined')traverseSubDirectory=1; 1939 1940 if(typeof folder_path=='object')dir=folder_path; 1941 else if(folder_path){ 1942 if(!folder_path.slice(-1)!=path_separator)folder_path+=path_separator; 1943 try{dir=fso.GetFolder(folder_path);}catch(e){dir=0;} 1944 } 1945 1946 if(dir){ 1947 total_subDirectorysCount=subDirectorysCount=dir.SubFolders.Count; 1948 var i,t,f=new Enumerator(dir.SubFolders); 1949 if(traverseSubDirectory||traverseSubDirectory==folder_info.f.noNewObj)for(;!f.atEnd();f.moveNext()){ 1950 i=f.item(); 1951 t=folder_info(i,file_filter,folder_info.f.noNewObj); 1952 //alert(i.path+'\n'+t[folder_info.f.size]+','+t[folder_info.f.Tfiles]+','+t[folder_info.f.Tdirs]); 1953 total_size_of_this_folder+=t[folder_info.f.size]; 1954 total_filesCount+=t[folder_info.f.Tfiles]; 1955 total_subDirectorysCount+=(t[folder_info.f.Tdirs]||0); 1956 } 1957 1958 //alert(dir.files.Count+'\n'+total_filesCount); 1959 total_filesCount+=(filesCount=dir.files.Count); 1960 f=new Enumerator(dir.files); 1961 for(;!f.atEnd();f.moveNext()){ 1962 i=f.item(); 1963 if(file_filter&&!file_filter.test(i.name))continue; 1964 //if(traverseSubDirectory!=folder_info.f.noNewObj)alert(i.name+': '+i.size+' / '+total_size_of_files); 1965 total_size_of_files+=i.size; 1966 } 1967 1968 total_size_of_this_folder+=total_size_of_files; 1969 } 1970 1971 //alert(dir.path+'\nfile filter: '+file_filter+'\n'+filesCount+','+subDirectorysCount+','+total_size_of_files+','+total_size_of_this_folder+','+total_filesCount+','+total_subDirectorysCount); 1972 if(traverseSubDirectory==folder_info.f.noNewObj) 1973 return [filesCount,subDirectorysCount,total_size_of_files,total_size_of_this_folder,total_filesCount,total_subDirectorysCount]; 1974 1975 this.files=this[folder_info.f.files]=filesCount; 1976 this.dirs=this[folder_info.f.dirs]=subDirectorysCount; 1977 this.fsize=this[folder_info.f.fsize]=total_size_of_files; 1978 this.size=this[folder_info.f.size]=total_size_of_this_folder; 1979 this.Tfiles=this[folder_info.f.Tfiles]=total_filesCount; 1980 this.Tdirs=this[folder_info.f.Tdirs]=total_subDirectorysCount; 1981 return this; 1982 }; 1983 CeL.application.OS.Windows.file 1984 . 1985 /** 1986 * <a href="#.folder_info">folder_info</a> 的 flag enumeration 1987 * @memberOf CeL.application.OS.Windows.file 1988 * @constant 1989 */ 1990 folder_info.f = { 1991 noNewObj : -1, 1992 files : 0, 1993 dirs : 1, 1994 fsize : 2, 1995 size : 3, 1996 Tsize : 3, 1997 Tfiles : 4, 1998 Tdirs : 5 1999 }; 2000 2001 2002 /* list files of folder 改編自 folder_info() 2003 var files=new listFile(path or folder object,extFilter,flag); 2004 2005 */ 2006 //listFile[generateCode.dLK]='initWScriptObj'; 2007 // 需同時修改if(flag==listFile.f.noNewObj)段落之return! 2008 2009 //setObjValue('listFile.f','ignoreCase=1',1); 2010 listFile.f={ 2011 ignoreCase:1 2012 }; 2013 2014 function listFile(folder_path, file_filter, flag) { 2015 var files = []; 2016 if (typeof flag == 'undefined') 2017 flag = 0; 2018 2019 if (typeof folder_path == 'object') 2020 dir = folder_path; 2021 else if (folder_path) { 2022 if (!folder_path.slice(-1) != path_separator) 2023 folder_path += path_separator; 2024 try { 2025 dir = fso.GetFolder(folder_path); 2026 } catch (e) { 2027 dir = 0; 2028 } 2029 } 2030 2031 if (dir) { 2032 var i, f = new Enumerator(dir.files); 2033 for (; !f.atEnd(); f.moveNext()) { 2034 i = f.item(); 2035 if (file_filter && !file_filter.test(i.name)) 2036 continue; 2037 files.push(i.name); 2038 } 2039 } 2040 2041 return files; 2042 }; 2043 2044 2045 2046 2047 2048 2049 /* 2050 in UNIX: 2051 iconv -l 2052 iconv -c -f UTF-16 -t BIG5-HKSCS function.js 2053 2054 */ 2055 CeL.application.OS.Windows.file 2056 . 2057 /** 2058 * 將編碼為fromCode之檔案fileName中所有不合編碼toCode之char以encodeFunction轉換 2059 * @param fileName 2060 * @param toCode 2061 * @param fromCode 2062 * @param encodeFunction 2063 * @return 2064 * @memberOf CeL.application.OS.Windows.file 2065 */ 2066 iconv_file = function(fileName, toCode, fromCode, encodeFunction) { 2067 return iconv(_.read_file(fileName, fromCode), toCode, 2068 encodeFunction); 2069 }; 2070 2071 CeL.application.OS.Windows.file 2072 . 2073 /* 將string text中所有不合編碼toCode之char以encodeFunction轉換 2074 convert string encoding<br/> 2075 2076 CeL.iconv('測試每個字元 abc あaいiうuえeおo','Big5') 2077 2078 TODO: 2079 一次寫入多 bytes 2080 */ 2081 //var iconvError=[]; 2082 iconv=function(text, toCode, encodeFunction) { 2083 if (!text) 2084 return ''; 2085 2086 // alert('iconv: ['+toCode+']\n'+text.slice(0,200)); 2087 if (/utf-?(8|16([bl]e)?)/i.test(toCode)) 2088 // skip Unicode 2089 return HTMLToUnicode(text, 1); 2090 2091 if (_.open_file(0, toCode || simpleFileDformat) !== 0){ 2092 // error occurred 2093 iconvError = simpleFileErr; 2094 CeL.log(iconvError.message); 2095 return text; 2096 } 2097 2098 // AdoStream.Type=AdoEnums.adTypeText; 2099 if (!encodeFunction) 2100 encodeFunction = 2101 // typeof toHTML ==='function' ? totoHTML: 2102 function(t) { 2103 return '\\u' + t.charCodeAt(0); 2104 }; 2105 // iconvError=[]; 2106 2107 var charToSet, i = 0, t = ''; 2108 // 測試每個字元 2109 for (; i < text.length; i++) 2110 try { 2111 charToSet = text.charAt(i); 2112 if (charToSet.charCodeAt(0) < 256) { 2113 // 對於 code 過小的,直接匯入以增加速度。 2114 t += charToSet; 2115 continue; 2116 } 2117 AdoStream.Position = 0; 2118 AdoStream.WriteText(charToSet); 2119 AdoStream.Position = 0; 2120 t += charToSet == AdoStream.ReadText(AdoEnums.adReadAll) ? charToSet 2121 : encodeFunction(charToSet); 2122 } catch (e) { 2123 //iconvError.push(e.description); 2124 t += encodeFunction(charToSet); 2125 } 2126 2127 try { 2128 AdoStream.Close(); 2129 } catch (e) { 2130 } 2131 return t; 2132 }; 2133 2134 2135 2136 //--------------------------------------------------- 2137 2138 2139 /* 2140 var driverProperty,folderProperty,fileProperty; 2141 setObjValue('driverProperty','AvailableSpace,DriveLetter,DriveType,FileSystem,FreeSpace,IsReady,Path,RootFolder,SerialNumber,ShareName,TotalSize,VolumeName',1,setObjValueFlag.array); 2142 setObjValue('folderProperty','Attributes,DateCreated,DateLastAccessed,DateLastModified,Drive,Name,ParentFolder,Path,ShortName,ShortPath,Size,Type,Files,IsRootFolder,SubFolders',1,setObjValueFlag.array);//Files起為Folder property 2143 fileProperty=folderProperty.slice(0,12);//folderProperty.sort(); 2144 */ 2145 2146 2147 //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'); 2148 /* 2149 2150 _.traverse_file_system(FS_function_array) 省略path會當作所有Drives 2151 _.traverse_file_system(FS_function_array,'c:') c:→c:\→sub dir of c:\ 2152 _.traverse_file_system(FS_function_array,'c:\\') c:\→sub dir of c:\ 2153 _.traverse_file_system(FS_function_array,'c:\\cc') c:\cc,cc為dir→sub dir of c:\cc\ 2154 _.traverse_file_system(FS_function_array,'c:\\cc\\') c:\cc\→sub dir of c:\cc\ 2155 _.traverse_file_system(FS_function_array,['c:\\cc\\','d:\\dd']) c:\cc\→sub dir of c:\cc\→d:\dd→sub dir of d:\dd 2156 _.traverse_file_system([,folderFunction],'.'); 2157 2158 2159 _.traverse_file_system([,folderFunction],basePath); 2160 function folderFunction(folderItem){ 2161 t=folderItem.Path.slice(same_length(basePath,folderItem.Path)); 2162 //if(t==folderItem.Name) // 僅單層subdir次目錄 2163 //if(t.indexOf(path_separator)==t.lastIndexOf(path_separator)) // 僅單層及次層subdir次目錄 2164 if(t.replace(new RegExp('[^'+path_separator_RegExp+']','g'),'').length<3) // 僅3層subdir以下 2165 ; 2166 } 2167 2168 2169 // itemType=0:file/1:folder/2:driver 2170 function fsoFunction(fsi,itemType){if(!itemType){}} 2171 function fileFunction(fileItem){} 2172 function folderFunction(folderItem){} 2173 function driverFunction(driverItem){} 2174 2175 filter: 2176 file_filter 僅單一 filter 時預設當作 file_filter, should has NO global flag. 2177 [file_filter,folder_filter] 2178 file_filter 篩選檔案, should has NO global flag. 2179 folder_filter 篩選資料夾, should has NO global flag. 2180 2181 2182 tip: 2183 使用相對路徑,如'..'開頭時需用getFP()調整過。 2184 用folder.Size==0可判別是否為empty folder 2185 2186 TODO: 2187 限定traverse深度幾層,sort=8,preOrder=0,widthFirst=0,postOrder=16,depthFirst=16 2188 */ 2189 //_.traverse_file_system.stop=false; 2190 2191 //_.traverse_file_system[generateCode.dLK]='initWScriptObj'; 2192 CeL.application.OS.Windows.file 2193 . 2194 /** 2195 * 巡覽 file system 的公用函數 2196 * @param FS_function_array file system handle function array 2197 * @param path target path 2198 * @param filter filter 2199 * @param flag see <a href="#.traverse_file_system.f">flag</a> 2200 * @return 2201 * @memberOf CeL.application.OS.Windows.file 2202 * @see <a href="http://msdn.microsoft.com/library/en-us/script56/html/0fa93e5b-b657-408d-9dd3-a43846037a0e.asp">FileSystemObject</a> 2203 */ 2204 traverse_file_system = function traverse_file_system(FS_function_array, path, filter, flag) { 2205 var _s = _.traverse_file_system, _f = _s.f; 2206 2207 // initial 2208 // 預設 flag 2209 // if(isNaN(flag))flag=_f.traverse; 2210 2211 //library_namespace.log('traverse_file_system:\n[' + path + ']'); 2212 if (FS_function_array === _f.get_object) 2213 // or FS_function_array=[,,]: 可以使用 Array 常值中的空白元素來建立零星稀疏的陣列。 2214 FS_function_array = new Array(_f.func_length), 2215 flag = _f.get_object; 2216 else { 2217 /* 2218 if (FS_function_array instanceof Array && FS_function_array.length == 1) 2219 FS_function_array = FS_function_array[0]; 2220 */ 2221 if (typeof FS_function_array === 'function') { 2222 var i = FS_function_array; 2223 FS_function_array = [ i, i, i ]; 2224 } 2225 } 2226 //library_namespace.log('traverse_file_system: fso:\n[' + fso + ']'); 2227 if (typeof fso !== 'object' || !(FS_function_array instanceof Array) 2228 || !FS_function_array.length) 2229 return; 2230 //library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']'); 2231 if (!filter) 2232 filter = []; 2233 else if (filter instanceof RegExp) 2234 // filter=[filter,filter]; 通常我們輸入的只會指定 file filter 2235 filter = [ filter, ]; 2236 else if (typeof filter !== 'object') 2237 filter = [ filter, ]; 2238 2239 //library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']'); 2240 var item, iType, fc, i, traverse = !(flag & _f.no_traverse), objBuf = [], typeBuf = [], folder_filter = filter[1], testFilter = function( 2241 f) { 2242 try { 2243 // f instanceof RegExp 2244 f.test(''); 2245 } 2246 catch (e) { 2247 // throw new Error(e.number,'traverse_file_system: 錯誤的 filter:\n'+f+'\n'+e.description); 2248 e.description = 'traverse_file_system: 錯誤的 filter:\n' + f + '\n' 2249 + e.description; 2250 throw e; 2251 } 2252 }; 2253 if (filter = filter[0]) 2254 if (typeof filter === 'string') 2255 filter = new RegExp(filter); 2256 else 2257 testFilter(filter); 2258 if (folder_filter) 2259 if (typeof folder_filter === 'string') 2260 folder_filter = new RegExp(folder_filter); 2261 else 2262 testFilter(folder_filter); 2263 // if(flag!=_f.get_object)alert(filter+'\n'+folder_filter); 2264 // 至此 filter 代表 file_filter, vs. folder_filter 2265 2266 2267 // 轉換輸入之各項成fso object 2268 if (!path) { // 取得各個driver code 2269 if (flag === _f.get_object) 2270 return; 2271 for ( var drivers = new Enumerator(fso.Drives); !drivers.atEnd(); drivers 2272 .moveNext()) 2273 objBuf.push(drivers.item()), typeBuf 2274 .push(_f.driver); 2275 objBuf.reverse(), typeBuf.reverse(); 2276 } else if (typeof path === 'object') 2277 if (path.length) { 2278 for (i = 0; i < path.length; i++) 2279 if (item = _s(_f.get_object, 2280 '' + path[i], filter, flag)) 2281 objBuf.push(item[0]), typeBuf.push(item[1]); 2282 } else { 2283 item = typeof path.IsReady !== 'undefined' ? _f.driver 2284 : typeof path.IsRootFolder !== 'undefined' ? _f.folder 2285 : typeof path.Path !== 'undefined' ? _f.file 2286 : _f.NULL; 2287 if (_f.NULL != -1) 2288 objBuf.push(path), typeBuf.push(item); 2289 } 2290 else { 2291 i = true; // fault 2292 if (i) 2293 try { 2294 objBuf.push(fso.GetFolder(path)), typeBuf 2295 .push(_f.folder), i = false; 2296 } catch (e) { 2297 }// fso.FolderExists() 2298 if (i) 2299 try { 2300 objBuf.push(fso.GetFile(path)), typeBuf 2301 .push(_f.file), i = false; 2302 } catch (e) { 2303 }// fso.FileExists() 2304 if (i && path == fso.GetDriveName(path)) 2305 try { 2306 objBuf.push(fso.GetDrive(path)), typeBuf 2307 .push(_f.driver), i = false; 2308 } catch (e) { 2309 } 2310 } 2311 if (flag == _f.get_object) 2312 return objBuf[0] ? [ objBuf[0], typeBuf[0] ] : 0; 2313 2314 // FS_function_array.length=_f.func_length; 2315 for (i = 0; i < _f.func_length; i++) 2316 // 可以安排僅對folder或是file作用之function 2317 if (typeof FS_function_array[i] !== 'function') 2318 FS_function_array[i] = function() {}; 2319 //alert(objBuf.length+','+typeBuf.length+'\n'+typeBuf); 2320 // main loop 2321 while (!_s.stop && objBuf.length) 2322 if (item = objBuf.pop()) // fsoFunction執行途中可能將此項目刪除 2323 switch (iType = typeBuf.pop()) { 2324 case _f.folder: 2325 if (!folder_filter || folder_filter.test(item.Name)) 2326 FS_function_array[iType](item, iType); 2327 // if(traverse||traverse!==0){ 2328 // if(!traverse)traverse=0; // 加上次一層: 會連這次一層之檔案都加上去。 2329 if (traverse) 2330 for (fc = new Enumerator(item.SubFolders); !fc.atEnd(); fc 2331 .moveNext()) 2332 if (i = fc.item(), !folder_filter 2333 || folder_filter.test(i.Name)) 2334 objBuf.push(i), typeBuf 2335 .push(_f.folder); 2336 // } 2337 // try 以防item已經被刪除 2338 try { 2339 fc = new Enumerator(item.Files); 2340 } catch (e) { 2341 fc = 0; 2342 } 2343 if (fc) { 2344 // for(;!fc.atEnd();fc.moveNext())if(i=fc.item(),!filter||filter.test(i.Name))FS_function_array[_f.file](i,_f.file); 2345 // 因為檔案可能因改名等改變順序,因此用.moveNext()的方法可能有些重複,有些漏掉未處理。 2346 for (item = []; !fc.atEnd(); fc.moveNext()) 2347 item.push(fc.item()); 2348 for (i in item) 2349 if (i = item[i], !filter || filter.test(i.Name)) 2350 FS_function_array[_f.file](i, 2351 _f.file); 2352 } 2353 break; 2354 case _f.file: 2355 if (!filter || filter.test(item.Name)) 2356 FS_function_array[iType](item, iType); 2357 break; 2358 case _f.driver: 2359 if (!item.IsReady) 2360 break; 2361 FS_function_array[iType](item, iType); 2362 if (traverse) 2363 objBuf.push(item.RootFolder), typeBuf 2364 .push(_f.folder); 2365 // break; 2366 //default:break; 2367 } 2368 2369 }; 2370 2371 2372 //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 2373 CeL.application.OS.Windows.file 2374 . 2375 /** 2376 * <a href="#.traverse_file_system">traverse_file_system</a> 的 flag enumeration 2377 * @memberOf CeL.application.OS.Windows.file 2378 * @constant 2379 */ 2380 traverse_file_system.f = 2381 traverse_file_system.f = { 2382 /** 2383 * return object 2384 * @memberOf CeL.application.OS.Windows.file 2385 */ 2386 get_object : -2, 2387 /** 2388 * null flag 2389 * @private 2390 * @memberOf CeL.application.OS.Windows.file 2391 */ 2392 NULL : -1, 2393 /** 2394 * 用於指示 file 2395 * @private 2396 * @memberOf CeL.application.OS.Windows.file 2397 */ 2398 file : 0, 2399 /** 2400 * 用於指示 folder 2401 * @private 2402 * @memberOf CeL.application.OS.Windows.file 2403 */ 2404 folder : 1, 2405 /** 2406 * 用於指示 driver 2407 * @private 2408 * @memberOf CeL.application.OS.Windows.file 2409 */ 2410 driver : 2, 2411 /** 2412 * handle function 應有的長度 2413 * @private 2414 * @memberOf CeL.application.OS.Windows.file 2415 */ 2416 func_length : 3, 2417 /** 2418 * 深入下層子目錄及檔案 2419 * @memberOf CeL.application.OS.Windows.file 2420 */ 2421 traverse : 0, 2422 /** 2423 * 不深入下層子目錄及檔案 2424 * @memberOf CeL.application.OS.Windows.file 2425 */ 2426 no_traverse : 4 2427 }; 2428 2429 2430 2431 2432 return ( 2433 CeL.application.OS.Windows.file 2434 ); 2435 } 2436 2437 2438 ); 2439 2440