Make the directory if it doesn't exist.

@param {string} path to directory.
@param {Object} opts optional args.
purge (boolean) - whether or not to purge existing files.
@param {Function} callback invoke when done.
19565
function maybeMkdir(path, opts, callback) {
  if (typeof opts === 'function') {
    callback = opts;
    opts = null;
  }

  fs.exists(path, function(exists) {
    if (opts && opts.purge) {
      rimraf.sync(path);
    } else {
      if (exists) {
        return callback && callback();
      }
    }

    (function tryMkdir() {
      fs.mkdir(path, function(err) {
        if (err) {
          // TODO(gaye): Eventually we should give up.
          debug('error maybeMkdir, will try again ' + path + ': ' + err);
          return tryMkdir();
        }

        return callback(null);
      });
    })();
  });
}
821527
function makeme (dir,mode,cb){

    var callback = function(err,parent){
        //console.log('makeme: ',dir)
        if(err) throw new Error(err)
        if(parent){
            // replace root of dir with parent
            dir = path.join(parent,path.basename(dir));
        }
        fs.mkdir(dir,mode,function(err){
            if(err !== null){
                if( err.code === 'EEXIST'
                 && err.path === dir){
                    // make sure the directory really does exist
                    fs.stat(dir,function(staterr,stat){
                        // as mkdirP guys say, this is very strange
                        if(staterr || !stat.isDirectory()){
                            if(cb) cb(err);
                        }
                        if(cb) cb(null,dir);
                        return null;
                        // if the stat is good, do nothing.  some other processed did it
                    });

                }else{
                    console.log(err);
                    throw new Error(err);
                }
            }else{
                if(cb) cb(null,dir);
            }
            return 1;

        });
    };
    return callback;
}
822432
function makeDirs(dirs) {
	_.castArray(dirs).forEach(dir => {
		if (fs.existsSync(dir)) {
			return;
		}

		log.added(`Create folder ${dir}`);
		fs.ensureDirSync(dir);
	});
}
471763
function createDirectory(options) {
  return new Promise(function(resolve, reject) {
    mkdirp( options.directory, function (err) {
      if(err && err.code !== 'EEXIST') {
        reject(err);
      } else {
        resolve(options);
      }
    });
  });
}
585789
function(dirPath, callback) {
            client
                .createDirectory(dirPath)
                .then(function() {
                    __executeCallbackAsync(callback, [null]);
                })
                .catch(callback);
        }
1068008
function _mkdirp (directory, mode, callback) {

			if ("undefined" === typeof directory) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof directory) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === directory.trim()) {
					throw new Error("\"directory\" argument is empty");
				}
			else if ("undefined" !== typeof callback && "number" !== typeof mode) {
				throw new TypeError("\"mode\" argument is not a number");
			}
			else if ("undefined" === typeof callback && "undefined" === typeof mode) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback && "function" !== typeof mode) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				let _callback = callback;
				let _mode = mode;

				if ("undefined" === typeof _callback) {
					_callback = mode;
					_mode = DEFAULT_OPTION;
				}

				isDirectoryProm(directory).then((exists) => {

					return exists ? Promise.resolve() : Promise.resolve().then(() => {

						const SUB_DIRECTORY = dirname(directory);

						return isDirectoryProm(SUB_DIRECTORY).then((_exists) => {

							return _exists ? new Promise((resolve, reject) => {

								mkdir(directory, _mode, (err) => {
									return err ? reject(err) : resolve();
								});

							}) : new Promise((resolve, reject) => {

								_mkdirp(SUB_DIRECTORY, _mode, (err) => {

									return err ? reject(err) : mkdir(directory, _mode, (_err) => {
										return _err ? reject(_err) : resolve();
									});

								});

							});

						});

					});

				}).then(() => {
					_callback(null);
				}).catch(callback);

			}

		}
553623
def make_dirs_if_dont_exist(path):
    
    if path[-1] not in ['/']: path += '/'
    path = os.path.dirname(path)
    if path != '':
        try: os.makedirs(path)
        except OSError: pass
305241
public static function purgePresets($path = null, $callback = null) {
        $moufManager = MoufManager::getMoufManager();
        $instances = $moufManager->findInstances('Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController');
        foreach ($instances as $instanceName) {
            $instance = $moufManager->getInstance($instanceName);
            if ($path && strpos($path, $instance->originalPath) !== false) {
                $imagePath = substr($path, strlen($instance->originalPath) + 1);
                $instance->deletePreset($imagePath);
                
                if(is_callable($callback)) {
                    $finalPath = ROOT_PATH . $instance->url . DIRECTORY_SEPARATOR . $imagePath;
                    $callback($finalPath);
                }
            }
        }
    }
722733
function _cmdRemove(extensionDir, callback, pCallback) {
    fs.remove(extensionDir, function (err) {
        if (err) {
            callback(err);
        } else {
            callback(null);
        }
    });
}
350177
async function makeDir(dir) {
    const res = await makePromise(fs.mkdir, dir, dir)
    return res
}
1064458
function mkdir(path, fn) {
  shell.mkdir('-p', path);
  shell.chmod(755, path);
  console.log(chalk.cyan('   create:'), path);
  if (fn) fn();
}
800162
function(targetPath, callback) {
            client
                .deleteFile(targetPath)
                .then(function() {
                    __executeCallbackAsync(callback, [null]);
                })
                .catch(callback);
        }
24520
public static function delete($path, $callback)
    {
        self::instance()->addRoute('DELETE', $path, self::callback($callback));
    }
598680
function (opts) {
    this.options = opts || {};
    this.pattern = null;
    this.middleware = {};
    this.includes = {};
    this.excludes = {};
    this.files = [];
    this.fns = [];

    options(this);
    iterators(this);
    symlinks(this);
    readers(this);
  }
843286
function mkdirRecursive(dirpath, mode, cb)
{
	if( arguments.length<3 ){
		cb= mode;
		mode= null;
	}
	
	fs.stat(dirpath, function(err, stats){
		if( err ){
			mkdirRecursive(path.dirname(dirpath), mode, function(err){
				if(err) cb(err);
				else{ fs.mkdir( dirpath, mode, cb ); }
			});
		}
		else if( stats.isDirectory() ){ cb( null ); }
		else{ cb( "create directory fail, not a directory, " + dirpath ); }
	});
}
144069
def mkdir(path, recursive=True):
    
    if os.path.exists(path):
        return True
    try:
        if recursive:
            os.makedirs(path)
        else:
            os.mkdir(path)
    except OSError as error:
        log.error('mkdir: execute failed: %s (%s)' % (path, error))
        return False
    return True
146252
function createParentDirectories(path, callback) {
    (new fs.Shell()).mkdirp(Path.dirname(path), function(err) {
      if(err && err.code !== 'EEXIST') {
        return callback(err);
      }

      callback();
    });
  }