CONFIGDIR // 
FUNCTION: configdir( [p] )
Returns a directory for user-specific configuration files.

@param {String} [p] - path to append to a base directory
@returns {String|Null} directory
187803
function configdir( p ) {
	var env = process.env,
		append,
		home,
		dir;

	if ( arguments.length ) {
		if ( !isString( p ) ) {
			throw new TypeError( 'invalid input argument. Must provide a string primitive. Value: `' + p + '`.' );
		}
		append = p;
	} else {
		append = '';
	}
	if ( isWindows ) {
		// http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx
		// https://en.wikipedia.org/wiki/Environment_variable#Windows
		dir = env[ 'LOCALAPPDATA' ] || env[ 'APPDATA' ];
		return ( dir ) ? path.join( dir, append ) : null;
	}
	home = homedir();
	if ( home === null ) {
		return null;
	}
	if ( platform === 'darwin' ) {
		// http://stackoverflow.com/questions/410013/where-do-osx-applications-typically-store-user-configuration-data
		return path.join( home, 'Library', 'Preferences', append );
	}
	// http://www.pathname.com/fhs/
	// http://www.pathname.com/fhs/pub/fhs-2.3.html
	// http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
	dir = env[ 'XDG_CONFIG_HOME' ] || path.join( home, '.config' );
	return path.join( dir, append );
}
51099
function resolve( dir ) {
	var udir = dir || configdir();
	if ( udir === null ) {
		debug( 'Unable to resolve user configuration directory.' );
	} else {
		udir = path.resolve( root, udir );
		debug( 'User configuration directory: %s', udir );
	}
	return udir;
}
757251
def _get_program_dir(name, config):
    
    if config is None:
        raise ValueError("Could not find directory in config for %s" % name)
    elif isinstance(config, six.string_types):
        return config
    elif "dir" in config:
        return expand_path(config["dir"])
    else:
        raise ValueError("Could not find directory in config for %s" % name)
409119
function findFile (filename) {
    const file = configDirectory + '/' + filename
    if (fs.existsSync(file)) return file
    const defaultFile = defaultDirectory + '/' + filename
    if (fs.existsSync(defaultFile)) return defaultFile
    return null
  }
1251298
function initConfig(conf) {
  const result = Object.assign({}, conf);
  if (conf.filename) {
    result.filepath = path.dirname(conf.filename);
  }
  return result;
}
1145101
def get_global_config_dir():
        
        from appdirs import user_config_dir

        return user_config_dir(
            appname=Config.APPNAME, appauthor=Config.APPAUTHOR
        )
204024
def get_config_directory():
    
    # avoid circular import
    from .commands.stacker import Stacker
    command = Stacker()
    namespace = command.parse_args()
    return os.path.dirname(namespace.config.name)
108290
function dirname(p){
  utils.assertString(p, 'path');
  return path.dirname(p.val).replace(/\\/g, '/');
}
69232
function getConfigPath(configPaths) {
  let conf = null;

  // Try all config paths and return for the first found one
  some(configPaths, configPath => {
    if (!configPath) return;

    // Compile config using environment variables
    const compiledConfigPath = template(configPath)(process.env);

    let resolvedConfigPath = resolve(process.cwd(), compiledConfigPath);
    const resolvedName = fileExists(resolvedConfigPath);

    if (resolvedConfigPath && resolvedName) {
      conf = resolvedName;
    }

    return conf;
  });

  return conf;
}
1222354
def mkdir_p(path)
      parts = path.split(/[\\\/]/)
      parts.each_index do |i|
        next if parts[i] == ""
        subpath = File.join(*parts[0, i + 1])
        unless File.exists?(subpath)
          FileUtils.mkdir_p(subpath)
          @cache["directories"][subpath] = true
        end
      end
    end
626226
function configurePackageDir(pkgs, currentPackages, dir) {
        var i, location, pkgObj;

        for (i = 0; (pkgObj = currentPackages[i]); i++) {
            pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
            location = pkgObj.location;

            //Add dir to the path, but avoid paths that start with a slash
            //or have a colon (indicates a protocol)
            if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) {
                location = dir + "/" + (location || pkgObj.name);
            }

            //Create a brand new object on pkgs, since currentPackages can
            //be passed in again, and config.pkgs is the internal transformed
            //state for all package configs.
            pkgs[pkgObj.name] = {
                name: pkgObj.name,
                location: location || pkgObj.name,
                //Remove leading dot in main, so main paths are normalized,
                //and remove any trailing .js, since different package
                //envs have different conventions: some use a module name,
                //some use a file name.
                main: (pkgObj.main || "main")
                      .replace(currDirRegExp, '')
                      .replace(jsSuffixRegExp, '')
            };
        }
    }
