pakmanaged.js
function writeableDir(dir) {
      if (!dir || !fs.existsSync(dir))
        return false;
    
      if (!fs.statSync(dir).isDirectory())
        return false;
    
      var testFile = dir+'/'+common.randomFileName();
      try {
        fs.writeFileSync(testFile, ' ');
        common.unlinkSync(testFile);
        return dir;
      } catch (e) {
        return false;
      }
    }
function writeableDir(dir) {
      if (!dir || !fs.existsSync(dir))
        return false;
    
      if (!fs.statSync(dir).isDirectory())
        return false;
    
      var testFile = dir+'/'+common.randomFileName();
      try {
        fs.writeFileSync(testFile, ' ');
        common.unlinkSync(testFile);
        return dir;
      } catch (e) {
        return false;
      }
    }
Returns false if 'dir' is not a writeable directory, 'dir' otherwise