Replaces `content://` with absolute path of `content_dir`.
    By default looks for content in subdirectory `content` in current directory.
513897
def get_abspath(path, content_dir=CONTENT_DIR):
    
    if path:
        file = re.search('content://(.+)', path)
        if file:
            return os.path.join(content_dir, file.group(1))
    return path
219278
function normalizeDirectory(dir) {
  if (!dir || dir === path.sep) {
    dir = '.';
  } else if (_.head(dir) === path.sep) {
    dir = dir.substr(1);
  }

  if (dir.length > 1 && _.last(dir) === path.sep) {
    dir = dir.substring(0, dir.length - 1);
  }

  return dir;
}
308071
def root_dir(relpath)
      r = relpath.match(%r(^[/]?.+?[/$]))
      return relpath if r.nil?
      r[0] || relpath
    end
856943
def _mkdir_p(abspath):
    
    try:
        os.makedirs(abspath)
    except OSError as e:
        if (e.errno == errno.EEXIST) and (os.path.isdir(abspath)):
            pass
        else: raise
747579
def tmp_chdir(new_path):
    """"""
    prev_cwd = os.getcwd()
    os.chdir(new_path)
    try:
        yield
    finally:
        os.chdir(prev_cwd)
882564
public function fixRelativePaths($content,$path,$targetDir=null) {
		// Rewrite relative URLs in CSS
		$f3=$this->f3;
		$method=$f3->get('ASSETS.fixRelativePaths');
		if ($method!==FALSE) {
			$webBase=$f3->get('BASE');
			// fix base path (resolve symbolic links)
			$basePath=$f3->fixslashes(realpath(
				$f3->fixslashes($_SERVER['DOCUMENT_ROOT'].$webBase)).DIRECTORY_SEPARATOR);
			// parse content for URLs
			$content=preg_replace_callback(
				'/\b(?<=url)\((?:([\"\']?)(.+?)((\?.*?)?)\1)\)/s',
				function($url) use ($path,$f3,$webBase,$basePath,$targetDir,$method) {
					// Ignore absolute URLs
					if (preg_match('/https?:/',$url[2]) ||
						!$rPath=realpath($path.$url[2]))
						return $url[0];
					if ($method=='relative') {
						// relative from new public file path
						$filePathFromBase=str_replace($basePath,'',$f3->fixslashes($rPath));
						$rel=$this->relPath($targetDir,$filePathFromBase);
						return '('.$url[1].$rel.(isset($url[4])?$url[4]:'').$url[1].')';
					} elseif ($method=='absolute') {
						// absolute to web root / base
						return '('.$url[1].preg_replace(
								'/'.preg_quote($basePath,'/').'(.+)/',
								'\1',$webBase.'/'.$f3->fixslashes($rPath).(isset($url[4])?$url[4]:'')
							).$url[1].')';
					}
					return $url[0];
				},$content);
		}
		return $content;
	}
877402
function (contents) {
                        files.forEach((file, i) => {
                            context.addFile({
                                path: file,
                                content: contents[i]
                            });
                        });

                        return context;
                    }
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
66604
def load_dir(self, path):
        

        def visit_path(arg, dirname, names):
            for name in names:
                fpath = os.path.join(dirname, name)
                new_path = fpath[len(path):]
                if os.path.isfile(fpath):
                    content = open(fpath, "rb").read()
                    self.touch(new_path, content)
                else:
                    self.mkdir(new_path)

        os.path.walk(path, visit_path, None)
1166877
def subdir_path(directory, relative):
    """"""
    item_bits = directory.split(os.sep)
    relative_bits = relative.split(os.sep)
    for i, _item in enumerate(item_bits):
        if i == len(relative_bits) - 1:
            return os.sep.join(item_bits[i:])
        else:
            if item_bits[i] != relative_bits[i]:
                return None

    return None
744563
def hard_path(path, prefix_dir):
    """"""
    relative = abspath("%s/%s" % (prefix_dir, path))
    a_path = abspath(path)
    if os.path.exists(relative):
        LOG.debug("using relative path %s (%s)", relative, path)
        return relative

    LOG.debug("using absolute path %s", a_path)
    return a_path
519965
def go_to_parent_directory(self):
        """"""
        self.chdir(osp.abspath(osp.join(getcwd_or_home(), os.pardir)))
464609
def dir_path(dir):
    """"""
    old_dir = os.getcwd()
    os.chdir(dir)
    yield
    os.chdir(old_dir)
1331159
def absolute_git_root_dir(fpath=""):
    
    if len(fpath) == 0:
        dirname_str = os.getcwd()
    else:
        dirname_str = os.path.dirname(fpath)
    dirname_str = os.path.abspath(dirname_str)
    dirnames = dirname_str.split(os.sep)
    n = len(dirnames)
    for i in xrange(n):
        # is there a .git directory at this level?
        # FIXME hack
        basedir = "/" + os.path.join(*dirnames[0:n - i])
        gitdir = os.path.join(basedir, ".git")
        if os.path.exists(gitdir):
            return basedir
1323427
def existingDirectory(string):
    
    if not os.path.isdir(string):
        argparse.ArgumentTypeError('{} is not a valid directory.'.format(string))
    return string
1259177
def complete_path(curr_dir, last_dir):
    
    if not last_dir or curr_dir.startswith(last_dir):
        return curr_dir
    elif last_dir == '~':
        return os.path.join(last_dir, curr_dir)
660907
function getContentOfDir(pathToDir) {
  return fs.readdirSync(pathToDir).filter(function(fileName) {
    return !hiddenReg.test(fileName);
  });
}