?? eol.csp
字號:
package eol;
function cvt_file_2unix(node)
{
var ins = node.stream("r");
var outn = new node(node.path);
outn.extension = "~~~";
var outs = outn.stream("w");
while(true) {
var line = ins.get("\r\n");
if( is_null(line) ) break;
}
ins.close();
outs.close();
node.remove();
outn.rename(node.path);
}
function cvt_file_2dos(node)
{
var ins = node.stream("rb");
var outn = new node(node.path);
outn.extension = "~~~";
var outs = outn.stream("wb");
while(true) {
var line = ins.get("\n");
if( is_null(line) ) break;
outs.printf("%s\r\n",line);
}
ins.close();
outs.close();
node.remove();
outn.rename(node.path);
}
function cvt_file_repair(node)
{
var ins = node.stream("rb");
var outn = new node(node.path);
outn.extension = "~~~";
var outs = outn.stream("wb");
ins.position = 0;
while(true) {
var line = ins.get("\r\n");
if( is_null(line) ) break;
line = line.replace("\r","","\n","");
outs.printf("%s\r\n",line);
}
ins.close();
outs.close();
node.remove();
outn.rename(node.path);
}
var ext_filter = new regexp("^(cpp|cxx|c|hpp|hxx|h|csp)$");
function cvt_file(node,direction)
{
var ext = node.extension.to_lower();
out.printf("%s ", node.path);
if( ext_filter.test(ext) )
{
if(direction == "2unix")
cvt_file_2unix(node);
else if(direction == "2dos")
cvt_file_2dos(node);
else
cvt_file_repair(node);
out.printf("converted\n");
}
else
out.printf("skipped\n");
}
function cvt_folder(nin,direction)
{
if( nin.is_folder )
{
var i, narray = nin.nodes("*.*");
for(i = 0; i < narray.length; i++) cvt_folder(narray[i],direction);
}
else if(nin.is_file) cvt_file(nin,direction);
}
function main(folder_name_in,direction_in) {
if(!folder_name_in && !direction_in)
{
out.printf("unix2dos or dos2unix eol file converter\n");
out.printf("USAGE: eol folder_or_file_name 2unix|2dos\n");
}
var nin = new node(folder_name_in);
cvt_folder(nin,direction_in);
out.printf("done.\n");
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -