Creates any subfolders we need for a given filevault key. If any errors occur during folder
creation an error is returned via the callback.

@param {String} key
@param {String} fullPath
@param {Function} cb
970173
function createKeyFolders(key, fullPath, cb) {
	// NOTE: We check after first character, since a leading slash will be omitted by path.join
	if (key.indexOf(path.sep) <= 0) {
		return cb();
	}

	mkdirp(path.dirname(fullPath), cb);
}
380598
function ftpProcessLocation(inPath, cb) {
    if (!toTransfer[inPath]) {
      cb(new Error('Data for ' + inPath + ' not found'));
    }
    ftpCwd('/' + remoteRoot + '/' + inPath.replace(/\\/gi, '/'), function(err) {
      var files;

      if (err) {
        grunt.warn('Could not switch to remote folder!');
      }

      currPath = inPath;
      files = toTransfer[inPath];
      async.forEach(files, ftpPut, function(err) {
        if (err) {
          grunt.warn('Failed uploading files!');
        }
        cb(null);
      });
    });
  }
713433
function(key, fn) {
    var self = this;
    var filepath = this._makeFilepath(key);

    fs.exists(filepath, function(exists) {
      if (!exists) {
        return fn();
      }

      fs.readFile(filepath, 'UTF8', function(err, data) {
        if (err) {
          return fn(err);
        }

        var cache = JSON.parse(data);

        if (!self._cacheIsValid(cache)) {
          return self.del(key, fn);
        }
        fn(null, cache.data);
      });

    });
  }
458657
function (ds, acc, m, cb) {
    if (ds.length > 0) {
      var d = ds.shift();

      acc.push(d);
      var dir = acc.join(path.sep);

      // look for dir on the fs, if it doesn't exist then create it, and 
      // continue our walk, otherwise if it's a file, we have a name
      // collision, so exit.
      fs.stat(dir, function (err, stat) {
        // if the directory doesn't exist then create it
        if (err) {
          // 2 means it's wasn't there
          if (err.errno == 2 || err.errno == 34) {
            fs.mkdir(dir, m, function (erro) {
              if (erro && erro.errno != 17 && erro.errno != 34) {
                return cb(erro);
              } else {
                return walk(ds, acc, m, cb);
              }
            });
          } else {
            return cb(err);
          }
        } else {
          if (stat.isDirectory()) {
            return walk(ds, acc, m, cb);
          } else {
            return cb(new Error("Failed to mkdir " + dir + ": File exists\n"));
          }
        }
      });
    } else {
      return cb();
    }
  }
1291280
function createResultFolder(folderName) {
        var folder = path.join(resultsDir, folderName);

        debug('Creating the folder %s', folderName);

        return createGlobalFolder().then(function() {
            return Q.nfcall(fs.mkdir, folder);
        });
    }
663070
function checkStatFile(p, cb) {
  var fullPath = path.resolve(p)
    , json;
  try {
    json = require(fullPath);
  } catch (e) {
    if (e.code == 'MODULE_NOT_FOUND') {
      return cb(null,false);
    } else {
      // eslint-disable-next-line no-console
      console.error('require("' + fullPath + '") failed', e);
      return cb(e);
    }
  }
  return cb(null, json);
}
383299
function mkdir(dest, cb) {
  var dir = path.dirname(path.resolve(dest));
  utils.mkdirp(dir, function(err) {
    if (err && err.code !== 'EEXIST') {
      err.message = formatError('mkdirp cannot create directory', dir, err);
      return cb(new Error(err));
    }
    cb();
  });
}
449809
function accessFromSnapshot (path_, cb) {
    var cb2 = cb || rethrow;
    var path = normalizePath(path_);
    // console.log("accessFromSnapshot", path);
    var entity = VIRTUAL_FILESYSTEM[path];
    if (!entity) return cb2(error_ENOENT('File or directory', path));
    return cb2(null, undefined);
  }
1320789
function watchFile(file, cb, partial) {
    setAbsolutePath(file);
    storeDirectory(file);
    if (!watched_files[file.fullPath]) {
      if (use_fs_watch) {
        (function() {
          watched_files[file.fullPath] = fs.watch(file.fullPath, function() {
            typeof cb === "function" && cb(file);
          });
          partial && cb(file);
        })(file, cb);
      } else {
        (function(file, cb) {
          watched_files[file.fullPath] = true;
          fs.watchFile(file.fullPath, {interval: 150}, function() {
            typeof cb === "function" && cb(file);
          });
          partial && cb(file);
        })(file, cb);
      }
    }
  }
