Files
rappaurio-sae501_502/app/node_modules/cejs/_documents/JsDoc/symbols/src/D__USB_cgi-bin_lib_JS_IO_Windows_file.origin.js.html
2023-09-25 13:27:24 +02:00

2466 lines
490 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style>
.KEYW {color: #933;}
.COMM {color: #bbb; font-style: italic;}
.NUMB {color: #393;}
.STRN {color: #393;}
.REGX {color: #339;}
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
</style></head><body><pre><span class='line'> 1</span> <span class="TOKN"></span><span class="WHIT">
<span class='line'> 2</span> </span><span class="COMM">/**
<span class='line'> 3</span> * @name CeL file function for Windows
<span class='line'> 4</span> * @fileoverview
<span class='line'> 5</span> * 本檔案包含了 Windows 的 file functions。
<span class='line'> 6</span> * @since 2009/12/1
<span class='line'> 7</span> */</span><span class="WHIT">
<span class='line'> 8</span>
<span class='line'> 9</span> </span><span class="COMM">/*
<span class='line'> 10</span> * TODO
<span class='line'> 11</span> * http://www.comsharp.com/GetKnowledge/zh-CN/It_News_K869.aspx
<span class='line'> 12</span> */</span><span class="WHIT">
<span class='line'> 13</span>
<span class='line'> 14</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">CeL</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 15</span>
<span class='line'> 16</span> </span><span class="COMM">/**
<span class='line'> 17</span> * 本 module 之 name(id)&lt;span style="text-decoration:line-through;">不設定時會從呼叫時之 path 取得&lt;/span>。
<span class='line'> 18</span> * @type String
<span class='line'> 19</span> * @constant
<span class='line'> 20</span> * @inner
<span class='line'> 21</span> * @ignore
<span class='line'> 22</span> */</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'IO.Windows.file'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 24</span>
<span class='line'> 25</span> </span><span class="COMM">//===================================================</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="COMM">/**
<span class='line'> 27</span> * 若欲 include 整個 module 時,需囊括之 code。
<span class='line'> 28</span> * @type Function
<span class='line'> 29</span> * @param {Function} library_namespace namespace of library
<span class='line'> 30</span> * @param load_arguments 呼叫時之 argument(s)
<span class='line'> 31</span> * @return
<span class='line'> 32</span> * @name CeL.IO.Windows.file
<span class='line'> 33</span> * @constant
<span class='line'> 34</span> * @inner
<span class='line'> 35</span> * @ignore
<span class='line'> 36</span> */</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">library_namespace</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">load_arguments</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 38</span>
<span class='line'> 39</span>
<span class='line'> 40</span> </span><span class="COMM">/**
<span class='line'> 41</span> * null module constructor
<span class='line'> 42</span> * @class Windows 下,檔案操作相關之 function。
<span class='line'> 43</span> */</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="COMM">// null module constructor</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span>
<span class='line'> 49</span> </span><span class="COMM">/**
<span class='line'> 50</span> * for JSDT: 有 prototype 才會將之當作 Class
<span class='line'> 51</span> */</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="PUNC">.</span><span class="NAME">prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span>
<span class='line'> 56</span>
<span class='line'> 57</span>
<span class='line'> 58</span> </span><span class="COMM">/*
<span class='line'> 59</span> JScript only -------------------------------------------------------
<span class='line'> 60</span> */</span><span class="WHIT">
<span class='line'> 61</span>
<span class='line'> 62</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="COMM">/**
<span class='line'> 65</span> * FileSystemObject Object I/O mode enumeration
<span class='line'> 66</span> * @see &lt;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&lt;/a>
<span class='line'> 67</span> * @memberOf CeL.IO.Windows.file
<span class='line'> 68</span> */</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="NAME">iomode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="COMM">// * @_description &lt;a href="#.iomode">iomode&lt;/a>: Open a file for reading only. You can't write to this file.</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 72</span> * Open a file for reading only. You can't write to this file.
<span class='line'> 73</span> * @memberOf CeL.IO.Windows.file
<span class='line'> 74</span> */</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="NAME">ForReading</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 77</span> * Open a file for writing.
<span class='line'> 78</span> * @memberOf CeL.IO.Windows.file
<span class='line'> 79</span> */</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="NAME">ForWriting</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 82</span> * Open a file and write to the end of the file.
<span class='line'> 83</span> * @memberOf CeL.IO.Windows.file
<span class='line'> 84</span> */</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="NAME">ForAppending</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span>
<span class='line'> 88</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="COMM">/**
<span class='line'> 91</span> * FileSystemObject Object file open format enumeration
<span class='line'> 92</span> * @see &lt;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&lt;/a>
<span class='line'> 93</span> * @memberOf CeL.IO.Windows.file
<span class='line'> 94</span> */</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="NAME">open_format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 97</span> * Opens the file using the system default.
<span class='line'> 98</span> * @memberOf CeL.IO.Windows.file
<span class='line'> 99</span> */</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="NAME">TristateUseDefault</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>102</span> * Opens the file as Unicode.
<span class='line'>103</span> * @memberOf CeL.IO.Windows.file
<span class='line'>104</span> */</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="NAME">TristateTrue</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>107</span> * Opens the file as ASCII.
<span class='line'>108</span> * @memberOf CeL.IO.Windows.file
<span class='line'>109</span> */</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="NAME">TristateFalse</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>111</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span>
<span class='line'>113</span>
<span class='line'>114</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">library_namespace.env.path_separator</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">path_separator_RegExp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">library_namespace.env.path_separator_RegExp</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">library_namespace.env.new_line</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>115</span> </span><span class="COMM">/**
<span class='line'>116</span> * FileSystemObject
<span class='line'>117</span> * @inner
<span class='line'>118</span> * @ignore
<span class='line'>119</span> * @see
<span class='line'>120</span> * &lt;a href="http://msdn.microsoft.com/en-us/library/z9ty6h50%28VS.85%29.aspx" accessdate="2010/1/9 8:10">FileSystemObject Object&lt;/a>
<span class='line'>121</span> */</span><span class="WHIT">
<span class='line'>122</span> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WScript.CreateObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>123</span> </span><span class="COMM">// XMLHttp,</span><span class="WHIT">
<span class='line'>124</span> </span><span class="NAME">WinShell</span><span class="WHIT"> </span><span class="COMM">// initWScriptObj</span><span class="WHIT">
<span class='line'>125</span> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ScriptHost</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span>
<span class='line'>127</span>
<span class='line'>128</span> </span><span class="COMM">/* ↑JScript only -------------------------------------------------------
<span class='line'>129</span> */</span><span class="WHIT">
<span class='line'>130</span>
<span class='line'>131</span>
<span class='line'>132</span>
<span class='line'>133</span>
<span class='line'>134</span> </span><span class="COMM">/*
<span class='line'>135</span>
<span class='line'>136</span> return {Object} report
<span class='line'>137</span> .list files matched
<span class='line'>138</span> .succeed success items
<span class='line'>139</span> .failed failed items
<span class='line'>140</span> .log log text
<span class='line'>141</span> .undo undo data
<span class='line'>142</span>
<span class='line'>143</span> usage example:
<span class='line'>144</span> move_file() get file list array of current dir.
<span class='line'>145</span> move_file(0,0,'dir') get file list array of dir.
<span class='line'>146</span> move_file('*.*','*.jpg','dir') Error! Please use RegExp('.*\..*') or turnWildcardToRegExp('*.*')
<span class='line'>147</span> move_file(/file(\d+).jpg/,0,'dir') get file list array of dir/file(\d+).jpg
<span class='line'>148</span> move_file(f1,move_file.f.remove) delete f1
<span class='line'>149</span> move_file('f1','f2') [f1]->[f2]
<span class='line'>150</span> move_file('f1','f2','.',move_file.f.copy|move_file.f.reverse) copy [./f2] to [./f1]
<span class='line'>151</span> 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
<span class='line'>152</span>
<span class='line'>153</span> prog example:
<span class='line'>154</span> 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;}
<span class='line'>155</span> var vol=11,doMove=move_file(new RegExp('(\\d+)\\('+vol+'\\)\\.pdf'),'$1.pdf');
<span class='line'>156</span> write_file('move.log','-'.x(60)+new_line+doMove.log,open_format.TristateTrue,ForAppending);
<span class='line'>157</span> write_file('move.undo.'+vol+'.txt',doMove.undo,open_format.TristateTrue),write_file('move.undo.'+vol+'.bat',doMove.undo);//bat不能用open_format.TristateTrue
<span class='line'>158</span> alert('Done '+doMove.succeed+'/'+doMove.list.length);
<span class='line'>159</span>
<span class='line'>160</span> for Win98, turn lower case:
<span class='line'>161</span> move_file(/^[A-Z\d.]+$/,function($0){return '_mv_tmp_'+$0.toLowerCase();},'.',move_file.f.include_folder|move_file.f.include_subfolder);
<span class='line'>162</span> alert(move_file(/^_mv_tmp_/,'','.',move_file.f.include_folder|move_file.f.include_subfolder).log);
<span class='line'>163</span>
<span class='line'>164</span>
<span class='line'>165</span> for(var i=0,j,n,m;i&lt;40;i++)
<span class='line'>166</span> if(!fso.FileExists(n='0000'+(i>9?'':'0')+i+'.pdf'))for(j=0;j&lt;25;j++)
<span class='line'>167</span> if(fso.FileExists(m='0000'+(i>9?'':'0')+i+'('+j+').pdf')){try{fso.MoveFile(m,n);}catch(e){}break;}
<span class='line'>168</span>
<span class='line'>169</span> TODO:
<span class='line'>170</span> move newer 把新檔移到目的地,舊檔移到 bak。
<span class='line'>171</span>
<span class='line'>172</span> */</span><span class="WHIT">
<span class='line'>173</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>174</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>175</span> </span><span class="COMM">/**
<span class='line'>176</span> * move/rename files, ** use RegExp, but no global flag **&lt;br/>
<span class='line'>177</span> * 可用 move_file_filter() 來排除不要的&lt;br/>
<span class='line'>178</span> * 本函數可能暫時改變目前工作目錄!
<span class='line'>179</span> * @param {String} from from file
<span class='line'>180</span> * @param {String} to to file
<span class='line'>181</span> * @param {String} base_path base path
<span class='line'>182</span> * @param flag
<span class='line'>183</span> * @param {Function} filter 可用 filter() 來排除不要的
<span class='line'>184</span> * @return {Object} report
<span class='line'>185</span> * @since 2004/4/12 17:25
<span class='line'>186</span> * @requires path_separator,fso,WshShell,new_line,Enumerator
<span class='line'>187</span> * @memberOf CeL.IO.Windows.file
<span class='line'>188</span> */</span><span class="WHIT">
<span class='line'>189</span> </span><span class="NAME">move_file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">move_file</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">move_file.f</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">move_file</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">_.move_file</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s.f</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="COMM">// '.?': 一定會match</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'.?'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.debug(typeof from + ',' + from.constructor);</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.reverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="COMM">//flag-=_f.reverse,</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">from</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">from</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="NAME">report.list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report.succeed</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">report.failed</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="NAME">report.undo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span>
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">get_folder</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">get_folder</span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>210</span>
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="COMM">// -1, or try: base_path.length-path_separator.length</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span>
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'FSO was already seted!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="STRN">'move_file(): 基準路徑不存在\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>226</span>
<span class='line'>227</span> </span><span class="WHIT"> </span><span class="COMM">// TODO: 對from不存在與為folder之處裡: fuzzy</span><span class="WHIT">
<span class='line'>228</span>
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.include_subfolder</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WshShell.CurrentDirectory</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.SubFolders</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">i.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="COMM">// 改變目前工作目錄</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT"> </span><span class="NAME">WshShell.CurrentDirectory</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT"> </span><span class="COMM">// if(flag&_f.include_folder){}</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.Files</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">use_exact</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.overwrite</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">not_test</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.Test</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.copy</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'copy'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">_f.remove</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.remove</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'delete'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'move'</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'list'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT"> </span><span class="COMM">// if(func=='delete')to=_f.remove; // 反正不是用這個判別的</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.debug('use_exact: ' + use_exact + '\nbase_path: ' + base_path + '\nfrom: ' + from);</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="COMM">// BUG: 這樣順序會亂掉,使得 traverse (遍歷)不完全</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">use_exact</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">i.Name</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">use_exact</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">from.test</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT"> </span><span class="NAME">report.list.push</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>251</span>
<span class='line'>252</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">filter</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'copy'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'move'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">i.Name.replace</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">to.source</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>256</span>
<span class='line'>257</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i.Name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">' to ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'] '</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'delete'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">not_test</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT"> </span><span class="NAME">i.Delete</span><span class="PUNC">(</span><span class="NAME">overwrite</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">not_test</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT"> </span><span class="NAME">fso.DeleteFile</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'copy'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT"> </span><span class="COMM">// Copy() 用的是 FileSystemObject.CopyFile or FileSystemObject.CopyFolder, 亦可用萬用字元(wildcard characters)</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT"> </span><span class="NAME">i.Copy</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT"> </span><span class="NAME">i.Move</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT"> </span><span class="NAME">u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'move '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i.Name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">': target existing, '</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'succeed.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT"> </span><span class="NAME">report.undo</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report.succeed</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'failed.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report.failed</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.debug(i.Name + ',' + t);</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>289</span>
<span class='line'>290</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.include_subfolder</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT"> </span><span class="NAME">WshShell.CurrentDirectory</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">not_test</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'(test)'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' ['</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'] to ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">gDate</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">gDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'done '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">report.succeed</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">report.list.length</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">report</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>298</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>299</span>
<span class='line'>300</span> </span><span class="COMM">//var move_file.f;</span><span class="WHIT">
<span class='line'>301</span> </span><span class="COMM">//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');</span><span class="WHIT">
<span class='line'>302</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>303</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>304</span> </span><span class="COMM">/**
<span class='line'>305</span> * &lt;a href="#.move_file">move_file&lt;/a> 的 flag enumeration
<span class='line'>306</span> * @constant
<span class='line'>307</span> * @memberOf CeL.IO.Windows.file
<span class='line'>308</span> */</span><span class="WHIT">
<span class='line'>309</span> </span><span class="NAME">move_file.f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>311</span> * null flag
<span class='line'>312</span> * @memberOf CeL.IO.Windows.file
<span class='line'>313</span> */</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT"> </span><span class="NAME">none</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>316</span> * overwrite target
<span class='line'>317</span> * @memberOf CeL.IO.Windows.file
<span class='line'>318</span> */</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>321</span> * If source don't exist but target exist, than reverse.
<span class='line'>322</span> * @deprecated TODO
<span class='line'>323</span> * @memberOf CeL.IO.Windows.file
<span class='line'>324</span> */</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT"> </span><span class="NAME">fuzzy</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>327</span> * reverse source and target
<span class='line'>328</span> * @memberOf CeL.IO.Windows.file
<span class='line'>329</span> */</span><span class="WHIT">
<span class='line'>330</span> </span><span class="WHIT"> </span><span class="NAME">reverse</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>332</span> * include folder
<span class='line'>333</span> * @memberOf CeL.IO.Windows.file
<span class='line'>334</span> */</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT"> </span><span class="NAME">include_folder</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>337</span> * include sub-folder
<span class='line'>338</span> * @memberOf CeL.IO.Windows.file
<span class='line'>339</span> */</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT"> </span><span class="NAME">include_subfolder</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>342</span> * Just do a test
<span class='line'>343</span> * @memberOf CeL.IO.Windows.file
<span class='line'>344</span> */</span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT"> </span><span class="NAME">Test</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>347</span> * copy, instead of move the file
<span class='line'>348</span> * @memberOf CeL.IO.Windows.file
<span class='line'>349</span> */</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT"> </span><span class="NAME">copy</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>352</span> * 當 target 指定此 flag或包含此 flag 而未指定 target 時remove the source。
<span class='line'>353</span> * @memberOf CeL.IO.Windows.file
<span class='line'>354</span> */</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT"> </span><span class="NAME">remove</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">128</span><span class="WHIT">
<span class='line'>356</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>357</span>
<span class='line'>358</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>359</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>360</span> </span><span class="COMM">/**
<span class='line'>361</span> * move file
<span class='line'>362</span> * @requires fso,get_folder,get_file_name,initWScriptObj
<span class='line'>363</span> * @memberOf CeL.IO.Windows.file
<span class='line'>364</span> */</span><span class="WHIT">
<span class='line'>365</span> </span><span class="NAME">move_1_file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">only_filename</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reverse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>366</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'filename error.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>368</span>
<span class='line'>369</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">get_folder</span><span class="PUNC">(</span><span class="NAME">dir</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>371</span>
<span class='line'>372</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">reverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">_i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">_i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">only_filename</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">get_file_name</span><span class="PUNC">(</span><span class="NAME">_i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>378</span>
<span class='line'>379</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.debug('move_1_file:\n' + dir + '\n\n' + e(from) + '\n→\n' + e(to));</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT"> </span><span class="NAME">fso.MoveFile</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">(</span><span class="NAME">to</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>384</span> </span><span class="WHIT"> </span><span class="NAME">e.message</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'move_1_file:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n→\n'</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">to</span><span class="COMM">// +'\n\n'+e.message</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>389</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>390</span>
<span class='line'>391</span>
<span class='line'>392</span> </span><span class="COMM">/*
<span class='line'>393</span> function mv(from,to,dir,only_filename,reverse){
<span class='line'>394</span> var e,_f,_t;
<span class='line'>395</span> dir=get_folder(dir);
<span class='line'>396</span>
<span class='line'>397</span> if(reverse)e=from,from=to,to=e;
<span class='line'>398</span> _f=from;
<span class='line'>399</span> _t=to;
<span class='line'>400</span> to=0;
<span class='line'>401</span> e=function(_i){
<span class='line'>402</span> return fso.FileExists(_i)?_i:dir&&fso.FileExists(_i=dir+(only_filename?get_file_name(_i):_i))?_i:0;
<span class='line'>403</span> };
<span class='line'>404</span>
<span class='line'>405</span> try{
<span class='line'>406</span> if(!(_f=e(_f)))to=1;else if(!(_t=e(_t)))to=2;
<span class='line'>407</span> else{
<span class='line'>408</span> alert('mv():\n'+dir+'\n\n'+_f+'\n→\n'+_t);
<span class='line'>409</span> fso.MoveFile(_f,_t);
<span class='line'>410</span> return;
<span class='line'>411</span> }
<span class='line'>412</span> }catch(e){return e;}
<span class='line'>413</span> return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t);
<span class='line'>414</span> }
<span class='line'>415</span>
<span class='line'>416</span>
<span class='line'>417</span> function mv(from,to,dir,only_filename,reverse){
<span class='line'>418</span> var e,_f,_t;
<span class='line'>419</span> dir=get_folder(dir);
<span class='line'>420</span>
<span class='line'>421</span> if(reverse)e=from,from=to,to=e;
<span class='line'>422</span> _f=from,_t=to,to=e=0;
<span class='line'>423</span>
<span class='line'>424</span> try{
<span class='line'>425</span> if(!fso.FileExists(_f)&&(!dir||!fso.FileExists(_f=dir+(only_filename?get_file_name(_f):_f))))to=1;
<span class='line'>426</span> else if(fso.FileExists(_t)&&(!dir||fso.FileExists(_t=dir+(only_filename?get_file_name(_t):_t))))to=2;
<span class='line'>427</span> else{
<span class='line'>428</span> alert('mv():\n'+dir+'\n'+_f+'\n→\n'+_t);
<span class='line'>429</span> //fso.MoveFile(_f,_t);
<span class='line'>430</span> return;
<span class='line'>431</span> }
<span class='line'>432</span> }catch(e){}
<span class='line'>433</span> return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t);
<span class='line'>434</span> }
<span class='line'>435</span>
<span class='line'>436</span> */</span><span class="WHIT">
<span class='line'>437</span>
<span class='line'>438</span>
<span class='line'>439</span> </span><span class="COMM">/*
<span class='line'>440</span>
<span class='line'>441</span> 下面一行調到檔案頭
<span class='line'>442</span> var get_file_details_items,get_file_details_get_object=-62.262;
<span class='line'>443</span> */</span><span class="WHIT">
<span class='line'>444</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>445</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>446</span> </span><span class="COMM">/**
<span class='line'>447</span> * get file details (readonly)
<span class='line'>448</span> * @example
<span class='line'>449</span> * get_file_details('path');
<span class='line'>450</span> * get_file_details('file/folder name',parentDir);
<span class='line'>451</span> * get_file_details('path',get_file_details_get_object);
<span class='line'>452</span> * @see &lt;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)&lt;/a>
<span class='line'>453</span> * @memberOf CeL.IO.Windows.file
<span class='line'>454</span> */</span><span class="WHIT">
<span class='line'>455</span> </span><span class="NAME">get_file_details</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fileObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT"> </span><span class="COMM">// WinShell=new ActiveXObject("Shell.Application");</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WinShell</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fileObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>460</span>
<span class='line'>461</span> </span><span class="WHIT"> </span><span class="COMM">// deal with fileObj & parentDirObj</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">get_file_details_get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="COMM">// else n='';</span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">parentDirObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT"> </span><span class="COMM">// fileObj is path</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fileObj.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fileObj.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT">
<span class='line'>471</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>476</span> </span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WinShell.NameSpace</span><span class="PUNC">(</span><span class="NAME">parentDirObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>477</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parentDirObj.ParseName</span><span class="PUNC">(</span><span class="NAME">fileObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT"> </span><span class="COMM">// just get [(object)parentDirObj,(object)fileObj]</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>482</span>
<span class='line'>483</span> </span><span class="WHIT"> </span><span class="COMM">// get item name</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">get_file_details_items</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT"> </span><span class="NAME">get_file_details_items</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">99</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT"> </span><span class="COMM">// scan cols</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WinShell.NameSpace</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">GetDetailsOf</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT"> </span><span class="NAME">get_file_details_items</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>491</span>
<span class='line'>492</span> </span><span class="WHIT"> </span><span class="COMM">// main process</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT"> </span><span class="COMM">//for(i=0,r=[];i&lt;get_file_details_items.length;i++)</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">get_file_details_items</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT"> </span><span class="COMM">//if(get_file_details_items[i])</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">get_file_details_items</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">GetDetailsOf</span><span class="PUNC">(</span><span class="NAME">fileObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>500</span>
<span class='line'>501</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>502</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span>
<span class='line'>504</span>
<span class='line'>505</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>506</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>507</span> </span><span class="COMM">/**
<span class='line'>508</span> * FileSystemObject Object Attributes Property
<span class='line'>509</span> * @see
<span class='line'>510</span> * &lt;a href="http://msdn.microsoft.com/en-us/library/5tx15443%28VS.85%29.aspx" accessdate="2010/1/9 8:11">Attributes Property&lt;/a>
<span class='line'>511</span> * @memberOf CeL.IO.Windows.file
<span class='line'>512</span> * @since 2010/1/9 08:33:36
<span class='line'>513</span> */</span><span class="WHIT">
<span class='line'>514</span> </span><span class="NAME">fso_attributes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>516</span> * Default. No attributes are set.
<span class='line'>517</span> * @memberOf CeL.IO.Windows.file
<span class='line'>518</span> */</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT"> </span><span class="NAME">none</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>521</span> * Normal file. No attributes are set.
<span class='line'>522</span> * @memberOf CeL.IO.Windows.file
<span class='line'>523</span> */</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT"> </span><span class="NAME">Normal</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>526</span> * Read-only file. Attribute is read/write.
<span class='line'>527</span> * @memberOf CeL.IO.Windows.file
<span class='line'>528</span> */</span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT"> </span><span class="NAME">ReadOnly</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>531</span> * Hidden file. Attribute is read/write.
<span class='line'>532</span> * @memberOf CeL.IO.Windows.file
<span class='line'>533</span> */</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT"> </span><span class="NAME">Hidden</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>536</span> * System file. Attribute is read/write.
<span class='line'>537</span> * @memberOf CeL.IO.Windows.file
<span class='line'>538</span> */</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT"> </span><span class="NAME">System</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>541</span> * Disk drive volume label. Attribute is read-only.
<span class='line'>542</span> * @memberOf CeL.IO.Windows.file
<span class='line'>543</span> */</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT"> </span><span class="NAME">Volume</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>546</span> * Folder or directory. Attribute is read-only.
<span class='line'>547</span> * @memberOf CeL.IO.Windows.file
<span class='line'>548</span> */</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT"> </span><span class="NAME">Directory</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>551</span> * File has changed since last backup. Attribute is read/write.
<span class='line'>552</span> * @memberOf CeL.IO.Windows.file
<span class='line'>553</span> */</span><span class="WHIT">
<span class='line'>554</span> </span><span class="WHIT"> </span><span class="NAME">Archive</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>555</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>556</span> * Link or shortcut. Attribute is read-only.
<span class='line'>557</span> * @memberOf CeL.IO.Windows.file
<span class='line'>558</span> */</span><span class="WHIT">
<span class='line'>559</span> </span><span class="WHIT"> </span><span class="NAME">Alias</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1024</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>560</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>561</span> * Compressed file. Attribute is read-only.
<span class='line'>562</span> * @memberOf CeL.IO.Windows.file
<span class='line'>563</span> */</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT"> </span><span class="NAME">Compressed</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2048</span><span class="WHIT">
<span class='line'>565</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>566</span>
<span class='line'>567</span> </span><span class="COMM">// reverse map</span><span class="WHIT">
<span class='line'>568</span> </span><span class="NAME">_.fso_attributes_reverse</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>569</span> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">_.fso_attributes</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'none'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>571</span> </span><span class="WHIT"> </span><span class="NAME">_.fso_attributes_reverse</span><span class="PUNC">[</span><span class="NAME">_.fso_attributes</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>572</span>
<span class='line'>573</span> </span><span class="COMM">/*
<span class='line'>574</span> TODO
<span class='line'>575</span> 未來change_attributes(path,'-ReadOnly&-Hidden&-System')
<span class='line'>576</span>
<span class='line'>577</span> 下面調到檔案頭
<span class='line'>578</span> setObjValue('Attribute','Normal=0,none=0,ReadOnly=1,Hidden=2,System=4,Volume=8,Directory=16,Archive=32,Alias=64,Compressed=128','int');
<span class='line'>579</span> setObjValue('AttributeV','0=Normal,1=ReadOnly,2=Hidden,4=System,8=Volume,16=Directory,32=Archive,64=Alias,128=Compressed');
<span class='line'>580</span> */</span><span class="WHIT">
<span class='line'>581</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>582</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>583</span> </span><span class="COMM">/**
<span class='line'>584</span> * 改變檔案之屬性。
<span class='line'>585</span> * chmod @ UNIX
<span class='line'>586</span> * @param F file path
<span class='line'>587</span> * @param A attributes, 屬性
<span class='line'>588</span> * @example
<span class='line'>589</span> * change_attributes(path,'-ReadOnly');
<span class='line'>590</span> * @memberOf CeL.IO.Windows.file
<span class='line'>591</span> */</span><span class="WHIT">
<span class='line'>592</span> </span><span class="NAME">change_attributes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">F</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>593</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">F</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>594</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>595</span>
<span class='line'>596</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>597</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>598</span> </span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">F</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>599</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>600</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>601</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>602</span>
<span class='line'>603</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>604</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>605</span> </span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">F.Attributes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>606</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>607</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>608</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>609</span>
<span class='line'>610</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>612</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Archive'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>613</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>614</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Normal'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>615</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>616</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">A</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>617</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A.charAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'x'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">A.charAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>618</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">_.fso_attributes</span><span class="PUNC">[</span><span class="NAME">A.substr</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>620</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>621</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>622</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.fso_attributes</span><span class="PUNC">[</span><span class="NAME">A</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>626</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_.fso_attributes_reverse</span><span class="PUNC">[</span><span class="NAME">A</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>627</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>630</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>631</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_.fso_attributes_reverse</span><span class="PUNC">[</span><span class="PUNC">-</span><span class="NAME">A</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>632</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>633</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>634</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>635</span> </span><span class="WHIT"> </span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>636</span>
<span class='line'>637</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>638</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>639</span> </span><span class="WHIT"> </span><span class="NAME">F.Attributes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>640</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>641</span> </span><span class="WHIT"> </span><span class="COMM">//popErr(e);</span><span class="WHIT">
<span class='line'>642</span> </span><span class="WHIT"> </span><span class="NAME">library_namespace.err</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>643</span> </span><span class="WHIT"> </span><span class="COMM">// 70防寫沒有使用權限</span><span class="WHIT">
<span class='line'>644</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">70</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">8</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">9</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>645</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>646</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">F.Attributes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>647</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>648</span>
<span class='line'>649</span>
<span class='line'>650</span>
<span class='line'>651</span>
<span class='line'>652</span>
<span class='line'>653</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>654</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>655</span> </span><span class="COMM">/**
<span class='line'>656</span> * 開檔處理&lt;br/>
<span class='line'>657</span> * 測試是否已開啟資料檔之測試與重新開啟資料檔
<span class='line'>658</span> * @param FN file name
<span class='line'>659</span> * @param NOTexist if NOT need exist
<span class='line'>660</span> * @param io_mode IO mode
<span class='line'>661</span> * @return
<span class='line'>662</span> * @requires fso,WshShell,iomode
<span class='line'>663</span> * @memberOf CeL.IO.Windows.file
<span class='line'>664</span> */</span><span class="WHIT">
<span class='line'>665</span> </span><span class="NAME">openDataTest</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NOTexist</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>666</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>667</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>668</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">NOTexist</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>669</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>670</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>671</span> </span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForAppending</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>672</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="PUNC">;</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>673</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>674</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ForAppending</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>675</span> </span><span class="WHIT"> </span><span class="NAME">Fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>678</span> </span><span class="WHIT"> </span><span class="COMM">// 對執行時檔案已經開啟之處理</span><span class="WHIT">
<span class='line'>679</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof e=='object'&&e.number&&(e.number&0xFFFF)==70)</span><span class="WHIT">
<span class='line'>680</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">70</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>681</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>682</span> </span><span class="WHIT"> </span><span class="STRN">'開啟資料檔 [&lt;green>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;\/>] 時發生錯誤!'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>683</span> </span><span class="WHIT"> </span><span class="NUMB">6</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>684</span> </span><span class="WHIT"> </span><span class="STRN">'開啟資料檔 ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']時發生不明錯誤,\n 是否中止執行?'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>685</span> </span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ScriptName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 測試是否已開啟資料檔:發生不明錯誤!'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>686</span> </span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>687</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">WshShell.Popup</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>689</span> </span><span class="WHIT"> </span><span class="STRN">'★資料檔:\n\ '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n 無法寫入!\n\n可能原因與解決方法\n ①資料檔已被開啟。執行程式前請勿以其他程式開啟資料檔!\n ②資料檔被設成唯讀,請取消唯讀屬性。'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>690</span> </span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ScriptName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">':資料檔開啟發生錯誤!'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>691</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>692</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>693</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>694</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>695</span>
<span class='line'>696</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>697</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>698</span> </span><span class="COMM">/**
<span class='line'>699</span> *
<span class='line'>700</span> * @param FN
<span class='line'>701</span> * @param format
<span class='line'>702</span> * @param io_mode
<span class='line'>703</span> * @return
<span class='line'>704</span> */</span><span class="WHIT">
<span class='line'>705</span> </span><span class="NAME">open_template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>707</span> * file
<span class='line'>708</span> * @inner
<span class='line'>709</span> * @ignore
<span class='line'>710</span> */</span><span class="WHIT">
<span class='line'>711</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>712</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>713</span> * file streams
<span class='line'>714</span> * @inner
<span class='line'>715</span> * @ignore
<span class='line'>716</span> */</span><span class="WHIT">
<span class='line'>717</span> </span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>719</span> </span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>720</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT"> </span><span class="COMM">//format=autodetectEncode(FN);</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_format.TristateUseDefault</span><span class="PUNC">;</span><span class="COMM">// TristateTrue</span><span class="WHIT">
<span class='line'>723</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>724</span> </span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>725</span> </span><span class="WHIT"> </span><span class="COMM">//Fs=_.open_file(FN,format,io_mode);</span><span class="WHIT">
<span class='line'>726</span> </span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">F.OpenAsTextStream</span><span class="PUNC">(</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>728</span> </span><span class="WHIT"> </span><span class="COMM">// 指定的檔案不存在?</span><span class="WHIT">
<span class='line'>729</span> </span><span class="WHIT"> </span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT"> </span><span class="COMM">// quit();</span><span class="WHIT">
<span class='line'>731</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>732</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>733</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>734</span>
<span class='line'>735</span> </span><span class="COMM">//var openOut.f; // default format</span><span class="WHIT">
<span class='line'>736</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">openOut</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">OUT</span><span class="PUNC">,</span><span class="NAME">OUTs</span><span class="PUNC">,</span><span class="NAME">_f</span><span class="PUNC">=</span><span class="NAME">openOut.f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>738</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="NAME">io_mode</span><span class="PUNC">=</span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>739</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">format</span><span class="PUNC">)</span><span class="NAME">format</span><span class="PUNC">=</span><span class="NAME">_f</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">&&</span><span class="NAME">_f</span><span class="PUNC">?</span><span class="NAME">_f</span><span class="PUNC">:</span><span class="NAME">_.open_format.TristateUseDefault</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>740</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>741</span> </span><span class="WHIT"> </span><span class="NAME">OUT</span><span class="PUNC">=</span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>742</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>743</span> </span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>744</span> </span><span class="WHIT"> </span><span class="COMM">//指定的檔案不存在</span><span class="WHIT">
<span class='line'>745</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="PUNC">=</span><span class="NAME">fso.CreateTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT"> </span><span class="NAME">tmp.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>747</span> </span><span class="WHIT"> </span><span class="NAME">OUT</span><span class="PUNC">=</span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>748</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>749</span>
<span class='line'>750</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">OUTs</span><span class="PUNC">=</span><span class="NAME">OUT.OpenAsTextStream</span><span class="PUNC">(</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>751</span>
<span class='line'>752</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">OUTs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>753</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>754</span>
<span class='line'>755</span>
<span class='line'>756</span>
<span class='line'>757</span>
<span class='line'>758</span>
<span class='line'>759</span>
<span class='line'>760</span>
<span class='line'>761</span> </span><span class="COMM">// 2007/5/31 21:5:16</span><span class="WHIT">
<span class='line'>762</span> </span><span class="NAME">compressF.tool</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT"> </span><span class="NAME">WinRAR</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">path</span><span class="PUNC">:</span><span class="STRN">'"%ProgramFiles%\\WinRAR\\WinRAR.exe"'</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">:</span><span class="STRN">'rar'</span><span class="WHIT">
<span class='line'>764</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $s $archive -- $files'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'a'</span><span class="WHIT"> </span><span class="COMM">// cL:command line, c:compress, s:switch</span><span class="WHIT">
<span class='line'>765</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">:</span><span class="STRN">'-u -dh -m5 -os -r -ts'</span><span class="WHIT"> </span><span class="COMM">// -rr1p -s&lt;N> -ap -as -ep1 -tl -x&lt;f> -x@&lt;lf> -z&lt;f> -p[p] -hp[p] // rar等</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT"> </span><span class="COMM">//,l:'-ilog logFN'</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>768</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">u</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive $eF $eTo'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'e'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// uncompress</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">t</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'t'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// test</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="STRN">'7-Zip'</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">path</span><span class="PUNC">:</span><span class="STRN">'"%ProgramFiles%\\7-Zip\\7zg.exe"'</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">:</span><span class="STRN">'7z'</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $s $archive $files'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'u'</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">:</span><span class="STRN">'-mx9 -ms -mhe -mmt -uy2'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// compress</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">u</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive $eF $_e'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'e'</span><span class="PUNC">,</span><span class="NAME">_e</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fO.eTo</span><span class="PUNC">?</span><span class="STRN">'-o'</span><span class="PUNC">+</span><span class="NAME">fO.eTo</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// uncompress</span><span class="WHIT">
<span class='line'>774</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">t</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'t'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// test</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>776</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>777</span> </span><span class="COMM">/*
<span class='line'>778</span> test:
<span class='line'>779</span> var base='C:\\kanashimi\\www\\cgi-bin\\program\\misc\\';
<span class='line'>780</span> compress(base+'jit','_jit.htm',{tool:'7-Zip',s:''});
<span class='line'>781</span> uncompress(base+'jit',base,{tool:'7-Zip'});
<span class='line'>782</span>
<span class='line'>783</span>
<span class='line'>784</span> fO={
<span class='line'>785</span> tool:'WinRAR' // or '7-Zip'
<span class='line'>786</span> ,m:'c' // method
<span class='line'>787</span> ,s:'' // switch
<span class='line'>788</span> ,archive:'' // archive file
<span class='line'>789</span> ,files='' // what to compress
<span class='line'>790</span> ,eTo='' // where to uncompress
<span class='line'>791</span> ,eF='' // what to uncompress
<span class='line'>792</span> ,rcL=1 // rebuild command line
<span class='line'>793</span> }
<span class='line'>794</span> */</span><span class="WHIT">
<span class='line'>795</span> </span><span class="COMM">// solid, overwrite, compressLevel, password</span><span class="WHIT">
<span class='line'>796</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">compressF</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// flags object</span><span class="WHIT">
<span class='line'>797</span> </span><span class="WHIT"> </span><span class="COMM">// 參數檢查: 未完全</span><span class="WHIT">
<span class='line'>798</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="NAME">fO</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>799</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fO</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>800</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.tool</span><span class="PUNC">)</span><span class="NAME">fO.tool</span><span class="PUNC">=</span><span class="STRN">'WinRAR'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>801</span> </span><span class="WHIT"> </span><span class="COMM">//if(!fO.m)fO.m='c';//method</span><span class="WHIT">
<span class='line'>802</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.m</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="NAME">fO.archive</span><span class="PUNC">&&</span><span class="PUNC">(</span><span class="NAME">fO.m</span><span class="PUNC">!=</span><span class="STRN">'c'</span><span class="PUNC">||</span><span class="NAME">fO.m</span><span class="PUNC">==</span><span class="STRN">'c'</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">fO.files</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>803</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">fO.m</span><span class="PUNC">==</span><span class="STRN">'c'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>804</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fO.files</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="NAME">fO.files</span><span class="PUNC">=</span><span class="NAME">fO.files</span><span class="PUNC">?</span><span class="PUNC">[</span><span class="NAME">fO.files</span><span class="PUNC">]</span><span class="PUNC">:</span><span class="NAME">fO.archive.replace</span><span class="PUNC">(</span><span class="REGX">/\..+$/</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>805</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.archive</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">=</span><span class="NAME">fO.files</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/[\\\/]$/</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="NAME">_t.ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>806</span> </span><span class="WHIT"> </span><span class="NAME">fO.files</span><span class="PUNC">=</span><span class="STRN">'"'</span><span class="PUNC">+</span><span class="NAME">fO.files.join</span><span class="PUNC">(</span><span class="STRN">'" "'</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>807</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>808</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="NAME">_t</span><span class="PUNC">=</span><span class="NAME">compressF.tool</span><span class="PUNC">[</span><span class="NAME">fO.tool</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="NAME">_m</span><span class="PUNC">,</span><span class="NAME">_c</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>809</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">_t</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">_m</span><span class="PUNC">=</span><span class="NAME">_t</span><span class="PUNC">[</span><span class="NAME">fO.m</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>810</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="REGX">/\.[a-z]+$/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">fO.archive</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="STRN">'.'</span><span class="PUNC">+</span><span class="NAME">_t.ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>811</span> </span><span class="WHIT"> </span><span class="COMM">//if(fO.bD)fO.archive=fO.bD+(/[\\\/]$/.test(fO.bD)?'':'\\')+fO.archive; // base directory, work directory, base folder</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="REGX">/["']/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">fO.archive</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">=</span><span class="STRN">'"'</span><span class="PUNC">+</span><span class="NAME">fO.archive</span><span class="PUNC">+</span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT"> </span><span class="COMM">//alert('compressF(): check OK.');</span><span class="WHIT">
<span class='line'>814</span> </span><span class="WHIT"> </span><span class="COMM">// 構築 command line</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_m._cL</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">fO.rcL</span><span class="PUNC">)</span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_m._cL</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// rebuild command line</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>817</span> </span><span class="WHIT"> </span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_m.cL.replace</span><span class="PUNC">(</span><span class="REGX">/\$path/</span><span class="PUNC">,</span><span class="NAME">_t.path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>818</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">_m</span><span class="PUNC">)</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fO</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_c.replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'\\$'</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">_m</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">?</span><span class="NAME">_m</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="NAME">_m</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">||</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT"> </span><span class="NAME">_m._cL</span><span class="PUNC">=</span><span class="NAME">_c</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT"> </span><span class="COMM">//alert('compressF():\n'+_c);</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">fO</span><span class="PUNC">)</span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_c.replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'\\$'</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">fO</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">||</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_c.indexOf</span><span class="PUNC">(</span><span class="STRN">'$'</span><span class="PUNC">)</span><span class="PUNC">!=</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">'compressF() error:\n'</span><span class="PUNC">+</span><span class="NAME">_c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT"> </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">'compressF() '</span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">_c.indexOf</span><span class="PUNC">(</span><span class="STRN">'$'</span><span class="PUNC">)</span><span class="PUNC">==</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">?</span><span class="STRN">'run'</span><span class="PUNC">:</span><span class="STRN">'error'</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">':\n'</span><span class="PUNC">+</span><span class="NAME">_c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT"> </span><span class="COMM">// run</span><span class="WHIT">
<span class='line'>826</span> </span><span class="WHIT"> </span><span class="NAME">WshShell.Run</span><span class="PUNC">(</span><span class="NAME">_c</span><span class="PUNC">,</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>827</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>828</span> </span><span class="COMM">//compress[generateCode.dLK]='compressF';</span><span class="WHIT">
<span class='line'>829</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">compress</span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">,</span><span class="NAME">files</span><span class="PUNC">,</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// compress file path, what to compress, flags object</span><span class="WHIT">
<span class='line'>830</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="NAME">fO</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fO</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>831</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.m</span><span class="PUNC">)</span><span class="NAME">fO.m</span><span class="PUNC">=</span><span class="STRN">'c'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>832</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">=</span><span class="NAME">archive</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>833</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">files</span><span class="PUNC">)</span><span class="NAME">fO.files</span><span class="PUNC">=</span><span class="NAME">files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>834</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">compressF</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>835</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>836</span> </span><span class="COMM">//uncompress[generateCode.dLK]='uncompressF';</span><span class="WHIT">
<span class='line'>837</span> </span><span class="COMM">/**
<span class='line'>838</span> * uncompress archive
<span class='line'>839</span> * @param archive compressed file path
<span class='line'>840</span> * @param eTo where to uncompress/target
<span class='line'>841</span> * @param {Object} flag flags
<span class='line'>842</span> * @returns
<span class='line'>843</span> */</span><span class="WHIT">
<span class='line'>844</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">uncompress</span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">eTo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>845</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">flag</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>846</span> </span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>849</span>
<span class='line'>850</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">flag.m</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>851</span> </span><span class="WHIT"> </span><span class="NAME">flag.m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'u'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>852</span>
<span class='line'>853</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">flag.eF</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>854</span> </span><span class="WHIT"> </span><span class="NAME">flag.eF</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>855</span>
<span class='line'>856</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>857</span> </span><span class="WHIT"> </span><span class="NAME">flag.archive</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">archive</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>858</span>
<span class='line'>859</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">eTo</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>860</span> </span><span class="WHIT"> </span><span class="NAME">flag.eTo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eTo</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>861</span>
<span class='line'>862</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">compressF</span><span class="PUNC">(</span><span class="NAME">flag</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>863</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>864</span>
<span class='line'>865</span>
<span class='line'>866</span>
<span class='line'>867</span>
<span class='line'>868</span>
<span class='line'>869</span>
<span class='line'>870</span>
<span class='line'>871</span> </span><span class="COMM">/*
<span class='line'>872</span> 轉換捷徑, 傳回shortcut的Object. true path
<span class='line'>873</span> http://msdn2.microsoft.com/en-us/library/xk6kst2k.aspx
<span class='line'>874</span> http://yuriken.hp.infoseek.co.jp/index3.html
<span class='line'>875</span> */</span><span class="WHIT">
<span class='line'>876</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>877</span> </span><span class="COMM">//dealShortcut[generateCode.dLK]='initWScriptObj';//,parseINI</span><span class="WHIT">
<span class='line'>878</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">dealShortcut</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">,</span><span class="NAME">rtPath</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>879</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">!=</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="NAME">path</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>880</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="REGX">/\.(lnk|url)$/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>881</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sc</span><span class="PUNC">=</span><span class="NAME">WshShell.CreateShortcut</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">sc.TargetPath</span><span class="PUNC">,</span><span class="NAME">_i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>882</span> </span><span class="WHIT"> </span><span class="COMM">// 檔名有可能是不被容許的字元(不一定總是有'?'),這時只有.url以文字儲存還讀得到。</span><span class="WHIT">
<span class='line'>883</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="COMM">/*(''+sc).indexOf('?')!=-1*/</span><span class="PUNC">!</span><span class="NAME">p</span><span class="PUNC">&&</span><span class="REGX">/\.url$/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">parseINI</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>884</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">parseINI</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">,</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>885</span> </span><span class="WHIT"> </span><span class="NAME">sc</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="NAME">_emu</span><span class="PUNC">:</span><span class="NAME">p</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>886</span> </span><span class="WHIT"> </span><span class="NAME">sc.TargetPath</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">p.InternetShortcut</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">URL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>887</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">_i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">)</span><span class="NAME">sc</span><span class="PUNC">[</span><span class="NAME">_i</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">_i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>888</span> </span><span class="COMM">/*
<span class='line'>889</span> URL File Format (.url) http://www.cyanwerks.com/file-format-url.html
<span class='line'>890</span> [DEFAULT]
<span class='line'>891</span> BASEURL=http://so.7walker.net/guide.php
<span class='line'>892</span> [DOC#n(#n#n#n…)]
<span class='line'>893</span> [DOC#4#5]
<span class='line'>894</span> BASEURL=http://www.someaddress.com/frame2.html
<span class='line'>895</span> [DOC_adjustiframe]
<span class='line'>896</span> BASEURL=http://so.7walker.net/guide.php
<span class='line'>897</span> ORIGURL=http://so.7walker.net/guide.php
<span class='line'>898</span> [InternetShortcut]
<span class='line'>899</span> URL=http://so.7walker.net/guide.php
<span class='line'>900</span> Modified=50A8FD7702D1C60106
<span class='line'>901</span> WorkingDirectory=C:\WINDOWS\
<span class='line'>902</span> ShowCommand= // 規定Internet Explorer啟動後窗口的初始狀態7表示最小化3表示最大化如果沒有ShowCommand這一項的話則表示正常大小。
<span class='line'>903</span> IconIndex=1 // IconFile和IconIndex用來為Internet快捷方式指定圖標
<span class='line'>904</span> IconFile=C:\WINDOWS\SYSTEM\url.dll
<span class='line'>905</span> Hotkey=1601
<span class='line'>906</span>
<span class='line'>907</span> Hotkey:
<span class='line'>908</span> 下面加起來: Fn 單獨 || (Fn || base) 擇一 + additional 擇2~3
<span class='line'>909</span> base:
<span class='line'>910</span> 0=0x30(ASCII)
<span class='line'>911</span> 9=0x39(ASCII)
<span class='line'>912</span> A=0x41(ASCII)
<span class='line'>913</span> Z=0x5a(ASCII)
<span class='line'>914</span> ;=0xba
<span class='line'>915</span> =
<span class='line'>916</span> ,
<span class='line'>917</span> -
<span class='line'>918</span> .
<span class='line'>919</span> /
<span class='line'>920</span> `=0xc0
<span class='line'>921</span> [=0xdb
<span class='line'>922</span> \
<span class='line'>923</span> ]
<span class='line'>924</span> '=0xde
<span class='line'>925</span>
<span class='line'>926</span> Fn:
<span class='line'>927</span> F1=0x70
<span class='line'>928</span> ..
<span class='line'>929</span> F12=0x7b
<span class='line'>930</span>
<span class='line'>931</span> additional:
<span class='line'>932</span> Shift=0x100
<span class='line'>933</span> Ctrl=0x200
<span class='line'>934</span> Alt=0x400
<span class='line'>935</span>
<span class='line'>936</span> */</span><span class="WHIT">
<span class='line'>937</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">p.URL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>938</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>939</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">rtPath</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sc</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>940</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">=</span><span class="REGX">/^file:/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">p.replace</span><span class="PUNC">(</span><span class="REGX">/^[^:]+:\/+/</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/[\/]/g</span><span class="PUNC">,</span><span class="STRN">'\\'</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// /\.url$/i.test(path)?'':p;</span><span class="WHIT">
<span class='line'>941</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>942</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">rtPath</span><span class="PUNC">?</span><span class="NAME">path</span><span class="PUNC">:</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>943</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>944</span>
<span class='line'>945</span> </span><span class="COMM">//filepath=OpenFileDialog(); 基於安全IE無法指定初始值或型態</span><span class="WHIT">
<span class='line'>946</span> </span><span class="COMM">//OpenFileDialog[generateCode.dLK]='IEA';</span><span class="WHIT">
<span class='line'>947</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">OpenFileDialog</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>948</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">IE</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">IEA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>949</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">IE.OK</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>950</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>951</span>
<span class='line'>952</span> </span><span class="WHIT"> </span><span class="NAME">IE.write</span><span class="PUNC">(</span><span class="STRN">'&lt;input id="file" type="file"/>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">// value="'+dP+'" useless</span><span class="WHIT">
<span class='line'>953</span>
<span class='line'>954</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">IE.getE</span><span class="PUNC">(</span><span class="STRN">'file'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>955</span> </span><span class="WHIT"> </span><span class="NAME">o.focus</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>956</span> </span><span class="WHIT"> </span><span class="NAME">o.click</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>957</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.value</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>958</span>
<span class='line'>959</span> </span><span class="WHIT"> </span><span class="COMM">// IE.setDialog(200,400).show(1);</span><span class="WHIT">
<span class='line'>960</span> </span><span class="WHIT"> </span><span class="NAME">IE.quit</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>961</span>
<span class='line'>962</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>963</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>964</span>
<span class='line'>965</span>
<span class='line'>966</span> </span><span class="COMM">/**
<span class='line'>967</span> * 是否為檔案
<span class='line'>968</span> * @param path file path
<span class='line'>969</span> * @param create create if not exist
<span class='line'>970</span> * @returns
<span class='line'>971</span> */</span><span class="WHIT">
<span class='line'>972</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">is_file</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">create</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>973</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>974</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>975</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>976</span> </span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>977</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>978</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>979</span>
<span class='line'>980</span> </span><span class="WHIT"> </span><span class="COMM">// doesn't exist</span><span class="WHIT">
<span class='line'>981</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">get_file_name</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>982</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">create</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>983</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>984</span> </span><span class="WHIT"> </span><span class="NAME">create</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.CreateTextFile</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>985</span> </span><span class="WHIT"> </span><span class="NAME">create.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>986</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>987</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>988</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>989</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>990</span>
<span class='line'>991</span> </span><span class="COMM">/**
<span class='line'>992</span> * 是否為目錄
<span class='line'>993</span> * @param path file path
<span class='line'>994</span> * @param create create if not exist
<span class='line'>995</span> * @returns 0:not folder, 1:absolute, 2:relative path
<span class='line'>996</span> */</span><span class="WHIT">
<span class='line'>997</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">is_folder</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">create</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>998</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>999</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1000</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fso.FolderExists</span><span class="PUNC">(</span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">turnToPath</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1001</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">isAbsPath</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">create</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT"> </span><span class="NAME">fso.CreateFolder</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">isAbsPath</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1006</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1007</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1008</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1010</span>
<span class='line'>1011</span> </span><span class="COMM">/**
<span class='line'>1012</span> * get directory name of a path
<span class='line'>1013</span> * @param folder_path
<span class='line'>1014</span> * @param mode 0:path, 1:filename
<span class='line'>1015</span> * @returns
<span class='line'>1016</span> */</span><span class="WHIT">
<span class='line'>1017</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">get_folder</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1018</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">folder_path.Path</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1019</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">folder_path.IsRootFolder</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1020</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">folder_path.Path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1021</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1022</span> </span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">folder_path.Path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1023</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1024</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1025</span> </span><span class="WHIT"> </span><span class="COMM">//else if(/^[a-z]$/i.test(folder_path))folder_path+=':\\';</span><span class="WHIT">
<span class='line'>1026</span>
<span class='line'>1027</span> </span><span class="WHIT"> </span><span class="COMM">// if(folder_path.slice(-1)!='\\')folder_path+='\\';</span><span class="WHIT">
<span class='line'>1028</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">folder_path.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'\\'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1029</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1030</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">folder_path.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1031</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">mode</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">folder_path.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">folder_path.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1032</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1033</span>
<span class='line'>1034</span>
<span class='line'>1035</span>
<span class='line'>1036</span> </span><span class="COMM">/**
<span class='line'>1037</span> * 取得下一個序號的檔名如輸入pp\aa.txt將嘗試pp\aa.txt→pp\aa[pattern].txt
<span class='line'>1038</span> * @param file_path file path
<span class='line'>1039</span> * @param begin_serial begin serial
<span class='line'>1040</span> * @param pattern 增添主檔名的模式包含Ser的部分將被轉換為序號
<span class='line'>1041</span> * @returns
<span class='line'>1042</span> */</span><span class="WHIT">
<span class='line'>1043</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getNextSerialFN</span><span class="PUNC">(</span><span class="NAME">file_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">begin_serial</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pattern</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1044</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">file_path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1045</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1046</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">begin_serial</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1047</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">file_path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1048</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">file_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1049</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="WHIT"> </span><span class="NAME">begin_serial</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1051</span>
<span class='line'>1052</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">file_path.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'.'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">base</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Ser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">':s:'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1053</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1054</span> </span><span class="WHIT"> </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">file_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1055</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1056</span> </span><span class="WHIT"> </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">file_path.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">file_path.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// fso.GetBaseName(filespec);fso.GetExtensionName(path);fso.GetTempName();</span><span class="WHIT">
<span class='line'>1057</span>
<span class='line'>1058</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">pattern</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1059</span> </span><span class="WHIT"> </span><span class="NAME">pattern</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'_'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Ser</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1060</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pattern.indexOf</span><span class="PUNC">(</span><span class="NAME">Ser</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1061</span>
<span class='line'>1062</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1063</span> </span><span class="WHIT"> </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pattern</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1064</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1065</span> </span><span class="WHIT"> </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pattern.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pattern.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Ser.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1066</span>
<span class='line'>1067</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">begin_serial</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">999</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1068</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ext</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1069</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1070</span>
<span class='line'>1071</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1072</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1073</span>
<span class='line'>1074</span>
<span class='line'>1075</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1076</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1077</span> </span><span class="COMM">/**
<span class='line'>1078</span> * 轉換以 adTypeBinary 讀到的資料
<span class='line'>1079</span> * @example
<span class='line'>1080</span> * // 較安全的讀檔:
<span class='line'>1081</span> * t=translate_AdoStream_binary_data(read_file(FP,'binary'));
<span class='line'>1082</span> * write_file(FP,t,'iso-8859-1');
<span class='line'>1083</span> * @see
<span class='line'>1084</span> * &lt;a href="http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html">Hawk&apos;s W3 Laboratory : Disposable WSH : 番外編文字エンコーディングとADODB.Stream&lt;/a>
<span class='line'>1085</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1086</span> */</span><span class="WHIT">
<span class='line'>1087</span> </span><span class="NAME">translate_AdoStream_binary_data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1088</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">,</span><span class="NAME">_i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">charArray</span><span class="PUNC">,</span><span class="NAME">val</span><span class="PUNC">,</span><span class="NAME">DOM</span><span class="PUNC">=</span><span class="NAME">_s.XMLDOM</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="NAME">txt</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1089</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">DOM</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1090</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1091</span> </span><span class="WHIT"> </span><span class="NAME">DOM</span><span class="PUNC">=</span><span class="NAME">_s.XMLDOM</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Microsoft.XMLDOM"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'tmp'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 要素名は何でも良い</span><span class="WHIT">
<span class='line'>1092</span> </span><span class="WHIT"> </span><span class="NAME">DOM.dataType</span><span class="PUNC">=</span><span class="STRN">'bin.hex'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1093</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1094</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">!==</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="NAME">DOM.nodeTypedValue</span><span class="PUNC">=</span><span class="NAME">data</span><span class="PUNC">,</span><span class="NAME">txt</span><span class="PUNC">=</span><span class="NAME">DOM.text</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="COMM">//binary data</span><span class="WHIT">
<span class='line'>1095</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">=</span><span class="NAME">_s.pos</span><span class="PUNC">,</span><span class="NAME">txt</span><span class="PUNC">=</span><span class="NAME">_s.text</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1096</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">||</span><span class="NAME">len</span><span class="PUNC">></span><span class="NAME">txt.length</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="NAME">len</span><span class="PUNC">=</span><span class="NAME">txt.length</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1097</span>
<span class='line'>1098</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1099</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">_i</span><span class="PUNC">&lt;</span><span class="NAME">len</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="NAME">val</span><span class="PUNC">=</span><span class="NUMB">0x100</span><span class="PUNC">*</span><span class="NAME">val</span><span class="PUNC">+</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">txt.substr</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1100</span> </span><span class="WHIT"> </span><span class="NAME">_s.pos</span><span class="PUNC">=</span><span class="NAME">pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1101</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1102</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1103</span>
<span class='line'>1104</span> </span><span class="COMM">/*
<span class='line'>1105</span> if(!(len>0)||len!=parseInt(len))
<span class='line'>1106</span> alert(pos+','+_i+'==0~len='+len+','+txt.slice(0,8));
<span class='line'>1107</span> */</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT"> </span><span class="NAME">charArray</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// Error 5029 [RangeError] (facility code 10): 陣列長度必須是一有限的正整數</span><span class="WHIT">
<span class='line'>1109</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="NAME">_i</span><span class="PUNC">&lt;</span><span class="NAME">len</span><span class="PUNC">;</span><span class="NAME">_i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// 極慢用charString+=更慢。</span><span class="WHIT">
<span class='line'>1110</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1111</span> </span><span class="WHIT"> </span><span class="COMM">//if(_i%100000==0)alert(i);</span><span class="WHIT">
<span class='line'>1112</span> </span><span class="WHIT"> </span><span class="COMM">//if(_i==40)alert(String.fromCharCode(parseInt(txt.substr(pos,2),16))+'\n'+charArray.join(''));</span><span class="WHIT">
<span class='line'>1113</span> </span><span class="WHIT"> </span><span class="NAME">charArray.push</span><span class="PUNC">(</span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">txt.substr</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1114</span> </span><span class="WHIT"> </span><span class="COMM">//charArray[_i]=String.fromCharCode((t.charCodeAt(_i&lt;&lt;1)&lt;&lt;8)+t.charCodeAt((_i&lt;&lt;1)+1));</span><span class="WHIT">
<span class='line'>1115</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1116</span> </span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">=</span><span class="STRN">'translate_AdoStream_binary_data: 輸入了錯誤的資料:\n'</span><span class="PUNC">+</span><span class="NAME">e.description</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1117</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1118</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1119</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data</span><span class="PUNC">)</span><span class="NAME">_s.pos</span><span class="PUNC">=</span><span class="NAME">pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">charArray.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1121</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1122</span>
<span class='line'>1123</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1124</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1125</span> </span><span class="COMM">/**
<span class='line'>1126</span> * 轉換以 adTypeBinary 讀到的資料
<span class='line'>1127</span> * @param data 以 adTypeBinary 讀到的資料
<span class='line'>1128</span> * @param pos position
<span class='line'>1129</span> * @since 2007/9/19 20:58:26
<span class='line'>1130</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1131</span> */</span><span class="WHIT">
<span class='line'>1132</span> </span><span class="NAME">Ado_binary</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1133</span> </span><span class="WHIT"> </span><span class="NAME">this.newDOM</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1134</span>
<span class='line'>1135</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1136</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT">
<span class='line'>1137</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1138</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1139</span> </span><span class="WHIT"> </span><span class="NAME">this.newFS</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1140</span> </span><span class="WHIT"> </span><span class="NAME">this.setPos</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1141</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1142</span> </span><span class="WHIT"> </span><span class="NAME">this.setData</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1143</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1144</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1145</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1146</span> </span><span class="COMM">/**
<span class='line'>1147</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1148</span> */</span><span class="WHIT">
<span class='line'>1149</span> </span><span class="NAME">Ado_binary.prototype</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1150</span> </span><span class="COMM">/**
<span class='line'>1151</span> * 設定 data
<span class='line'>1152</span> *
<span class='line'>1153</span> * @param data binary data
<span class='line'>1154</span> * @param pos
<span class='line'>1155</span> * @return
<span class='line'>1156</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1157</span> */</span><span class="WHIT">
<span class='line'>1158</span> </span><span class="NAME">setData</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1159</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM.nodeTypedValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="COMM">// binary data</span><span class="WHIT">
<span class='line'>1160</span> </span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.DOM.text</span><span class="PUNC">;</span><span class="COMM">// binary text</span><span class="WHIT">
<span class='line'>1161</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.AdoS</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1162</span> </span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bt.length</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1163</span> </span><span class="WHIT"> </span><span class="NAME">this.setPos</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1164</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1165</span> </span><span class="NAME">setPos</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1166</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1167</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1168</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1169</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1170</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1171</span> </span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1172</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1173</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1174</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1175</span> </span><span class="NAME">testLen</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1176</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1177</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1178</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1179</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1180</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1181</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1182</span> </span><span class="COMM">/**
<span class='line'>1183</span> * read data
<span class='line'>1184</span> * @private
<span class='line'>1185</span> * @param len length
<span class='line'>1186</span> * @return
<span class='line'>1187</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1188</span> */</span><span class="WHIT">
<span class='line'>1189</span> </span><span class="NAME">readData</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1190</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.Position</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1191</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Read</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1192</span> </span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>1193</span> </span><span class="WHIT"> </span><span class="NAME">this.setData</span><span class="PUNC">(</span><span class="NAME">_data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Position</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1194</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1195</span> </span><span class="NAME">read</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1196</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.testLen</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1197</span> </span><span class="WHIT"> </span><span class="NAME">this.readData</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1198</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1199</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1200</span> </span><span class="WHIT"> </span><span class="NAME">charArray.push</span><span class="PUNC">(</span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">this.bt</span><span class="WHIT">
<span class='line'>1201</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1202</span> </span><span class="WHIT"> </span><span class="COMM">// charArray[i]=String.fromCharCode((t.charCodeAt(i&lt;&lt;1)&lt;&lt;8)+t.charCodeAt((i&lt;&lt;1)+1));</span><span class="WHIT">
<span class='line'>1203</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1204</span> </span><span class="WHIT"> </span><span class="NAME">this.retErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1205</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1206</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">charArray.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1207</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1208</span> </span><span class="NAME">readNum</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1209</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.testLen</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1210</span> </span><span class="WHIT"> </span><span class="NAME">this.readData</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1211</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1212</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1213</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1214</span> </span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0x100</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT">
<span class='line'>1215</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">this.bt.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">--</span><span class="NAME">_i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1216</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="WHIT"> </span><span class="NAME">this.retErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1218</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1219</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1220</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1221</span> </span><span class="NAME">readHEX</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1222</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.testLen</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1223</span> </span><span class="WHIT"> </span><span class="NAME">this.readData</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1224</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1225</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1226</span> </span><span class="NAME">retErr</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1227</span> </span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'translate_AdoStream_binary_data: 輸入了錯誤的資料:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1228</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1229</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1230</span> </span><span class="COMM">/**
<span class='line'>1231</span> * @private
<span class='line'>1232</span> * @return
<span class='line'>1233</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1234</span> */</span><span class="WHIT">
<span class='line'>1235</span> </span><span class="NAME">newDOM</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1236</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1237</span> </span><span class="WHIT"> </span><span class="COMM">//try{</span><span class="WHIT">
<span class='line'>1238</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Microsoft.XMLDOM"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'tmp'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Math.random</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 要素名は何でも良い</span><span class="WHIT">
<span class='line'>1239</span> </span><span class="WHIT"> </span><span class="COMM">//}catch(e){return;}</span><span class="WHIT">
<span class='line'>1240</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM.dataType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'bin.hex'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1241</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1242</span> </span><span class="COMM">/**
<span class='line'>1243</span> * @private
<span class='line'>1244</span> * @param FP
<span class='line'>1245</span> * @return
<span class='line'>1246</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1247</span> */</span><span class="WHIT">
<span class='line'>1248</span> </span><span class="NAME">newFS</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1249</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="WHIT"> </span><span class="NAME">this.FP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FP</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1251</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.FP</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1252</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1253</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_file.returnADO</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1254</span> </span><span class="WHIT"> </span><span class="NAME">_.open_file.returnADO</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1255</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'binary'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1256</span> </span><span class="WHIT"> </span><span class="NAME">_.open_file.returnADO</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1257</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.AdoS</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1258</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1259</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.LoadFromFile</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1260</span> </span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1261</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1262</span> </span><span class="COMM">/**
<span class='line'>1263</span> * 實際上沒多大效用。實用解決法:少用 AdoStream.Write()
<span class='line'>1264</span> * @return
<span class='line'>1265</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1266</span> */</span><span class="WHIT">
<span class='line'>1267</span> </span><span class="NAME">renew</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1268</span> </span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1269</span> </span><span class="WHIT"> </span><span class="NAME">this.newDOM</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1270</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.FP</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Position</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1272</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1273</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1274</span> </span><span class="WHIT"> </span><span class="NAME">this.newFS</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1275</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1276</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1277</span> </span><span class="NAME">destory</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1278</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.AdoS</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1279</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1280</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1281</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1282</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// Ado_binary.prototype={</span><span class="WHIT">
<span class='line'>1283</span>
<span class='line'>1284</span>
<span class='line'>1285</span> </span><span class="COMM">/*
<span class='line'>1286</span> // 速度過慢,放棄。
<span class='line'>1287</span> //_.open_file.returnADO=true;
<span class='line'>1288</span> function dealBinary(FP,func,interval){
<span class='line'>1289</span> var t,fs=_.open_file(FP,'binary',ForReading);
<span class='line'>1290</span> if(!fs)return;
<span class='line'>1291</span> AdoStream.LoadFromFile(FP);
<span class='line'>1292</span> if(!interval)interval=1;
<span class='line'>1293</span> //alert(fs.size)
<span class='line'>1294</span> while(!fs.EOS)
<span class='line'>1295</span> if(func(translate_AdoStream_binary_data(fs.Read(interval))))return;
<span class='line'>1296</span> func();
<span class='line'>1297</span> fs.Close();
<span class='line'>1298</span> }
<span class='line'>1299</span> */</span><span class="WHIT">
<span class='line'>1300</span>
<span class='line'>1301</span> </span><span class="COMM">/* 配合simple系列使用
<span class='line'>1302</span> http://thor.prohosting.com/~mktaka/html/utf8.html
<span class='line'>1303</span> http://www.andrewu.co.uk/webtech/comment/?703
<span class='line'>1304</span> http://www.blueidea.com/bbs/NewsDetail.asp?id=1488978
<span class='line'>1305</span> http://www.blueidea.com/bbs/NewsDetail.asp?GroupName=WAP+%BC%BC%CA%F5%D7%A8%C0%B8&DaysPrune=5&lp=1&id=1524739
<span class='line'>1306</span> C# http://www.gotdotnet.com/team/clr/bcl/TechArticles/TechArticles/IOFAQ/FAQ.aspx
<span class='line'>1307</span> http://www.sqlxml.org/faqs.aspx?faq=2
<span class='line'>1308</span> http://www.imasy.or.jp/~hir/hir/tech/js_tips.html
<span class='line'>1309</span>
<span class='line'>1310</span> ADODB.Stream 最大問題不能append
<span class='line'>1311</span> http://msdn2.microsoft.com/en-us/library/ms808792.aspx
<span class='line'>1312</span> http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp
<span class='line'>1313</span> http://study.99net.net/study/web/asp/1067048121.html http://www.6to23.com/s11/s11d5/20031222114950.htm
<span class='line'>1314</span> http://blog.csdn.net/dfmz007/archive/2004/07/23/49373.aspx
<span class='line'>1315</span> */</span><span class="WHIT">
<span class='line'>1316</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">,</span><span class="NAME">AdoEnums</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// ADO Enumerated Constants http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp</span><span class="WHIT">
<span class='line'>1317</span> </span><span class="COMM">/* 搬到前面
<span class='line'>1318</span> setObjValue('AdoEnums','adTypeBinary=1,adTypeText=2' // StreamTypeEnum
<span class='line'>1319</span> +',adReadAll=-1,adReadLine=-2' // StreamReadEnum http://msdn2.microsoft.com/en-us/library/ms806462.aspx
<span class='line'>1320</span> +',adSaveCreateNotExist=1,adSaveCreateOverWrite=2' // SaveOptionsEnum
<span class='line'>1321</span> +',adCR=13,adCRLF=-1,adLF=10' // LineSeparatorsEnum
<span class='line'>1322</span> ,'int');
<span class='line'>1323</span> */</span><span class="WHIT">
<span class='line'>1324</span> </span><span class="NAME">AdoEnums</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1325</span> </span><span class="WHIT"> </span><span class="NAME">adTypeBinary</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1326</span> </span><span class="WHIT"> </span><span class="NAME">adTypeText</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1327</span> </span><span class="WHIT"> </span><span class="NAME">adReadAll</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1328</span> </span><span class="WHIT"> </span><span class="NAME">adReadLine</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1329</span> </span><span class="WHIT"> </span><span class="NAME">adSaveCreateNotExist</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1330</span> </span><span class="WHIT"> </span><span class="NAME">adSaveCreateOverWrite</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1331</span> </span><span class="WHIT"> </span><span class="NAME">adCR</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">13</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1332</span> </span><span class="WHIT"> </span><span class="NAME">adCRLF</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1333</span> </span><span class="WHIT"> </span><span class="NAME">adLF</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="WHIT">
<span class='line'>1334</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1335</span>
<span class='line'>1336</span>
<span class='line'>1337</span> </span><span class="COMM">//_.open_file[generateCode.dLK]='AdoEnums,simpleFileErr,ForReading,ForWriting,ForAppending,TristateUseDefault';//AdoStream</span><span class="WHIT">
<span class='line'>1338</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1339</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1340</span> </span><span class="COMM">/**
<span class='line'>1341</span> * 提供給 &lt;a href="#.read_file">read_file&lt;/a>, &lt;a href="#.write_file">write_file&lt;/a> 使用的簡易開檔函數
<span class='line'>1342</span> * @param FN file path
<span class='line'>1343</span> * @param format open format, e.g., open_format.TristateUseDefault
<span class='line'>1344</span> * @param io_mode open mode, e.g., iomode.ForWriting
<span class='line'>1345</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1346</span> */</span><span class="WHIT">
<span class='line'>1347</span> </span><span class="NAME">open_file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1348</span> </span><span class="WHIT"> </span><span class="COMM">//if(!FN||typeof isAbsPath=='function'&&typeof get_file_name=='function'&&!isAbsPath(FN)&&!(FN=get_file_name(FN)))return;</span><span class="WHIT">
<span class='line'>1349</span> </span><span class="WHIT"> </span><span class="COMM">//if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return;</span><span class="WHIT">
<span class='line'>1350</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">open_file</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1351</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1352</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">_s.returnADO</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">!=</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1353</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1354</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1355</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"ADODB.Stream"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">//var objStream=Server.CreateObject("ADODB.Stream"); // ASPの場合,Err.Number=-2147221005表不支援</span><span class="WHIT">
<span class='line'>1356</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1357</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1358</span> </span><span class="WHIT"> </span><span class="COMM">//AdoStream.Mode=3; // read write</span><span class="WHIT">
<span class='line'>1359</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">format</span><span class="PUNC">==</span><span class="STRN">'binary'</span><span class="PUNC">)</span><span class="NAME">AdoStream.Type</span><span class="PUNC">=</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 以二進位方式操作</span><span class="WHIT">
<span class='line'>1360</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1361</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Type</span><span class="PUNC">=</span><span class="NAME">AdoEnums.adTypeText</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1362</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">AdoStream.Charset</span><span class="PUNC">=</span><span class="NAME">format</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="PUNC">,</span><span class="STRN">'open_file: Error format:\n ('</span><span class="PUNC">+</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">+</span><span class="STRN">') ['</span><span class="PUNC">+</span><span class="NAME">format</span><span class="PUNC">+</span><span class="STRN">']\n'</span><span class="PUNC">+</span><span class="NAME">e.description</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// UTF-8,unicode,shift_jis,Big5,GB2312,ascii=iso-8859-1,_autodetect,_autodetect_all.. HKEY_CLASSES_ROOT\MIME\Database\Charset</span><span class="WHIT">
<span class='line'>1363</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1364</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Open</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1365</span> </span><span class="WHIT"> </span><span class="COMM">//AdoStream.Position=0,AdoStream.LineSeparator=AdoEnums.adLF;</span><span class="WHIT">
<span class='line'>1366</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_s.returnADO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_A</span><span class="PUNC">=</span><span class="NAME">AdoStream</span><span class="PUNC">;</span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_A</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1367</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1368</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1369</span> </span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1370</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1371</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1372</span> </span><span class="WHIT"> </span><span class="COMM">// 使用某些防毒軟體(如諾頓 Norton)時,.OpenTextFile() 可能會被攔截,因而延宕。</span><span class="WHIT">
<span class='line'>1373</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1374</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">io_mode</span><span class="PUNC">==</span><span class="NAME">_.iomode.ForAppending</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">io_mode</span><span class="PUNC">=</span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 無此檔時改 writing</span><span class="WHIT">
<span class='line'>1375</span> </span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">=</span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">||</span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">==</span><span class="NAME">_.iomode.ForWriting</span><span class="COMM">/*create*/</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">||</span><span class="NAME">_.open_format.TristateUseDefault</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1376</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1377</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1378</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1379</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1380</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1381</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1382</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1383</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1384</span> </span><span class="PUNC">.</span><span class="NAME">open_file.returnADO</span><span class="PUNC">=</span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1385</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1386</span> </span><span class="PUNC">.</span><span class="NAME">open_file.error</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1387</span>
<span class='line'>1388</span> </span><span class="COMM">// 若是僅使用普通的開檔方法_.open_format.TristateTrue/_.open_format.TristateFalse等不使用ADODB.Stream直接引用下兩函數與fso段定義即可。否則還需要引入_.open_file(),setObjValue(),dQuote()</span><span class="WHIT">
<span class='line'>1389</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1390</span> </span><span class="WHIT"> </span><span class="COMM">//_autodetect autodetectEncode(file)</span><span class="WHIT">
<span class='line'>1391</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileAutodetectEncode</span><span class="PUNC">=</span><span class="PUNC">-</span><span class="NUMB">5.4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1392</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>1393</span> </span><span class="WHIT"> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1394</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">open_format.TristateUseDefault</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1395</span>
<span class='line'>1396</span> </span><span class="COMM">//_.read_file[generateCode.dLK]=_.write_file[generateCode.dLK]='simpleFileErr,simpleFileAutodetectEncode,simpleFileDformat,initWScriptObj';//_.open_file,autodetectEncode,getFP,_.open_format.TristateUseDefault</span><span class="WHIT">
<span class='line'>1397</span> </span><span class="COMM">//_.read_file[generateCode.dLK]+=',ForReading';_.write_file[generateCode.dLK]+=',ForWriting';</span><span class="WHIT">
<span class='line'>1398</span> </span><span class="COMM">//_.read_file[generateCode.dLK]+=',translate_AdoStream_binary_data'; // for _.read_file(FP,'binary')</span><span class="WHIT">
<span class='line'>1399</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1400</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1401</span> </span><span class="COMM">/**
<span class='line'>1402</span> * 讀取檔案
<span class='line'>1403</span> * @param FN file path
<span class='line'>1404</span> * @param format open encode = simpleFileDformat
<span class='line'>1405</span> * @param io_mode open IO mode = ForReading
<span class='line'>1406</span> * @param func do this function per line, or [func, maxsize] (TODO)
<span class='line'>1407</span> * @return {String} 檔案內容
<span class='line'>1408</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1409</span> */</span><span class="WHIT">
<span class='line'>1410</span> </span><span class="NAME">read_file</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="NAME">func</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1411</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">format</span><span class="PUNC">==</span><span class="NAME">simpleFileAutodetectEncode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1412</span> </span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">=</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">autodetectEncode</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">?</span><span class="NAME">autodetectEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1413</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">FN</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">=</span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1414</span> </span><span class="WHIT"> </span><span class="COMM">//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;}</span><span class="WHIT">
<span class='line'>1415</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">,</span><span class="NAME">fs</span><span class="PUNC">;</span><span class="COMM">//,i,s=0,t;</span><span class="WHIT">
<span class='line'>1416</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="PUNC">!=</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1417</span> </span><span class="WHIT"> </span><span class="COMM">//{if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return;</span><span class="WHIT">
<span class='line'>1418</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fs</span><span class="PUNC">=</span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">||</span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">,</span><span class="KEYW">false</span><span class="COMM">/*create*/</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">||</span><span class="NAME">simpleFileDformat</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1419</span> </span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1420</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">fs</span><span class="PUNC">=</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">||</span><span class="NAME">simpleFileDformat</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">||</span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">fs</span><span class="PUNC">===</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1421</span>
<span class='line'>1422</span> </span><span class="WHIT"> </span><span class="COMM">//if(func instanceof Array)s=func[1],func=func[0];</span><span class="WHIT">
<span class='line'>1423</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">fs</span><span class="PUNC">!==</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1424</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">func</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1425</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fs.AtEndOfStream</span><span class="PUNC">)</span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">fs.ReadLine</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1426</span> </span><span class="COMM">/*
<span class='line'>1427</span> while(!fs.AtEndOfStream){
<span class='line'>1428</span> for(t='',i=0;!fs.AtEndOfStream&&(!t||i&lt;s);i++)
<span class='line'>1429</span> t+=fs.ReadLine();
<span class='line'>1430</span> a+=func(t);
<span class='line'>1431</span> }
<span class='line'>1432</span> */</span><span class="WHIT">
<span class='line'>1433</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">fs.ReadAll</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1434</span> </span><span class="WHIT"> </span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1435</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1436</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">!=</span><span class="STRN">'undefined'</span><span class="PUNC">&&</span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1437</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1438</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.LoadFromFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1439</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="PUNC">==</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1440</span> </span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">AdoStream.Read</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadAll</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>1441</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_.read_file.turnBinToStr</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1442</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">func</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1443</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">AdoStream.EOS</span><span class="PUNC">)</span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadLine</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1444</span> </span><span class="COMM">/*
<span class='line'>1445</span> while(!AdoStream.EOS){
<span class='line'>1446</span> for(t='',i=0;!AdoStream.AtEndOfStream&&(!t||i&lt;s);i++)
<span class='line'>1447</span> t+=AdoStream.ReadText(AdoEnums.adReadLine);
<span class='line'>1448</span> a+=func(t);
<span class='line'>1449</span> }
<span class='line'>1450</span> */</span><span class="WHIT">
<span class='line'>1451</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadAll</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1452</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1453</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1454</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1455</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1456</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1457</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1458</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="STRN">'unknown error!'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">simpleFileErr.name</span><span class="PUNC">=</span><span class="STRN">'unknownError'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1459</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1460</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1461</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1462</span> </span><span class="PUNC">.</span><span class="NAME">read_file.turnBinToStr</span><span class="PUNC">=</span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1463</span>
<span class='line'>1464</span>
<span class='line'>1465</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1466</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1467</span> </span><span class="COMM">/**
<span class='line'>1468</span> * 將 content 寫入 file
<span class='line'>1469</span> * ** ADODB.Stream does not support appending!
<span class='line'>1470</span> * @param FN file path
<span class='line'>1471</span> * @param content content to write
<span class='line'>1472</span> * @param format open format = simpleFileDformat
<span class='line'>1473</span> * @param io_mode write mode = ForWriting, e.g., ForAppending
<span class='line'>1474</span> * @param N_O DO NOT overwrite
<span class='line'>1475</span> * @return error No.
<span class='line'>1476</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1477</span> */</span><span class="WHIT">
<span class='line'>1478</span> </span><span class="NAME">write_file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">content</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">N_O</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1479</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1480</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">simpleFileAutodetectEncode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1481</span> </span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">autodetectEncode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">autodetectEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1482</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1483</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1484</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1485</span> </span><span class="WHIT"> </span><span class="COMM">//var fs;try{fs=fso.OpenTextFile(FN,iomode||ForWriting,true,format||TristateUseDefault);}catch(e){return 2;}if(!fs)return 3;</span><span class="WHIT">
<span class='line'>1486</span> </span><span class="WHIT"> </span><span class="COMM">//try{fs.Write(content);}catch(e){return e.number&0xFFFF==5?5:4;} // 5:content中有此local無法相容的字元例如在中文中寫入日文假名</span><span class="WHIT">
<span class='line'>1487</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1488</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1489</span> </span><span class="WHIT"> </span><span class="COMM">// {if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return 2;</span><span class="WHIT">
<span class='line'>1490</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1491</span> </span><span class="WHIT"> </span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1492</span> </span><span class="WHIT"> </span><span class="KEYW">true</span><span class="COMM">/* create */</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1493</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fs</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1494</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1495</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1496</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1497</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1498</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1499</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT">
<span class='line'>1500</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1501</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1502</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">fs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1503</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1504</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1505</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1506</span> </span><span class="WHIT"> </span><span class="NAME">fs.Write</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1507</span> </span><span class="WHIT"> </span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1508</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1509</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1510</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1511</span> </span><span class="WHIT"> </span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1512</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1513</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1514</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">simpleFileErr.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1515</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1516</span> </span><span class="WHIT"> </span><span class="COMM">// AdoStream.SaveToFile()需在AdoStream.Write之後</span><span class="WHIT">
<span class='line'>1517</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1518</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1519</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">AdoEnums.adTypeText</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1520</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.WriteText</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1521</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1522</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Write</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1523</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.SaveToFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT">
<span class='line'>1524</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">AdoEnums.adSaveCreateOverWrite</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1525</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1526</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1527</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1528</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1529</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1530</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1531</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1532</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1533</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1534</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1535</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'unknown error!'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1536</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'unknownError'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1537</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1538</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1539</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1540</span>
<span class='line'>1541</span> </span><span class="COMM">// TODO: unfinished</span><span class="WHIT">
<span class='line'>1542</span> </span><span class="COMM">//simpleDealFile[generateCode.dLK]='autodetectEncode,_.read_file,_.write_file';</span><span class="WHIT">
<span class='line'>1543</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1544</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1545</span> </span><span class="NAME">simpleDealFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">inFN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">func</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">outFN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">N_O</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1546</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">inFN</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1547</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1548</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">outFN</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1549</span> </span><span class="WHIT"> </span><span class="NAME">outFN</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">inFN</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1550</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">autodetectEncode</span><span class="PUNC">(</span><span class="NAME">inFN</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.read_file</span><span class="PUNC">(</span><span class="NAME">inFN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.read_file</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1551</span> </span><span class="WHIT"> </span><span class="NAME">outFN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">inFN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1552</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1553</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_.write_file</span><span class="PUNC">(</span><span class="NAME">outFN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">N_O</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1554</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1555</span>
<span class='line'>1556</span> </span><span class="COMM">/*
<span class='line'>1557</span> var autodetectEncodeSP,autodetectEncodeCode; // 特殊字元,各種編碼及判別所需最短長度
<span class='line'>1558</span> 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,'
<span class='line'>1559</span> +'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,'
<span class='line'>1560</span> +'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,'
<span class='line'>1561</span> +'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,'
<span class='line'>1562</span> +'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,'
<span class='line'>1563</span> +'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,'
<span class='line'>1564</span> +'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,'
<span class='line'>1565</span> +'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,'
<span class='line'>1566</span> +'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,'
<span class='line'>1567</span> +'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,'
<span class='line'>1568</span> +'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,'
<span class='line'>1569</span> +'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,'
<span class='line'>1570</span> +'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,'
<span class='line'>1571</span> +'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,'
<span class='line'>1572</span> +'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,'
<span class='line'>1573</span> +'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,'
<span class='line'>1574</span> +'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,'
<span class='line'>1575</span> +'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,'
<span class='line'>1576</span> +'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,'
<span class='line'>1577</span> +'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,'
<span class='line'>1578</span> +'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,'
<span class='line'>1579</span> +'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,'
<span class='line'>1580</span> +'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,'
<span class='line'>1581</span> +'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,'
<span class='line'>1582</span> +'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,'
<span class='line'>1583</span> +'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,'
<span class='line'>1584</span> +'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,'
<span class='line'>1585</span> +'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,'
<span class='line'>1586</span> +'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,'
<span class='line'>1587</span> +'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,'
<span class='line'>1588</span> +'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,'
<span class='line'>1589</span> +'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,'
<span class='line'>1590</span> +'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,'
<span class='line'>1591</span> +'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,'
<span class='line'>1592</span> +'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,'
<span class='line'>1593</span> +'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,'
<span class='line'>1594</span> +'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,'
<span class='line'>1595</span> +'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,'
<span class='line'>1596</span> +'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,'
<span class='line'>1597</span> +'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,'
<span class='line'>1598</span> +'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,'
<span class='line'>1599</span> +'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,'
<span class='line'>1600</span> +'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,'
<span class='line'>1601</span> +'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,'
<span class='line'>1602</span> +'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,'
<span class='line'>1603</span> +'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,'
<span class='line'>1604</span> +'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,'
<span class='line'>1605</span> +'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,'
<span class='line'>1606</span> +'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,'
<span class='line'>1607</span> +'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,'
<span class='line'>1608</span> +'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,'
<span class='line'>1609</span> +'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,'
<span class='line'>1610</span> +'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,'
<span class='line'>1611</span> +'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,'
<span class='line'>1612</span> +'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,'
<span class='line'>1613</span> +'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,'
<span class='line'>1614</span> +'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,'
<span class='line'>1615</span> +'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,'
<span class='line'>1616</span> +'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,'
<span class='line'>1617</span> +'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,'
<span class='line'>1618</span> +'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,'
<span class='line'>1619</span> +'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,'
<span class='line'>1620</span> +'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,'
<span class='line'>1621</span> +'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,'
<span class='line'>1622</span> +'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,'
<span class='line'>1623</span> +'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,'
<span class='line'>1624</span> +'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);
<span class='line'>1625</span> // HKEY_CLASSES_ROOT\MIME\Database\Charset
<span class='line'>1626</span> // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字Big5常用字卻常常是gb中奇怪字碼與罕用字
<span class='line'>1627</span> setObjValue('autodetectEncodeCode','GB2312=3000,Big5=3000,shift_jis=900,iso-8859-1=2000',1);
<span class='line'>1628</span>
<span class='line'>1629</span>
<span class='line'>1630</span> TODO:
<span class='line'>1631</span> 只檢測常用的幾個字,無法判別才廣泛測試。
<span class='line'>1632</span> */</span><span class="WHIT">
<span class='line'>1633</span> </span><span class="COMM">//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));</span><span class="WHIT">
<span class='line'>1634</span> </span><span class="COMM">/* 自動判別檔案(或字串)之編碼 文字エンコーディング判定を行う
<span class='line'>1635</span> http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html
<span class='line'>1636</span> http://www.ericphelps.com/q193998/
<span class='line'>1637</span> http://hp.vector.co.jp/authors/VA003334/ado/adostream.htm
<span class='line'>1638</span> */</span><span class="WHIT">
<span class='line'>1639</span> </span><span class="COMM">//autodetectEncode[generateCode.dLK]='is_file,simpleFileDformat,_.open_file,autodetectStringEncode,autodetectHTMLEncode';</span><span class="WHIT">
<span class='line'>1640</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1641</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1642</span> </span><span class="NAME">autodetectEncode</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">isHTML</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1643</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">,</span><span class="NAME">code</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1644</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"autodetectEncode: Can't find ActiveXObject!"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1645</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof autodetectHTMLEncode!='function')isHTML=false;</span><span class="WHIT">
<span class='line'>1646</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">is_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">FN.length</span><span class="PUNC">&lt;</span><span class="NUMB">64</span><span class="PUNC">?</span><span class="NAME">simpleFileDformat</span><span class="PUNC">:</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">autodetectStringEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">t</span><span class="PUNC">:</span><span class="PUNC">(</span><span class="NAME">isHTML</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">isHTML</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">&&</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">autodetectHTMLEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">t</span><span class="PUNC">:</span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1647</span> </span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>1648</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">AdoEnums</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1649</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.LoadFromFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1650</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">//Read(3);//</span><span class="WHIT">
<span class='line'>1651</span> </span><span class="WHIT"> </span><span class="COMM">//alert(FN+'\n'+t.charCodeAt(0)+','+t.charCodeAt(1)+','+t.charCodeAt(2));</span><span class="WHIT">
<span class='line'>1652</span>
<span class='line'>1653</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof t!='string')return simpleFileDformat;//t=''+t; // 此時type通常是unknown不能用+=</span><span class="WHIT">
<span class='line'>1654</span> </span><span class="WHIT"> </span><span class="COMM">// Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏它是以FF-FE這兩個bytes表達在BE(big endian)裏是FEFF。而在UTF-8裏它是以EF-BB-BF這三個bytes表達。</span><span class="WHIT">
<span class='line'>1655</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">t.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">==</span><span class="STRN">'\xFF\xFE'</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="STRN">'unicodeFFFE'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1656</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">t.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">==</span><span class="STRN">'\xFE\xFF'</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="STRN">'unicode'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1657</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">==</span><span class="STRN">'\xEF\xBB\xBF'</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="STRN">'UTF-8'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1658</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1659</span> </span><span class="WHIT"> </span><span class="COMM">// 即使是用OpenTextFile(_.open_format.TristateFalse)UTF-8還是會被轉換而判別不出來。</span><span class="WHIT">
<span class='line'>1660</span> </span><span class="WHIT"> </span><span class="COMM">// from http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html</span><span class="WHIT">
<span class='line'>1661</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">,</span><span class="NAME">codes</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">reg</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">stream</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"ADODB.Stream"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1662</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="STRN">'[\\x09\\x0a\\x0d\\x20-\\x7e]'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1663</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'big5'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1664</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xa4-\\xc6\\xc9-\\xf9][\\x40-\\xfe]'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://www.cns11643.gov.tw/web/word/big5/index.html</span><span class="WHIT">
<span class='line'>1665</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'shift_jis'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1666</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\x81-\\x9f\\xe0-\\xef\\xfa-\\xfc][\\x40-\\x7e\\x80-\\xfc]|[\\xa1-\\xdf]'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://hp.vector.co.jp/authors/VA013241/misc/shiftjis.html</span><span class="WHIT">
<span class='line'>1667</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'euc-jp'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1668</span> </span><span class="WHIT"> </span><span class="STRN">'|\\x8f[\\xa1-\\xfe][\\xa1-\\xfe]|[\\xa1-\\xfe][\\xa1-\\xfe]|\\x8e[\\xa1-\\xdf]'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1669</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'utf-8'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1670</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xc0-\\xdf][\\x80-\\xbf]|[\\xe0-\\xef][\\x80-\\xbf]{2}|[\\xf0-\\xf7][\\x80-\\xbf]{3}'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1671</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xf8-\\xfb][\\x80-\\xbf]{4}|[\\xfc-\\xfd][\\x80-\\xbf]{5}'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1672</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'gb2312'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="COMM">// GBK</span><span class="WHIT">
<span class='line'>1673</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xa1-\\xf7][\\xa1-\\xfe]'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://zh.wikipedia.org/wiki/GB_18030 http://zh.wikipedia.org/wiki/GB_2312</span><span class="WHIT">
<span class='line'>1674</span>
<span class='line'>1675</span> </span><span class="WHIT"> </span><span class="NAME">stream.type</span><span class="PUNC">=</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1676</span> </span><span class="WHIT"> </span><span class="NAME">stream.open</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1677</span> </span><span class="WHIT"> </span><span class="NAME">stream.loadFromFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1678</span> </span><span class="WHIT"> </span><span class="NAME">stream.position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1679</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">stream.read</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1680</span> </span><span class="WHIT"> </span><span class="NAME">stream.close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1681</span> </span><span class="WHIT"> </span><span class="NAME">stream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1682</span>
<span class='line'>1683</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">,</span><span class="NUMB">4</span><span class="NAME">e3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1684</span>
<span class='line'>1685</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_e</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1686</span> </span><span class="WHIT"> </span><span class="NAME">reg</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'^(?:'</span><span class="PUNC">+</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="NAME">_e</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1687</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1688</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">!=</span><span class="NAME">s.length</span><span class="PUNC">)</span><span class="NAME">l</span><span class="PUNC">=</span><span class="NAME">s.length</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">=</span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="NAME">reg</span><span class="PUNC">,</span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1689</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">==</span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">code</span><span class="PUNC">=</span><span class="NAME">_e</span><span class="PUNC">;</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1690</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1691</span>
<span class='line'>1692</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1693</span> </span><span class="WHIT"> </span><span class="COMM">//sl('autodetectEncode: coding: ['+code+'] in parse 1.');</span><span class="WHIT">
<span class='line'>1694</span>
<span class='line'>1695</span> </span><span class="WHIT"> </span><span class="COMM">// 假如是HTML檔判斷是否有charset設定。這個判別放在unicode之後其他自動判別之前。</span><span class="WHIT">
<span class='line'>1696</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">isHTML</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">isHTML</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">&&</span><span class="REGX">/\.s?html?$/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1697</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="PUNC">==</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">)</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1698</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">AdoStream.Charset</span><span class="PUNC">=</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>1699</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">autodetectHTMLEncode</span><span class="PUNC">(</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NUMB">4</span><span class="NAME">e3</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1700</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1701</span> </span><span class="WHIT"> </span><span class="COMM">//sl('autodetectEncode: coding: ['+code+'] in parse 2.');</span><span class="WHIT">
<span class='line'>1702</span>
<span class='line'>1703</span> </span><span class="WHIT"> </span><span class="COMM">//autodetectEncodeCode.GB2312=900000; // 4 test</span><span class="WHIT">
<span class='line'>1704</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">code</span><span class="PUNC">)</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">autodetectEncodeCode</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1705</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="PUNC">==</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">)</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1706</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">i</span><span class="PUNC">==</span><span class="NAME">autodetectStringEncode</span><span class="PUNC">(</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">autodetectEncodeCode</span><span class="PUNC">[</span><span class="NAME">AdoStream.Charset</span><span class="PUNC">=</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">code</span><span class="PUNC">=</span><span class="NAME">i</span><span class="PUNC">;</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1707</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1708</span>
<span class='line'>1709</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1710</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">code</span><span class="PUNC">||</span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// ascii=iso-8859-1,_autodetect,_autodetect_all</span><span class="WHIT">
<span class='line'>1711</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1712</span>
<span class='line'>1713</span> </span><span class="COMM">/**
<span class='line'>1714</span> * 判斷HTML檔是否有charset設定
<span class='line'>1715</span> * @param file_contents file contents
<span class='line'>1716</span> * @returns
<span class='line'>1717</span> */</span><span class="WHIT">
<span class='line'>1718</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">autodetectHTMLEncode</span><span class="PUNC">(</span><span class="NAME">file_contents</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1719</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1720</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">file_contents.match</span><span class="PUNC">(</span><span class="REGX">/&lt;meta\s+([^>]+)>/i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1721</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/content="([^"]+)"/i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/content=([^\w]+)/i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1722</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/charset=([\w-]{2,})/i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1723</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">file_contents.match</span><span class="PUNC">(</span><span class="REGX">/&lt;\?xml\s[^>]+\sencoding\s*=\s*["']([a-z\d\-]+)["']/i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1724</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1725</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1726</span>
<span class='line'>1727</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1728</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1729</span> </span><span class="COMM">/**
<span class='line'>1730</span> * 靠常用字自動判別字串之編碼 string,預設編碼
<span class='line'>1731</span> */</span><span class="WHIT">
<span class='line'>1732</span> </span><span class="NAME">autodetectStringEncode</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1733</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">!=</span><span class="STRN">'string'</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">=</span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="REGX">/\s+/g</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1734</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">=</span><span class="NAME">str.length</span><span class="PUNC">,</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">,</span><span class="NAME">a</span><span class="PUNC">,</span><span class="NAME">kana</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">jianhuazi</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">halfwidthKatakana</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">Hangul</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">ascii</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">asciiHigh</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">kanji</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">kokuji</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">symbol</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">unknown</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1735</span> </span><span class="WHIT"> </span><span class="COMM">//if(len>9000)len=9000;</span><span class="WHIT">
<span class='line'>1736</span> </span><span class="WHIT"> </span><span class="COMM">//var unknownC='';</span><span class="WHIT">
<span class='line'>1737</span>
<span class='line'>1738</span> </span><span class="WHIT"> </span><span class="COMM">// char分類</span><span class="WHIT">
<span class='line'>1739</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">len</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1740</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">=</span><span class="NAME">str.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x80</span><span class="PUNC">)</span><span class="NAME">ascii</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1741</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x100</span><span class="PUNC">)</span><span class="NAME">asciiHigh</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1742</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0x3040</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x30ff</span><span class="PUNC">)</span><span class="NAME">kana</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1743</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">==</span><span class="NUMB">0x30fb</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0xff65</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xff9e</span><span class="PUNC">)</span><span class="NAME">halfwidthKatakana</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1744</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0x1100</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x11fa</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0xac00</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xad00</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0xd700</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xd7a4</span><span class="PUNC">)</span><span class="NAME">Hangul</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1745</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0x4dff</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x9fa6</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">kanji</span><span class="PUNC">++</span><span class="PUNC">,</span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">autodetectEncodeSP</span><span class="PUNC">[</span><span class="NAME">c</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">==</span><span class="STRN">'C'</span><span class="PUNC">)</span><span class="NAME">jianhuazi</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">==</span><span class="STRN">'J'</span><span class="PUNC">)</span><span class="NAME">kokuji</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1746</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0xfa00</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xfa6b</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">autodetectEncodeSP</span><span class="PUNC">[</span><span class="NAME">c</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'J'</span><span class="PUNC">)</span><span class="NAME">kokuji</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1747</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0x2010</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x2610</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0xfe30</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xfe70</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0xff00</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xff5f</span><span class="PUNC">)</span><span class="NAME">symbol</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1748</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0x3000</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x3400</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0x33ff</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x4db6</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1749</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">autodetectEncodeSP</span><span class="PUNC">[</span><span class="NAME">c</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'J'</span><span class="PUNC">)</span><span class="NAME">kokuji</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">symbol</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1750</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">unknown</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="COMM">//,unknownC+=str.charAt(i);</span><span class="WHIT">
<span class='line'>1751</span>
<span class='line'>1752</span> </span><span class="WHIT"> </span><span class="COMM">//alert('len='+len+'\nkana='+kana+'\nkokuji='+kokuji+'\njianhuazi='+jianhuazi+'\nhalfwidthKatakana='+halfwidthKatakana+'\nHangul='+Hangul+'\nascii='+ascii+'\nasciiHigh='+asciiHigh+'\nkanji='+kanji+'\nsymbol='+symbol+'\nunknown='+unknown);</span><span class="WHIT">
<span class='line'>1753</span> </span><span class="WHIT"> </span><span class="COMM">//if(unknownC)alert('unknown:\n'+unknownC.slice(0,200));//alert(unknownC.slice(0,200)+'\n'+str.slice(0,1000));</span><span class="WHIT">
<span class='line'>1754</span> </span><span class="WHIT"> </span><span class="COMM">// 依各種常用字母之條件判別</span><span class="WHIT">
<span class='line'>1755</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ascii</span><span class="PUNC">+</span><span class="NAME">asciiHigh</span><span class="PUNC">==</span><span class="NAME">len</span><span class="PUNC">?</span><span class="STRN">'iso-8859-1'</span><span class="WHIT">
<span class='line'>1756</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">unknown</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">05</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="STRN">''</span><span class="COMM">//unicode // unknown不能太多</span><span class="WHIT">
<span class='line'>1757</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">kana</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">2</span><span class="PUNC">*</span><span class="NAME">len</span><span class="PUNC">&&</span><span class="NAME">kanji</span><span class="PUNC">+</span><span class="NAME">kana</span><span class="PUNC">+</span><span class="NAME">symbol</span><span class="PUNC">></span><span class="NUMB">3</span><span class="PUNC">*</span><span class="NAME">halfwidthKatakana</span><span class="PUNC">?</span><span class="STRN">'shift_jis'</span><span class="WHIT">
<span class='line'>1758</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">kanji</span><span class="PUNC">+</span><span class="NAME">symbol</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">7</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">&&</span><span class="NAME">kana</span><span class="PUNC">&lt;</span><span class="PUNC">.</span><span class="NUMB">05</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">jianhuazi</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">1</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="STRN">'GB2312'</span><span class="PUNC">:</span><span class="STRN">'Big5'</span><span class="WHIT">
<span class='line'>1759</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">Hangul</span><span class="PUNC">+</span><span class="NAME">symbol</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">7</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="STRN">'korean'</span><span class="COMM">//ks_c_5601</span><span class="WHIT">
<span class='line'>1760</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">kanji</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">2</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">jianhuazi</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">1</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="NAME">kokuji</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">02</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="STRN">'unicode'</span><span class="PUNC">:</span><span class="STRN">'GB2312'</span><span class="PUNC">:</span><span class="NAME">kokuji</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">02</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="STRN">'shift_jis'</span><span class="PUNC">:</span><span class="STRN">'Big5'</span><span class="WHIT">
<span class='line'>1761</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">;</span><span class="COMM">//unicode</span><span class="WHIT">
<span class='line'>1762</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1763</span>
<span class='line'>1764</span> </span><span class="COMM">/*
<span class='line'>1765</span> 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
<span class='line'>1766</span> http://www.theorem.ca/~mvcorks/cgi-bin/unicode.pl.cgi?start=F900&end=FAFF http://homepage1.nifty.com/nomenclator/unicode/normalization.htm
<span class='line'>1767</span>
<span class='line'>1768</span> Unicode的漢字大致是以康熙部首排序不過間中有部分字排錯部首筆劃
<span class='line'>1769</span> 第一批在1993年加進Unicode的
<span class='line'>1770</span> 於中國內地、台灣、南韓及日本已有字集的漢字,
<span class='line'>1771</span> 編碼於U+4E00至U+9FA5
<span class='line'>1772</span> 亦有部分南韓重覆漢字被編到U+F900至U+FA0B、
<span class='line'>1773</span> 兩個Big-5重覆漢字被編到U+FA0C至U+FA0D、
<span class='line'>1774</span> 日本廠商漢字被編到U+FA0E至U+FA2D
<span class='line'>1775</span>
<span class='line'>1776</span> 全形符號只限鍵盤上那94個位於U+FF01至U+FF5E
<span class='line'>1777</span> 中日韓專用符號放到了U+3000至U+33FF內
<span class='line'>1778</span> 其餘有部分符號放到了U+2XXX及U+FE30至U+FE6F
<span class='line'>1779</span>
<span class='line'>1780</span> 第二批在1999年加進Unicode的
<span class='line'>1781</span> 加進了新加坡用漢字、南韓PKS C 5700-2 1994、
<span class='line'>1782</span> 部分CNS11643第三、四、十五字面等用字、
<span class='line'>1783</span> 未包括在第一批字的數個GB字集用字
<span class='line'>1784</span> 被編入U+3400至U+4DB5
<span class='line'>1785</span>
<span class='line'>1786</span> 第三批在2001年加進Unicode的
<span class='line'>1787</span> 加進了CNS11643第三、四、五、六、七、十五字面所有字、
<span class='line'>1788</span> 香港增補字集用字、四庫全書、辭海、辭源、康熙字典、
<span class='line'>1789</span> 漢語大字典、漢語大詞典內的所有用字,
<span class='line'>1790</span> 被編入U+20000至U+2A6D6
<span class='line'>1791</span> JIS-X0213漢字被加到U+FA30至U+FA6A
<span class='line'>1792</span> CNS11643重覆漢字被加到U+2F800至U+2FA1D
<span class='line'>1793</span>
<span class='line'>1794</span> 简化字总表 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
<span class='line'>1795</span> 简化字分布似乎並無規範只好以array判斷:
<span class='line'>1796</span>
<span class='line'>1797</span> &lt;div id="dataGB">
<span class='line'>1798</span> http://cdns.twnic.net.tw/cjktable/simtab.html
<span class='line'>1799</span> 簡化字總表之 UNICODE 碼表
<span class='line'>1800</span> &lt;/div>
<span class='line'>1801</span> &lt;div id="dataJP">
<span class='line'>1802</span> http://homepage2.nifty.com/TAB01645/ohara/index_j2.htm
<span class='line'>1803</span> JIS区点索引
<span class='line'>1804</span> &lt;/div>
<span class='line'>1805</span>
<span class='line'>1806</span> &lt;script type="text/javascript">
<span class='line'>1807</span> var i=0,c=0,autodetectEncodeSP=[],m=document.getElementById('dataGB').innerHTML.match(/\([0-9A-F]{4},\w*\)/g),t="setObjValue('autodetectEncodeSP','";
<span class='line'>1808</span> for(;i&lt;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);
<span class='line'>1809</span> if(m[i].indexOf('T')==-1)autodetectEncodeSP[parseInt(m[i].substr(1,4),16)]='C';
<span class='line'>1810</span> for(i=0,m=document.getElementById('dataJP').innerHTML.match(/【.】/g);i&lt;m.length;i++)
<span class='line'>1811</span> autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]=autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]?0:'J';
<span class='line'>1812</span>
<span class='line'>1813</span> m=[];for(i in autodetectEncodeSP)m.push(parseInt(i));m.sort();
<span class='line'>1814</span> for(i=0;i&lt;m.length;i++)if(autodetectEncodeSP[m[i]]){t+=m[i].toString(16)+'='+autodetectEncodeSP[m[i]]+',',c++;if(c%40==0)t+="'&lt;br/>+'";}
<span class='line'>1815</span> alert(c+'字');
<span class='line'>1816</span> document.getElementById('dataJP').innerHTML='';
<span class='line'>1817</span> document.getElementById('dataGB').innerHTML=t.slice(0,-1)+"',1,16);";
<span class='line'>1818</span> &lt;/script>
<span class='line'>1819</span>
<span class='line'>1820</span>
<span class='line'>1821</span> 和製漢字(国字)は、和語(ヤマトコトバ)に相当する漢字が無い場合に新規につくられたもので、奈良時代から作られた。ほとんどは訓読みしかない。魚篇や木篇が多い。
<span class='line'>1822</span> http://homepage2.nifty.com/TAB01645/ohara/index.htm
<span class='line'>1823</span> http://zh.wiktionary.org/wiki/%E8%BE%BB
<span class='line'>1824</span> http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=8fbb
<span class='line'>1825</span> http://jprs.jp/doc/rule/saisoku-1-wideusejp-furoku-4.html
<span class='line'>1826</span> http://m2000.idv.tw/informer/zhi/char-root.htm
<span class='line'>1827</span> http://www.ajisai.sakura.ne.jp/~dindi/chrc/ref/wincode2.txt
<span class='line'>1828</span> http://cs-people.bu.edu/butta1/personal/hkscs/hkscs-oct.html
<span class='line'>1829</span> http://www.nobi.or.jp/i/kotoba/kanji/wasei-kanji.html
<span class='line'>1830</span> http://www.melma.com/mag/52/m00011552/a00000066.html
<span class='line'>1831</span>
<span class='line'>1832</span>
<span class='line'>1833</span> 韓語字母/諺文
<span class='line'>1834</span> http://www.sinica.edu.tw/~cytseng/Korean%20reader/hangul.htm
<span class='line'>1835</span> http://www.unicode.org/charts/normalization/
<span class='line'>1836</span>
<span class='line'>1837</span> old:
<span class='line'>1838</span> // 自動判別檔案(或字串)之編碼
<span class='line'>1839</span> function autodetectEncode(FN){
<span class='line'>1840</span> if(!is_file(FN))return FN.length>64?autodetectStringEncode(FN):simpleFileDformat;
<span class='line'>1841</span> _.open_file(FN,'iso-8859-1');
<span class='line'>1842</span> if(!AdoEnums)return simpleFileDformat;
<span class='line'>1843</span> //AdoStream.Type=AdoEnums.adTypeBinary;
<span class='line'>1844</span> AdoStream.LoadFromFile(FN);
<span class='line'>1845</span> var t=AdoStream.ReadText(3),code;
<span class='line'>1846</span> // Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏它是以FF-FE這兩個bytes表達在BE(big endian)裏是FEFF。而在UTF-8裏它是以EF-BB-BF這三個bytes表達。
<span class='line'>1847</span> if(t.slice(0,2)=='\xFF\xFE')code='unicodeFFFE';
<span class='line'>1848</span> if(t.slice(0,2)=='\xFE\xFF')code='unicode';
<span class='line'>1849</span> if(t=='\xEF\xBB\xBF')code='UTF-8';
<span class='line'>1850</span> if(code){AdoStream.Close();return code;}
<span class='line'>1851</span>
<span class='line'>1852</span> if(!code)with(AdoStream){
<span class='line'>1853</span> // 將sjis排在gb與Big5前面是因為sjis常符合gb且sjis之判定相當嚴。
<span class='line'>1854</span> if(!code)Position=0,Charset='shift_jis',code=autodetectStringEncode(ReadText(900),Charset);
<span class='line'>1855</span> // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字Big5常用字卻常常是gb中奇怪字碼與罕用字
<span class='line'>1856</span> if(!code)Position=0,Charset='GB2312',code=autodetectStringEncode(ReadText(2000),Charset);
<span class='line'>1857</span> if(!code)Position=0,Charset='Big5',code=autodetectStringEncode(ReadText(2000),Charset);
<span class='line'>1858</span> }
<span class='line'>1859</span>
<span class='line'>1860</span> AdoStream.Close();
<span class='line'>1861</span> return code||simpleFileDformat; // ascii=iso-8859-1,_autodetect,_autodetect_all
<span class='line'>1862</span> }
<span class='line'>1863</span> // 靠常用字自動判別字串之編碼 string,預設編碼
<span class='line'>1864</span> function autodetectStringEncode(str,dcode){
<span class='line'>1865</span> var code;
<span class='line'>1866</span> if(str.length>9000)str=str.slice(0,9000);
<span class='line'>1867</span>
<span class='line'>1868</span> // 將sjis排在gb與Big5前面是因為sjis常符合gb且sjis之判定相當嚴。
<span class='line'>1869</span> if(dcode=='shift_jis'||!dcode&&!code){
<span class='line'>1870</span> // http://www.asahi-net.or.jp/~hc3j-tkg/unicode/ http://www.unicode.org/Public/UNIDATA/DerivedCoreProperties.txt
<span class='line'>1871</span> var i=0,c,k=0,u=0,h=0;//h_=u_=k_='';
<span class='line'>1872</span> for(;i&lt;str.length;i++)if(c=str.charCodeAt(i),c>0xFF)
<span class='line'>1873</span> if(c==0x30FB||c>0xFF65&&c&lt;0xFF9E)h++;//,h_+=str.charAt(i);//||c==0xE134 // HALFWIDTH KATAKANA LETTER等可能不是日文文件中會出現的char
<span class='line'>1874</span> else if(c>0x3040&&c&lt;0x30FF)k++;//,k_+=str.charAt(i); // kana
<span class='line'>1875</span> else u++;//,u_+=str.charAt(i); // unknown kanji
<span class='line'>1876</span> //alert(k+','+u+','+h+'\n*'+k_+'\n*'+u_+'\n*'+h_);//alert(u_.charCodeAt(2));
<span class='line'>1877</span> if(k+u>2*h)code='shift_jis'; // HALFWIDTH KATAKANA LETTER數目比漢字少時判別為shift_jis
<span class='line'>1878</span> }
<span class='line'>1879</span>
<span class='line'>1880</span> // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字Big5常用字卻常常是gb中奇怪字碼與罕用字
<span class='line'>1881</span> if(dcode=='Big5'||dcode=='GB2312'||!dcode&&!code){
<span class='line'>1882</span> var i=0,c,k=0,u=0;//k_=u_='';
<span class='line'>1883</span> for(;i&lt;str.length;i++)if(c=str.charCodeAt(i),c>0xFF)
<span class='line'>1884</span> if(c>0x4DFF&&c&lt;0x9FA6||c>0xFF00&&c&lt;0xFF5F||c>0x33ff&&c&lt;0x4DB6||c==0x2605||c==0x2606)k++;//,k_+=str.charAt(i); // 2605,6:★☆
<span class='line'>1885</span> else u++;//,u_+=str.charAt(i);
<span class='line'>1886</span> //alert(k+','+u+'\n'+k_+'\n*'+u_);
<span class='line'>1887</span> if(k>5*u)code=dcode||'Big5'; // 漢字比不認識的字多時判定
<span class='line'>1888</span> }
<span class='line'>1889</span>
<span class='line'>1890</span> if(dcode=='iso-8859-1'||dcode=='ascii'||!dcode&&!code){
<span class='line'>1891</span> }
<span class='line'>1892</span>
<span class='line'>1893</span> return code;
<span class='line'>1894</span> }
<span class='line'>1895</span> */</span><span class="WHIT">
<span class='line'>1896</span>
<span class='line'>1897</span>
<span class='line'>1898</span> </span><span class="COMM">/* 將 iso-8859-1 轉成utf-8
<span class='line'>1899</span> To use:
<span class='line'>1900</span> ..
<span class='line'>1901</span> translated=turnBinStr(original);
<span class='line'>1902</span> ..
<span class='line'>1903</span> translated=turnBinStr(); // delete temp file
<span class='line'>1904</span> */</span><span class="WHIT">
<span class='line'>1905</span> </span><span class="NAME">turnBinStr.temp_file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'turnBinStr.tmp'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// temp file name</span><span class="WHIT">
<span class='line'>1906</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">turnBinStr</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_enc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1907</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1908</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1909</span> </span><span class="WHIT"> </span><span class="NAME">turnBinStr.tmpF</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">turnBinStr.temp_file</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1910</span>
<span class='line'>1911</span> </span><span class="WHIT"> </span><span class="COMM">//t+='';</span><span class="WHIT">
<span class='line'>1912</span> </span><span class="WHIT"> </span><span class="COMM">//if(t.replace(/[^\x00-\x7f]+/g,''))return t;</span><span class="WHIT">
<span class='line'>1913</span> </span><span class="WHIT"> </span><span class="COMM">//var _q=t.replace(/[^?]+/g,'').length,_t,_j=0;</span><span class="WHIT">
<span class='line'>1914</span> </span><span class="WHIT"> </span><span class="NAME">_.write_file</span><span class="PUNC">(</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">+</span><span class="NAME">t</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1915</span> </span><span class="WHIT"> </span><span class="COMM">//alert(turnBinStr.tmpF+'\n'+simpleFileErr.description+'\n'+t+'\n'+_.read_file(turnBinStr.tmpF,'utf-8'));</span><span class="WHIT">
<span class='line'>1916</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_.read_file</span><span class="PUNC">(</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">,</span><span class="STRN">'utf-8'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1917</span> </span><span class="COMM">/*
<span class='line'>1918</span> if(!_enc)_enc='utf-8,Big5,shift_jis,euc-jp,GB2312'.split(',');
<span class='line'>1919</span> else if(!(_enc instanceof Array))_enc=[_enc];
<span class='line'>1920</span> for(;_j&lt;_enc.length;_j++)
<span class='line'>1921</span> if((_t=_.read_file(turnBinStr.tmpF,_enc[_j])).replace(/[^?]+/g,'').length==_q)
<span class='line'>1922</span> return _t;//'['+_enc[_j]+']'+
<span class='line'>1923</span> return t;
<span class='line'>1924</span> */</span><span class="WHIT">
<span class='line'>1925</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1926</span> </span><span class="WHIT"> </span><span class="COMM">// 有時會出錯</span><span class="WHIT">
<span class='line'>1927</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1928</span> </span><span class="WHIT"> </span><span class="NAME">fso.DeleteFile</span><span class="PUNC">(</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1929</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1930</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1931</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1932</span>
<span class='line'>1933</span>
<span class='line'>1934</span>
<span class='line'>1935</span>
<span class='line'>1936</span>
<span class='line'>1937</span> </span><span class="COMM">//folder_info[generateCode.dLK]='initWScriptObj';</span><span class="WHIT">
<span class='line'>1938</span> </span><span class="COMM">// 需同時修改if(traverseSubDirectory==folder_info.f.noNewObj)段落之return!</span><span class="WHIT">
<span class='line'>1939</span>
<span class='line'>1940</span> </span><span class="COMM">//setObjValue('folder_info.f','noNewObj=-1,files,dirs,fsize,size,Tsize=3,Tfiles,Tdirs',1);</span><span class="WHIT">
<span class='line'>1941</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1942</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1943</span> </span><span class="COMM">/**
<span class='line'>1944</span> * Get the infomation of folder
<span class='line'>1945</span> * @param folder_path folder path
<span class='line'>1946</span> * @param file_filter
<span class='line'>1947</span> * @param traverseSubDirectory
<span class='line'>1948</span> * @return
<span class='line'>1949</span> * @example
<span class='line'>1950</span> * var finfo=new folder_info(path or folder object,extFilter,0/1);
<span class='line'>1951</span> * @deprecated 以 &lt;a href="#.traverse_file_system">traverse_file_system&lt;/a> 代替
<span class='line'>1952</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1953</span> */</span><span class="WHIT">
<span class='line'>1954</span> </span><span class="NAME">folder_info</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">,</span><span class="NAME">file_filter</span><span class="PUNC">,</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1955</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="PUNC">,</span><span class="NAME">filesCount</span><span class="PUNC">,</span><span class="NAME">subDirectorysCount</span><span class="PUNC">,</span><span class="NAME">total_size_of_files</span><span class="PUNC">,</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">,</span><span class="NAME">total_filesCount</span><span class="PUNC">,</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1956</span> </span><span class="WHIT"> </span><span class="NAME">filesCount</span><span class="PUNC">=</span><span class="NAME">subDirectorysCount</span><span class="PUNC">=</span><span class="NAME">total_size_of_files</span><span class="PUNC">=</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">=</span><span class="NAME">total_filesCount</span><span class="PUNC">=</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1957</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">traverseSubDirectory</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1958</span>
<span class='line'>1959</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="PUNC">==</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NAME">folder_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1960</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1961</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">folder_path.slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">!=</span><span class="NAME">path_separator</span><span class="PUNC">)</span><span class="NAME">folder_path</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1962</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1963</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1964</span>
<span class='line'>1965</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">dir</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1966</span> </span><span class="WHIT"> </span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">=</span><span class="NAME">subDirectorysCount</span><span class="PUNC">=</span><span class="NAME">dir.SubFolders.Count</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1967</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="NAME">t</span><span class="PUNC">,</span><span class="NAME">f</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.SubFolders</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1968</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">||</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">==</span><span class="NAME">folder_info.f.noNewObj</span><span class="PUNC">)</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1969</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1970</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">folder_info</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="NAME">file_filter</span><span class="PUNC">,</span><span class="NAME">folder_info.f.noNewObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1971</span> </span><span class="WHIT"> </span><span class="COMM">//alert(i.path+'\n'+t[folder_info.f.size]+','+t[folder_info.f.Tfiles]+','+t[folder_info.f.Tdirs]);</span><span class="WHIT">
<span class='line'>1972</span> </span><span class="WHIT"> </span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">folder_info.f.size</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1973</span> </span><span class="WHIT"> </span><span class="NAME">total_filesCount</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tfiles</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1974</span> </span><span class="WHIT"> </span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tdirs</span><span class="PUNC">]</span><span class="PUNC">||</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1975</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1976</span>
<span class='line'>1977</span> </span><span class="WHIT"> </span><span class="COMM">//alert(dir.files.Count+'\n'+total_filesCount);</span><span class="WHIT">
<span class='line'>1978</span> </span><span class="WHIT"> </span><span class="NAME">total_filesCount</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="NAME">filesCount</span><span class="PUNC">=</span><span class="NAME">dir.files.Count</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1979</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.files</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1980</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1981</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1982</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">file_filter</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">file_filter.test</span><span class="PUNC">(</span><span class="NAME">i.name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1983</span> </span><span class="WHIT"> </span><span class="COMM">//if(traverseSubDirectory!=folder_info.f.noNewObj)alert(i.name+': '+i.size+' / '+total_size_of_files);</span><span class="WHIT">
<span class='line'>1984</span> </span><span class="WHIT"> </span><span class="NAME">total_size_of_files</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">i.size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1985</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1986</span>
<span class='line'>1987</span> </span><span class="WHIT"> </span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">total_size_of_files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1988</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1989</span>
<span class='line'>1990</span> </span><span class="WHIT"> </span><span class="COMM">//alert(dir.path+'\nfile filter: '+file_filter+'\n'+filesCount+','+subDirectorysCount+','+total_size_of_files+','+total_size_of_this_folder+','+total_filesCount+','+total_subDirectorysCount);</span><span class="WHIT">
<span class='line'>1991</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">==</span><span class="NAME">folder_info.f.noNewObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1992</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">filesCount</span><span class="PUNC">,</span><span class="NAME">subDirectorysCount</span><span class="PUNC">,</span><span class="NAME">total_size_of_files</span><span class="PUNC">,</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">,</span><span class="NAME">total_filesCount</span><span class="PUNC">,</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1993</span>
<span class='line'>1994</span> </span><span class="WHIT"> </span><span class="NAME">this.files</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.files</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">filesCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1995</span> </span><span class="WHIT"> </span><span class="NAME">this.dirs</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.dirs</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">subDirectorysCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1996</span> </span><span class="WHIT"> </span><span class="NAME">this.fsize</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.fsize</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_size_of_files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1997</span> </span><span class="WHIT"> </span><span class="NAME">this.size</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.size</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1998</span> </span><span class="WHIT"> </span><span class="NAME">this.Tfiles</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tfiles</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_filesCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1999</span> </span><span class="WHIT"> </span><span class="NAME">this.Tdirs</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tdirs</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2000</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2001</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2002</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2003</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2004</span> </span><span class="COMM">/**
<span class='line'>2005</span> * &lt;a href="#.folder_info">folder_info&lt;/a> 的 flag enumeration
<span class='line'>2006</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2007</span> * @constant
<span class='line'>2008</span> */</span><span class="WHIT">
<span class='line'>2009</span> </span><span class="NAME">folder_info.f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2010</span> </span><span class="WHIT"> </span><span class="NAME">noNewObj</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2011</span> </span><span class="WHIT"> </span><span class="NAME">files</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2012</span> </span><span class="WHIT"> </span><span class="NAME">dirs</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2013</span> </span><span class="WHIT"> </span><span class="NAME">fsize</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2014</span> </span><span class="WHIT"> </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2015</span> </span><span class="WHIT"> </span><span class="NAME">Tsize</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2016</span> </span><span class="WHIT"> </span><span class="NAME">Tfiles</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2017</span> </span><span class="WHIT"> </span><span class="NAME">Tdirs</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="WHIT">
<span class='line'>2018</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2019</span>
<span class='line'>2020</span>
<span class='line'>2021</span> </span><span class="COMM">/* list files of folder 改編自 folder_info()
<span class='line'>2022</span> var files=new listFile(path or folder object,extFilter,flag);
<span class='line'>2023</span>
<span class='line'>2024</span> */</span><span class="WHIT">
<span class='line'>2025</span> </span><span class="COMM">//listFile[generateCode.dLK]='initWScriptObj';</span><span class="WHIT">
<span class='line'>2026</span> </span><span class="COMM">// 需同時修改if(flag==listFile.f.noNewObj)段落之return!</span><span class="WHIT">
<span class='line'>2027</span>
<span class='line'>2028</span> </span><span class="COMM">//setObjValue('listFile.f','ignoreCase=1',1);</span><span class="WHIT">
<span class='line'>2029</span> </span><span class="NAME">listFile.f</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2030</span> </span><span class="WHIT"> </span><span class="NAME">ignoreCase</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="WHIT">
<span class='line'>2031</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2032</span>
<span class='line'>2033</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">listFile</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">file_filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2034</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">files</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2035</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2036</span> </span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2037</span>
<span class='line'>2038</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2039</span> </span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2040</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2041</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">folder_path.slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2042</span> </span><span class="WHIT"> </span><span class="NAME">folder_path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2043</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2044</span> </span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2045</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2046</span> </span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2047</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2048</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2049</span>
<span class='line'>2050</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dir</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2051</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.files</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2052</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2053</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2054</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">file_filter</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">file_filter.test</span><span class="PUNC">(</span><span class="NAME">i.name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2055</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2056</span> </span><span class="WHIT"> </span><span class="NAME">files.push</span><span class="PUNC">(</span><span class="NAME">i.name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2057</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2058</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2059</span>
<span class='line'>2060</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2061</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2062</span>
<span class='line'>2063</span>
<span class='line'>2064</span>
<span class='line'>2065</span>
<span class='line'>2066</span>
<span class='line'>2067</span>
<span class='line'>2068</span> </span><span class="COMM">/*
<span class='line'>2069</span> in UNIX:
<span class='line'>2070</span> iconv -l
<span class='line'>2071</span> iconv -c -f UTF-16 -t BIG5-HKSCS function.js
<span class='line'>2072</span>
<span class='line'>2073</span> */</span><span class="WHIT">
<span class='line'>2074</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2075</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2076</span> </span><span class="COMM">/**
<span class='line'>2077</span> * 將編碼為fromCode之檔案fileName中所有不合編碼toCode之char以encodeFunction轉換
<span class='line'>2078</span> * @param fileName
<span class='line'>2079</span> * @param toCode
<span class='line'>2080</span> * @param fromCode
<span class='line'>2081</span> * @param encodeFunction
<span class='line'>2082</span> * @return
<span class='line'>2083</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2084</span> */</span><span class="WHIT">
<span class='line'>2085</span> </span><span class="NAME">iconv_file</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fileName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">toCode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fromCode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2086</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">iconv</span><span class="PUNC">(</span><span class="NAME">_.read_file</span><span class="PUNC">(</span><span class="NAME">fileName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fromCode</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">toCode</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2087</span> </span><span class="WHIT"> </span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2088</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2089</span>
<span class='line'>2090</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2091</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2092</span> </span><span class="COMM">/* 將string text中所有不合編碼toCode之char以encodeFunction轉換
<span class='line'>2093</span> convert string encoding&lt;br/>
<span class='line'>2094</span>
<span class='line'>2095</span> CeL.iconv('測試每個字元 abc あaいiうuえeおo','Big5')
<span class='line'>2096</span>
<span class='line'>2097</span> TODO:
<span class='line'>2098</span> 一次寫入多 bytes
<span class='line'>2099</span> */</span><span class="WHIT">
<span class='line'>2100</span> </span><span class="COMM">//var iconvError=[];</span><span class="WHIT">
<span class='line'>2101</span> </span><span class="NAME">iconv</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">toCode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2102</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2103</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2104</span>
<span class='line'>2105</span> </span><span class="WHIT"> </span><span class="COMM">// alert('iconv: ['+toCode+']\n'+text.slice(0,200));</span><span class="WHIT">
<span class='line'>2106</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="REGX">/utf-?(8|16([bl]e)?)/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">toCode</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2107</span> </span><span class="WHIT"> </span><span class="COMM">// skip Unicode</span><span class="WHIT">
<span class='line'>2108</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">HTMLToUnicode</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2109</span>
<span class='line'>2110</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">toCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2111</span> </span><span class="WHIT"> </span><span class="COMM">// error occurred</span><span class="WHIT">
<span class='line'>2112</span> </span><span class="WHIT"> </span><span class="NAME">iconvError</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2113</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="PUNC">(</span><span class="NAME">iconvError.message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2114</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2115</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2116</span>
<span class='line'>2117</span> </span><span class="WHIT"> </span><span class="COMM">// AdoStream.Type=AdoEnums.adTypeText;</span><span class="WHIT">
<span class='line'>2118</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2119</span> </span><span class="WHIT"> </span><span class="NAME">encodeFunction</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>2120</span> </span><span class="WHIT"> </span><span class="COMM">// typeof toHTML ==='function' ? totoHTML:</span><span class="WHIT">
<span class='line'>2121</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2122</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'\\u'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2123</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2124</span> </span><span class="WHIT"> </span><span class="COMM">// iconvError=[];</span><span class="WHIT">
<span class='line'>2125</span>
<span class='line'>2126</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charToSet</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2127</span> </span><span class="WHIT"> </span><span class="COMM">// 測試每個字元</span><span class="WHIT">
<span class='line'>2128</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">text.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2129</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2130</span> </span><span class="WHIT"> </span><span class="NAME">charToSet</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.charAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2131</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">charToSet.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">256</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2132</span> </span><span class="WHIT"> </span><span class="COMM">// 對於 code 過小的,直接匯入以增加速度。</span><span class="WHIT">
<span class='line'>2133</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charToSet</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2134</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2135</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2136</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Position</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2137</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.WriteText</span><span class="PUNC">(</span><span class="NAME">charToSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2138</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Position</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2139</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charToSet</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadAll</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">charToSet</span><span class="WHIT">
<span class='line'>2140</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">encodeFunction</span><span class="PUNC">(</span><span class="NAME">charToSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2141</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2142</span> </span><span class="WHIT"> </span><span class="COMM">//iconvError.push(e.description);</span><span class="WHIT">
<span class='line'>2143</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeFunction</span><span class="PUNC">(</span><span class="NAME">charToSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2144</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2145</span>
<span class='line'>2146</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2147</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2148</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2149</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2150</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2151</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2152</span>
<span class='line'>2153</span>
<span class='line'>2154</span>
<span class='line'>2155</span> </span><span class="COMM">//---------------------------------------------------</span><span class="WHIT">
<span class='line'>2156</span>
<span class='line'>2157</span>
<span class='line'>2158</span> </span><span class="COMM">/*
<span class='line'>2159</span> var driverProperty,folderProperty,fileProperty;
<span class='line'>2160</span> setObjValue('driverProperty','AvailableSpace,DriveLetter,DriveType,FileSystem,FreeSpace,IsReady,Path,RootFolder,SerialNumber,ShareName,TotalSize,VolumeName',1,setObjValueFlag.array);
<span class='line'>2161</span> setObjValue('folderProperty','Attributes,DateCreated,DateLastAccessed,DateLastModified,Drive,Name,ParentFolder,Path,ShortName,ShortPath,Size,Type,Files,IsRootFolder,SubFolders',1,setObjValueFlag.array);//Files起為Folder property
<span class='line'>2162</span> fileProperty=folderProperty.slice(0,12);//folderProperty.sort();
<span class='line'>2163</span> */</span><span class="WHIT">
<span class='line'>2164</span>
<span class='line'>2165</span>
<span class='line'>2166</span> </span><span class="COMM">//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');</span><span class="WHIT">
<span class='line'>2167</span> </span><span class="COMM">/*
<span class='line'>2168</span>
<span class='line'>2169</span> _.traverse_file_system(FS_function_array) 省略path會當作所有Drives
<span class='line'>2170</span> _.traverse_file_system(FS_function_array,'c:') c:→c:\→sub dir of c:\
<span class='line'>2171</span> _.traverse_file_system(FS_function_array,'c:\\') c:\→sub dir of c:\
<span class='line'>2172</span> _.traverse_file_system(FS_function_array,'c:\\cc') c:\cc,cc為dir→sub dir of c:\cc\
<span class='line'>2173</span> _.traverse_file_system(FS_function_array,'c:\\cc\\') c:\cc\→sub dir of c:\cc\
<span class='line'>2174</span> _.traverse_file_system(FS_function_array,['c:\\cc\\','d:\\dd']) c:\cc\→sub dir of c:\cc\→d:\dd→sub dir of d:\dd
<span class='line'>2175</span> _.traverse_file_system([,folderFunction],'.');
<span class='line'>2176</span>
<span class='line'>2177</span>
<span class='line'>2178</span> _.traverse_file_system([,folderFunction],basePath);
<span class='line'>2179</span> function folderFunction(folderItem){
<span class='line'>2180</span> t=folderItem.Path.slice(same_length(basePath,folderItem.Path));
<span class='line'>2181</span> //if(t==folderItem.Name) // 僅單層subdir次目錄
<span class='line'>2182</span> //if(t.indexOf(path_separator)==t.lastIndexOf(path_separator)) // 僅單層及次層subdir次目錄
<span class='line'>2183</span> if(t.replace(new RegExp('[^'+path_separator_RegExp+']','g'),'').length&lt;3) // 僅3層subdir以下
<span class='line'>2184</span> ;
<span class='line'>2185</span> }
<span class='line'>2186</span>
<span class='line'>2187</span>
<span class='line'>2188</span> // itemType=0:file/1:folder/2:driver
<span class='line'>2189</span> function fsoFunction(fsi,itemType){if(!itemType){}}
<span class='line'>2190</span> function fileFunction(fileItem){}
<span class='line'>2191</span> function folderFunction(folderItem){}
<span class='line'>2192</span> function driverFunction(driverItem){}
<span class='line'>2193</span>
<span class='line'>2194</span> filter:
<span class='line'>2195</span> file_filter 僅單一 filter 時預設當作 file_filter, should has NO global flag.
<span class='line'>2196</span> [file_filter,folder_filter]
<span class='line'>2197</span> file_filter 篩選檔案, should has NO global flag.
<span class='line'>2198</span> folder_filter 篩選資料夾, should has NO global flag.
<span class='line'>2199</span>
<span class='line'>2200</span>
<span class='line'>2201</span> tip:
<span class='line'>2202</span> 使用相對路徑,如'..'開頭時需用getFP()調整過。
<span class='line'>2203</span> 用folder.Size==0可判別是否為empty folder
<span class='line'>2204</span>
<span class='line'>2205</span> TODO:
<span class='line'>2206</span> 限定traverse深度幾層,sort=8,preOrder=0,widthFirst=0,postOrder=16,depthFirst=16
<span class='line'>2207</span> */</span><span class="WHIT">
<span class='line'>2208</span> </span><span class="COMM">//_.traverse_file_system.stop=false;</span><span class="WHIT">
<span class='line'>2209</span>
<span class='line'>2210</span> </span><span class="COMM">//_.traverse_file_system[generateCode.dLK]='initWScriptObj';</span><span class="WHIT">
<span class='line'>2211</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2212</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2213</span> </span><span class="COMM">/**
<span class='line'>2214</span> * 巡覽 file system 的公用函數
<span class='line'>2215</span> * @param FS_function_array file system handle function array
<span class='line'>2216</span> * @param path target path
<span class='line'>2217</span> * @param filter filter
<span class='line'>2218</span> * @param flag see &lt;a href="#.traverse_file_system.f">flag&lt;/a>
<span class='line'>2219</span> * @return
<span class='line'>2220</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2221</span> * @see &lt;a href="http://msdn.microsoft.com/library/en-us/script56/html/0fa93e5b-b657-408d-9dd3-a43846037a0e.asp">FileSystemObject&lt;/a>
<span class='line'>2222</span> */</span><span class="WHIT">
<span class='line'>2223</span> </span><span class="NAME">traverse_file_system</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">traverse_file_system</span><span class="PUNC">(</span><span class="NAME">FS_function_array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2224</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.traverse_file_system</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s.f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2225</span>
<span class='line'>2226</span> </span><span class="WHIT"> </span><span class="COMM">// initial</span><span class="WHIT">
<span class='line'>2227</span> </span><span class="WHIT"> </span><span class="COMM">// 預設 flag</span><span class="WHIT">
<span class='line'>2228</span> </span><span class="WHIT"> </span><span class="COMM">// if(isNaN(flag))flag=_f.traverse;</span><span class="WHIT">
<span class='line'>2229</span>
<span class='line'>2230</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system:\n[' + path + ']');</span><span class="WHIT">
<span class='line'>2231</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2232</span> </span><span class="WHIT"> </span><span class="COMM">// or FS_function_array=[,,]: 可以使用 Array 常值中的空白元素來建立零星稀疏的陣列。</span><span class="WHIT">
<span class='line'>2233</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">_f.func_length</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2234</span> </span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2235</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2236</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'>2237</span> if (FS_function_array instanceof Array && FS_function_array.length == 1)
<span class='line'>2238</span> FS_function_array = FS_function_array[0];
<span class='line'>2239</span> */</span><span class="WHIT">
<span class='line'>2240</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2241</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2242</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2243</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2244</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2245</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system: fso:\n[' + fso + ']');</span><span class="WHIT">
<span class='line'>2246</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2247</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">FS_function_array.length</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2248</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2249</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']');</span><span class="WHIT">
<span class='line'>2250</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">filter</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2251</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2252</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">filter</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2253</span> </span><span class="WHIT"> </span><span class="COMM">// filter=[filter,filter]; 通常我們輸入的只會指定 file filter</span><span class="WHIT">
<span class='line'>2254</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2255</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2256</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2257</span>
<span class='line'>2258</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']');</span><span class="WHIT">
<span class='line'>2259</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fc</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">traverse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.no_traverse</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">objBuf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">folder_filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">testFilter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>2260</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2261</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2262</span> </span><span class="WHIT"> </span><span class="COMM">// f instanceof RegExp</span><span class="WHIT">
<span class='line'>2263</span> </span><span class="WHIT"> </span><span class="NAME">f.test</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2264</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2265</span> </span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2266</span> </span><span class="WHIT"> </span><span class="COMM">// throw new Error(e.number,'traverse_file_system: 錯誤的 filter:\n'+f+'\n'+e.description);</span><span class="WHIT">
<span class='line'>2267</span> </span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'traverse_file_system: 錯誤的 filter:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="WHIT">
<span class='line'>2268</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2269</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2270</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2271</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2272</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2273</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2274</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="NAME">filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2275</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>2276</span> </span><span class="WHIT"> </span><span class="NAME">testFilter</span><span class="PUNC">(</span><span class="NAME">filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2277</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">folder_filter</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2278</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">folder_filter</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2279</span> </span><span class="WHIT"> </span><span class="NAME">folder_filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="NAME">folder_filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2280</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>2281</span> </span><span class="WHIT"> </span><span class="NAME">testFilter</span><span class="PUNC">(</span><span class="NAME">folder_filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2282</span> </span><span class="WHIT"> </span><span class="COMM">// if(flag!=_f.get_object)alert(filter+'\n'+folder_filter);</span><span class="WHIT">
<span class='line'>2283</span> </span><span class="WHIT"> </span><span class="COMM">// 至此 filter 代表 file_filter, vs. folder_filter</span><span class="WHIT">
<span class='line'>2284</span>
<span class='line'>2285</span>
<span class='line'>2286</span> </span><span class="WHIT"> </span><span class="COMM">// 轉換輸入之各項成fso object</span><span class="WHIT">
<span class='line'>2287</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// 取得各個driver code</span><span class="WHIT">
<span class='line'>2288</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2289</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2290</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">drivers</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">fso.Drives</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">drivers.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">drivers</span><span class="WHIT">
<span class='line'>2291</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2292</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">drivers.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>2293</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.driver</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2294</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2295</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2296</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">path.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2297</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">path.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2298</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">(</span><span class="NAME">_f.get_object</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2299</span> </span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2300</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2301</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2302</span> </span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">path.IsReady</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_f.driver</span><span class="WHIT">
<span class='line'>2303</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">path.IsRootFolder</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_f.folder</span><span class="WHIT">
<span class='line'>2304</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">path.Path</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_f.file</span><span class="WHIT">
<span class='line'>2305</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">_f.NULL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2306</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_f.NULL</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2307</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2308</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2309</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2310</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// fault</span><span class="WHIT">
<span class='line'>2311</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2312</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2313</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>2314</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.folder</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2315</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2316</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">// fso.FolderExists()</span><span class="WHIT">
<span class='line'>2317</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2318</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2319</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>2320</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.file</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2321</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2322</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">// fso.FileExists()</span><span class="WHIT">
<span class='line'>2323</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">fso.GetDriveName</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2324</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2325</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">fso.GetDrive</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>2326</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.driver</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2327</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2328</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2329</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2330</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2331</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">objBuf</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">objBuf</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2332</span>
<span class='line'>2333</span> </span><span class="WHIT"> </span><span class="COMM">// FS_function_array.length=_f.func_length;</span><span class="WHIT">
<span class='line'>2334</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">_f.func_length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2335</span> </span><span class="WHIT"> </span><span class="COMM">// 可以安排僅對folder或是file作用之function</span><span class="WHIT">
<span class='line'>2336</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2337</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2338</span> </span><span class="WHIT"> </span><span class="COMM">//alert(objBuf.length+','+typeBuf.length+'\n'+typeBuf);</span><span class="WHIT">
<span class='line'>2339</span> </span><span class="WHIT"> </span><span class="COMM">// main loop</span><span class="WHIT">
<span class='line'>2340</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">_s.stop</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">objBuf.length</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2341</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">objBuf.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// fsoFunction執行途中可能將此項目刪除</span><span class="WHIT">
<span class='line'>2342</span> </span><span class="WHIT"> </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">iType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">typeBuf.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2343</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">_f.folder</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2344</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">folder_filter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">folder_filter.test</span><span class="PUNC">(</span><span class="NAME">item.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2345</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">iType</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2346</span> </span><span class="WHIT"> </span><span class="COMM">// if(traverse||traverse!==0){</span><span class="WHIT">
<span class='line'>2347</span> </span><span class="WHIT"> </span><span class="COMM">// if(!traverse)traverse=0; // 加上次一層: 會連這次一層之檔案都加上去。</span><span class="WHIT">
<span class='line'>2348</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">traverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2349</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">item.SubFolders</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fc.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT">
<span class='line'>2350</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2351</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fc.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">folder_filter</span><span class="WHIT">
<span class='line'>2352</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">folder_filter.test</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2353</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>2354</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.folder</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2355</span> </span><span class="WHIT"> </span><span class="COMM">// }</span><span class="WHIT">
<span class='line'>2356</span> </span><span class="WHIT"> </span><span class="COMM">// try 以防item已經被刪除</span><span class="WHIT">
<span class='line'>2357</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2358</span> </span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">item.Files</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2359</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2360</span> </span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2361</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2362</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2363</span> </span><span class="WHIT"> </span><span class="COMM">// for(;!fc.atEnd();fc.moveNext())if(i=fc.item(),!filter||filter.test(i.Name))FS_function_array[_f.file](i,_f.file);</span><span class="WHIT">
<span class='line'>2364</span> </span><span class="WHIT"> </span><span class="COMM">// 因為檔案可能因改名等改變順序,因此用.moveNext()的方法可能有些重複,有些漏掉未處理。</span><span class="WHIT">
<span class='line'>2365</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fc.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">fc.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2366</span> </span><span class="WHIT"> </span><span class="NAME">item.push</span><span class="PUNC">(</span><span class="NAME">fc.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2367</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2368</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">filter.test</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2369</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">_f.file</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2370</span> </span><span class="WHIT"> </span><span class="NAME">_f.file</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2371</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2372</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2373</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">_f.file</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2374</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">filter.test</span><span class="PUNC">(</span><span class="NAME">item.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2375</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">iType</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2376</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2377</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">_f.driver</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2378</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">item.IsReady</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2379</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2380</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">iType</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2381</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">traverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2382</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">item.RootFolder</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>2383</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.folder</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2384</span> </span><span class="WHIT"> </span><span class="COMM">// break;</span><span class="WHIT">
<span class='line'>2385</span> </span><span class="WHIT"> </span><span class="COMM">//default:break;</span><span class="WHIT">
<span class='line'>2386</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2387</span>
<span class='line'>2388</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2389</span>
<span class='line'>2390</span>
<span class='line'>2391</span> </span><span class="COMM">//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</span><span class="WHIT">
<span class='line'>2392</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2393</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2394</span> </span><span class="COMM">/**
<span class='line'>2395</span> * &lt;a href="#.traverse_file_system">traverse_file_system&lt;/a> 的 flag enumeration
<span class='line'>2396</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2397</span> * @constant
<span class='line'>2398</span> */</span><span class="WHIT">
<span class='line'>2399</span> </span><span class="NAME">traverse_file_system.f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>2400</span> </span><span class="NAME">traverse_file_system.f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2401</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2402</span> * return object
<span class='line'>2403</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2404</span> */</span><span class="WHIT">
<span class='line'>2405</span> </span><span class="WHIT"> </span><span class="NAME">get_object</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2406</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2407</span> * null flag
<span class='line'>2408</span> * @private
<span class='line'>2409</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2410</span> */</span><span class="WHIT">
<span class='line'>2411</span> </span><span class="WHIT"> </span><span class="NAME">NULL</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2412</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2413</span> * 用於指示 file
<span class='line'>2414</span> * @private
<span class='line'>2415</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2416</span> */</span><span class="WHIT">
<span class='line'>2417</span> </span><span class="WHIT"> </span><span class="NAME">file</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2418</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2419</span> * 用於指示 folder
<span class='line'>2420</span> * @private
<span class='line'>2421</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2422</span> */</span><span class="WHIT">
<span class='line'>2423</span> </span><span class="WHIT"> </span><span class="NAME">folder</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2424</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2425</span> * 用於指示 driver
<span class='line'>2426</span> * @private
<span class='line'>2427</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2428</span> */</span><span class="WHIT">
<span class='line'>2429</span> </span><span class="WHIT"> </span><span class="NAME">driver</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2430</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2431</span> * handle function 應有的長度
<span class='line'>2432</span> * @private
<span class='line'>2433</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2434</span> */</span><span class="WHIT">
<span class='line'>2435</span> </span><span class="WHIT"> </span><span class="NAME">func_length</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2436</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2437</span> * 深入下層子目錄及檔案
<span class='line'>2438</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2439</span> */</span><span class="WHIT">
<span class='line'>2440</span> </span><span class="WHIT"> </span><span class="NAME">traverse</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2441</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>2442</span> * 不深入下層子目錄及檔案
<span class='line'>2443</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2444</span> */</span><span class="WHIT">
<span class='line'>2445</span> </span><span class="WHIT"> </span><span class="NAME">no_traverse</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT">
<span class='line'>2446</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2447</span>
<span class='line'>2448</span>
<span class='line'>2449</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>2450</span> </span><span class="WHIT"> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2451</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2452</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2453</span>
<span class='line'>2454</span> </span><span class="COMM">//===================================================</span><span class="WHIT">
<span class='line'>2455</span>
<span class='line'>2456</span> </span><span class="NAME">CeL.setup_module</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2457</span>
<span class='line'>2458</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2459</span> </span></pre></body></html>