1288345
function getDefaultConfigPath () {
  let filePath
  let i
  let k

  for (k = 0; k < DEFAULT_CONFIG_DIRS.length; k++) {
    for (i = 0; i < SUPPORTED_EXTENSIONS.length; i++) {
      filePath = DEFAULT_CONFIG_DIRS[k] + SUPPORTED_EXTENSIONS[i]
      if (fileUtils.fileExistsSync(filePath)) {
        return filePath
      }
    }
  }

  throw new Error('No config file found')
}
1171552
function setup() {

    // check if config directory is given
    if( _config_path !== -1 ) {

      // get path
      var config_path = path.resolve( process.argv[ _config_path + 1 ] );

      // check if directory exists and is a valid directory
      fs.stat( config_path, function( err, stats ) {
        if( err && err.code === "ENOENT" ) {
          process.stdout.write( "The given directory doesn't exists.\n".red );
        } else if( err ) {

          // unknown error
          process.stdout.write( (err.message + "\n").red );
        } else if( !stats.isDirectory() ) {
          process.stdout.write( "The given config directory is not an actual directory.\n".red );
        } else {
          readConfigDir( config_path );
        }
      } );
      return;
    }

    // ask for config directory
    ask( "Where are your config files? ", function( c_path ) {
        readConfigDir( c_path );
    } );
}
121276
function getCommonBaseDir(a, b) {
	var common = [];
	a = a.split(path.sep);
	b = b.split(path.sep);
	for (var i = 0; i < a.length; i++) {
		if (b[i] === undefined || b[i] !== a[i]) {
			break;
		}
		common.push(a[i]);
	}
	return common.join(path.sep);
}
1213269
def user_config_dir():
    
    """
    if WINDOWS:
        path = os.environ.get('APPDATA')
    elif MACOS:
        path = os.path.expanduser('~/Library/Application Support')
    else:
        path = os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config')
    if path is None:
        path = ''
    else:
        path = os.path.join(path, 'glances')

    return path
1023811
function getConfig(configPath, searchPath = process.cwd(), stopDir = homedir()) {
  const useCustomPath = !!configPath
  const explorer = cosmiconfig('cca', { sync: true, stopDir })

  try {
    const searchPathAbsolute = !useCustomPath && searchPath
    const configPathAbsolute = useCustomPath && path.join(process.cwd(), configPath)
    // search from the root of the process if the user didnt specify a config file,
    // or use the custom path if a file is passed.
    const result = explorer.load(searchPathAbsolute, configPathAbsolute)

    // dont throw if the explorer didnt find a configfile,
    // instead use default config
    const config = result ? result.config : {}
    const filepath = result ? result.filepath : {}
    if (!result) Logger.log('No config file detected, using defaults.')

    return { ...config, filepath }
  } catch (error) {
    Logger.error('An error occured while parsing your config file. Using defaults...\n\n', error.message)
  }
  return {}
}
702310
function newDirectoryApi(input, opts, cb) {
    var fd = new FormData(), files = [];
    var iterate = function(entries, path, resolve) {
      var promises = [];
      entries.forEach(function(entry) {
        promises.push(new Promise(function(resolve) {
          if ("getFilesAndDirectories" in entry) {
            entry.getFilesAndDirectories().then(function(entries) {
              iterate(entries, entry.path + "/", resolve);
            });
          } else {
            if (entry.name) {
              var p = (path + entry.name).replace(/^[/\\]/, "");
              fd.append(opts.name, entry, p);
              files.push(p);
            }
            resolve();
          }
        }));
      });
      Promise.all(promises).then(resolve);
    };
    input.getFilesAndDirectories().then(function(entries) {
      new Promise(function(resolve) {
        iterate(entries, "/", resolve);
      }).then(cb.bind(null, fd, files));
    });
  }