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

📄 utils.csp

📁 c-smile 一个语法类似与JS 又有点像C++的 编译器
💻 CSP
字号:
package utils;

function format_date(d) 
{ 
  //Apr 29 1994
  return date(d).format("%b %d %Y"); 
}
function format_node_atts(n) 
{ 
  return string::printf("%c------%c%c%c",
      (n.is_folder?'d':'-'),
      (n.can_read?'r':'-'), 
      (n.can_write?'w':'-'),
      (n.can_exec?'x':'-')); 
}

//|
//|  path with base
//|
class path 
{
  var _base_path;
  var _path;
//|
//|  constructor
//|
  function path(base_path) 
  {
    _base_path = base_path || "";
    _path = new array();
  }
//|
//|  constructor
//|
  property base(base_path) 
  {
    if(base_path) {
      _base_path = base_path;
      _path.clear();
    }
    return _base_path;
  }
//|
//|  returns path relative to base
//|
  function rel_path() 
  {
    var i,s = "";
    for(i = 0; i < _path.length; i++) { s += ("/" + _path[i]); }
    return s;
  }
//|
//|  map_path
//|
  function map(file_name)  
  { 
    if(file_name)
    {
       if(file_name[0] == '/') return _base_path + file_name;
       return _base_path + rel_path() + "/" + file_name; 
    }
    return _base_path + rel_path(); 
  }
//|
//|  change dir
//|
  function change(prm)
  {
    var save;  
    if(prm == ".") ; // do nothing
    else if (prm == "..") { save = new array(_path); _path.pop(); } // just drop last element
    else if (prm.like("*..*") || prm.like("*//*")) // h-m-m, what about ../.. ? should we support it?
    {
      return false;
    }
    else if (prm.like("/*")) //we've got absolute (from the root) path
    {
      save = new array(_path);
      _path.clear();
      _path = prm.split('/');
    }
    else if (prm.like("*/*"))
    {
      save = new array(_path);
      var p = prm.split('/'); 
      _path.concat(p);  
    }
    else 
    {
      save = new array(_path);
      _path.push(prm);
    }

    //check existence
    var n = new node(map());
    if (!n.is_folder) 
    {
        if(save) _path = save;
        return false;
    }
    return true;
  }
}


⌨️ 快捷键说明

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