538254
function iterateRecurse (dir, options, cb) {
  try {
    var files = fs.readdirSync(dir)
    files.forEach(function (file, index) {
      var parsedPath = path.parse(file)
      var name = parsedPath.name
      var ext = parsedPath.ext
      var srcpath = path.join(dir, file)

      if (options.skip_ && name.charAt(0) === '_') {
        logger.debug('Skipping file/folder: ' + srcpath)
      } else {
        if (fs.lstatSync(srcpath).isDirectory()) {
          if (options.dirs) {
            cb(srcpath, name)
          }

          // Do recursive search when needed
          if (options.recursive) {
            iterateRecurse(srcpath, options, cb)
          }
        } else {
          for (var i = 0; i < options.ext.length; i++) {
            if (ext === options.ext[i]) {
              cb(srcpath, name, ext)
            }
          }
        }
      }
    })
  } catch (e) {
    logger.debug('Error iterating files: ' + e)
  }
}
1218479
function(name, data, enc, cbfscreatefile) {
        jsDAV_FS_Directory.createFile.call(this, name, data, enc,
            afterCreateFile.bind(this, name, cbfscreatefile));
    }
284988
public void pushNestedPath(final String subPath, final String key) {
        final String canonicalPath = normalizePath(subPath);
        ArgUtils.notEmpty(subPath, "subPath");
        ArgUtils.notEmpty(key, "key");
        
        pushNestedPath(String.format("%s[%s]", canonicalPath, key));
    }
536392
function (folder, oldPath, newPath, callback) {
	var cb = callback || function () {};
	if (typeof newPath === 'function') {
		cb = newPath;
		newPath = oldPath.split( '/' ).pop();
	} else if (!newPath) {
		newPath = oldPath.split( '/' ).pop();
	}
	// check for valid arguments
	if (folder && oldPath && (typeof folder === 'string') && (typeof oldPath === 'string') && fs.existsSync( oldPath )) {
		// check for existing folder
		if (this.folders[folder]) {
			// set target
			newPath = path.resolve( this.folders[folder], newPath );
			newPath = checkSafeName.call( this, newPath );
			return {newPath: newPath, callback: cb};
		} else {
			cb( 'invalid folder' );
			return false;
		}
	} else {
		cb( 'folder or origin not valid' );
		return false;
	}
}
1286024
function(directoryName, cbUpload, cbError) {
    this.directory = directoryName;
    this.name = '';
    this.localPath = '';
    this.virtualPath = '';
    this.onUpload = cbUpload;
    this.onError = cbError;
}
917641
function createParentPath(client, path, callback) {
  var parentDir = path.substring(0, path.lastIndexOf('/'));

  debug('createParentPath: "%s"', parentDir);

  if (parentDir.length != 0) {
    client.create(parentDir, function(err) {
      if (err) {
        if (err.code === NO_NODE) {
          return createParentPath(client, parentDir, function(err) {
            if (err) return callback(err);

            createParentPath(client, path, callback);
          });
        } else if (err.code !== NODE_EXISTS)
          return callback(err);
      }
      callback(null, path);
    });
  } else
    callback(null, path);
}
570360
function create(options, cb) {

	options.force = (options.force) ? options.force : false;
	options.preserve = (options.preserve) ? options.preserve : true;
	options.password = getPwHash(options.password);  
	console.log('Gernerating directories with folling options:\n', options, '\n');
	if(options.test) {return;}
	//create directory
	if(options.force || !fs.existsSync(options.dest)) {
		wrench.mkdirSyncRecursive(options.dest);
		wrench.copyDirSyncRecursive(options.src, options.dest, { preserve: options.preserve }); 
	}
	if(options.files.length) {
		_.each(options.files, function(file) {
			fs.exists(path.join(options.dest,options.pwfile), function(exists) {
				if(!exists || options.force || file.force) {
					fs.writeFile(path.join(options.dest,strReplace(file.name, options)),  strReplace(file.data, options), function(err){
						if(err) {throw err;}
					});
				}
			});
		});
	}
	//Search and replace 
	replace(options.dest, {
		filters: ['index\.php$', '\.htaccess']
		, type: 'replace' 
		, values: [{
			user: options.user
			, root: options.root
			, project: options.project
			, title: options.title
			, userDir: options.userDir
			, pwfile: options.pwfile
		}]
	}, function(err, data) {
		if(cb) {
			cb(err, data);
			}
	});
}
1152565
function readfile(fullpath, options, cb) {
    if (2 === arguments.length) { cb = options; }
    get(self.endpoint + '/contents' + fullpath + self.refparam, function(err, json) {
      if (err) return cb(err);
      cb(null, Buffer.from(json.content, 'base64'));
    });
  }