Transforms a path into a path within the site files folder, if needed.

Eg, turns 'foo' into 'sites/default/foo'.
Absolute paths are unchanged.
970058
function directoryPath(&$directory) {
    if (substr($directory, 0, 1) != '/') {
      // Relative, and so assumed to be in Drupal's files folder: prepend this to
      // the given directory.
      // sanity check. need to verify /files exists before we do anything. see http://drupal.org/node/367138
      $files = file_create_path();
      file_check_directory($files, FILE_CREATE_DIRECTORY);
      $directory = file_create_path($directory);
    }
  }
285379
def normalized_path(dir = Dir.pwd, options = {})
      rootdir = (FalkorLib::Git.init?(dir)) ? FalkorLib::Git.rootdir(dir) : dir
      path = dir
      path = Dir.pwd if dir == '.'
      path = File.join(Dir.pwd, dir) unless (dir =~ /^\// || (dir == '.'))
      if (options[:relative] || options[:relative_to])
        root = (options[:relative_to]) ? options[:relative_to] : rootdir
        relative_path_to_root = Pathname.new( File.realpath(path) ).relative_path_from Pathname.new(root)
        path = relative_path_to_root.to_s
      end
      path
    end
346915
function expandPath(p) {
  if(p[0] === '~') {
    p = getUserHome() + p.slice(1);
  }
  return path.normalize(p);
}
180977
function (fileName) {
            var dir;
            if (currDirRegExp.test(fileName)) {
                dir = frontSlash(location.href);
                if (dir.indexOf('/') !== -1) {
                    dir = dir.split('/');

                    //Pull off protocol and host, just want
                    //to allow paths (other build parts, like
                    //require._isSupportedBuildUrl do not support
                    //full URLs), but a full path from
                    //the root.
                    dir.splice(0, 3);

                    dir.pop();
                    dir = '/' + dir.join('/');
                }

                fileName = dir + fileName.substring(1);
            }

            return fileName;
        }
893710
def rel_path(anchor, *paths):
    
    anchor = os.path.abspath(os.path.expandvars(os.path.expanduser(anchor)))
    if os.path.exists(anchor) and os.path.isfile(anchor):
        anchor = os.path.dirname(anchor)
    return os.path.normpath(os.path.join(anchor, *paths))
178627
function (path) {
                //There has to be an easier way to do this.
                var i, part, ary,
                    firstChar = path.charAt(0);

                if (firstChar !== '/' &&
                        firstChar !== '\\' &&
                        path.indexOf(':') === -1) {
                    //A relative path. Use the current working directory.
                    path = xpcUtil.cwd() + '/' + path;
                }

                ary = path.replace(/\\/g, '/').split('/');

                for (i = 0; i < ary.length; i += 1) {
                    part = ary[i];
                    if (part === '.') {
                        ary.splice(i, 1);
                        i -= 1;
                    } else if (part === '..') {
                        ary.splice(i - 1, 2);
                        i -= 2;
                    }
                }
                return ary.join('/');
            }
878834
def to_full_path(cls, path):
        
        if isinstance(path, SymbolicReference):
            path = path.path
        full_ref_path = path
        if not cls._common_path_default:
            return full_ref_path
        if not path.startswith(cls._common_path_default + "/"):
            full_ref_path = '%s/%s' % (cls._common_path_default, path)
        return full_ref_path
762628
def path_to_url2(path):
    
    path = os.path.normpath(os.path.abspath(path))
    drive, path = os.path.splitdrive(path)
    filepath = path.split(os.path.sep)
    url = '/'.join([urllib.quote(part) for part in filepath])
    if not drive:
        url = url.lstrip('/')
    return 'file:///' + drive + url
1106901
def makepath(s, as_file=False):
    
    if s is None:
        return None
    result = FilePath(s) if (os.path.isfile(s) or as_file) else DirectPath(s)
    return result.expandall()
227962
def to_absolute_paths(paths):
    
    abspath = os.path.abspath
    paths = return_set(paths)
    absolute_paths = {abspath(x) for x in paths}
    return absolute_paths
801379
def join_path(self, *path):
		
		path = self.directory_sep().join(path)
		return self.normalize_path(path)
1143655
def expand_path(path):
    """"""

    paths = []
    path = os.path.expanduser(path)
    path = os.path.expandvars(path)

    if os.path.isdir(path):

        for (dir, dirs, files) in os.walk(path):
            for file in files:
                paths.append(os.path.join(dir, file))
    else:
        paths.extend(glob(path))

    return paths
695720
function normalizePath(fsPath) {
  fsPath = path.normalize(fsPath);

  if (process.platform === 'win32') {
    fsPath = fsPath.replace(backwardSlashRegExp, '/');
  }

  return fsPath;
}
813812
def fix_raw_path(path):
    
    double_path_separator = PATH_SEPARATOR + PATH_SEPARATOR
    while path.find(
            double_path_separator) >= 0:  # there are double separators
        path = path.replace(double_path_separator,
                            PATH_SEPARATOR)  # remove double path separator

    if is_folder(path) and not path.endswith("/"):
        path = path + "/"

    return path
302485
def normalize_path(path, filetype=FILE):
    
    if not path:
        raise ValueError('"{0}" is not a valid path.'.format(path))
    if not os.path.exists(path):
        raise ValueError('"{0}" does not exist.'.format(path))
    if filetype == FILE and not os.path.isfile(path):
        raise ValueError('"{0}" is not a file.'.format(path))
    elif filetype == DIR and not os.path.isdir(path):
        raise ValueError('"{0}" is not a dir.'.format(path))

    return os.path.abspath(path)
1291682
function normalizePaths(opts) {
  for (var srcKey in opts.src) {
    if (!path.isAbsolute(opts.src[srcKey].glob)) {
      opts.src[srcKey].glob = path.resolve(opts.src[srcKey].glob);
    }
    if (!path.isAbsolute(opts.src[srcKey].basedir)) {
      opts.src[srcKey].basedir = path.resolve(opts.src[srcKey].basedir);
    }
  }
}
201434
def clean_path(p):
    
    p = os.path.expanduser(p)
    p = os.path.expandvars(p)
    p = os.path.abspath(p)
    return p