text: var fs = require('fs');
  
  var Result = require('./Result');
  var Errors = require('./Errors');
  
  var Common = function() {
  }
  
  Common.prototype.check_array = function(a) {
      if (a instanceof Array)
          return a;
      var ret = [];
      if(a) ret[0] = a;
      return ret;
  };
  
  Common.prototype.create_dir = function(dir, h){
      //console.log(arguments);
  
      f_mkdir(dir, h);
  
      function f_mkdir(path, cb, i){
  
          if(!i) i = 1;
  
          var a = path.split('/');
  
          if(i>a.length){
              cb(null, path);
              return;
          }
  
          var dir_name = a.splice(0,i);
          //console.log(dir_name);
  
          if('.'==dir_name.join('/')) {
              ++i;
              dir_name = a.splice(0,i);
          }
          if('..'==dir_name.join('/')) {
              ++i;
              dir_name = a.splice(0,i);
          }
          //console.log(dir_name);
  
          dir_name = dir_name.join('/');
  
          fs.mkdir(dir_name, function(e,o){
              if(e){
                  if(47==e.errno){
                      f_mkdir(path, cb, ++i);
                  } else {
                      cb(e);
                  }
              } else {
                  f_mkdir(path, cb, ++i);
              }
          });
      }
  }
  
  Common.prototype.copy_object = function(o){
      return JSON.parse(JSON.stringify(o));
  }
  
  Common.prototype.write_file = function(fn, data, h){
      var self = this;
  
      var ret = new Result(h, arguments, '');
  
      var a = fn.split('/');
      var f = a.splice(a.length-1, 1)[0];
      var dir = a.join('/');
  
      self.create_dir(dir, ret.checkError(Errors.common.create_dir, dir_created));
  
      function dir_created(dir_name){
          fs.writeFile(dir+'/'+f, data, ret.checkError(Errors.common.write_file));
      }
  }
  
  /*
  Common.prototype.write_file_sync = function(fn, data, timeout){
      if(!timeout){
          timeout = 10*1000;
      }
  
      var sleep = function(ms) {
          ms += new Date().getTime();
          while (new Date() < ms){}
      }
  
      var done = false;
      var r;
      this.write_file(fn, data, function(e, o){
          r = (e)?false:true;
          done = true;
      });
  
      var t = 0;
      while(!done){
          this.sleep(10);
          t += 10;
          if(t>=timeout){
              r = false;
              break;
          }
      }
  
      return r;
  }
  */
  
  Common.prototype.formatNdigit = function(n, t){
      var formated = t.toString();
      var str = '';
      for(var i=0; i<n; i++) str += '0';
      return str.substr(1, str.length-formated.length) + formated;
  }
  
  module.exports = new Common();