Lookup the path, handling windows weirdness
174333
@Override
  public PathImpl schemeWalk(String userPath,
                         Map<String,Object> attributes,
                         String filePath,
                         int offset)
  {
    int p = filePath.indexOf('!', offset);
    String backingPath;
    String jarPath;

    if (p > 0) {
      backingPath = filePath.substring(offset, p);
      jarPath = filePath.substring(p + 1);
    }
    else {
      backingPath = filePath.substring(offset);
      jarPath = "";
    }

    PathImpl backing = VfsOld.lookup(backingPath);

    return JarPath.create(backing).lookup(jarPath);
  }
91029
def scan_path(executable="mongod"):
    
    for path in os.environ.get("PATH", "").split(":"):
        path = os.path.abspath(path)
        executable_path = os.path.join(path, executable)
        if os.path.exists(executable_path):
            return executable_path
996382
def convert_windows_path_to_cygwin(path):
    """"""
    if len(path) > 2 and path[1] == ":" and path[2] == "\\":
        newpath = cygwin_full_path_prefix + "/" + path[0]
        if len(path) > 3: newpath += "/" + path[3:]
        path = newpath
    path = path.replace("\\", "/")
    return path
706115
function openExplorer(path, callback) {
    if (osType == 'Windows_NT') {
        openExplorerinWindows(path, callback);
    }
    else if (osType == 'Darwin') {
        openExplorerinMac(path, callback);
    }
    else {
        openExplorerinLinux(path, callback);
    }
}
74521
def is_subpath(path, parent):
  '''
  
  '''

  try:
    relpath = os.path.relpath(path, parent)
  except ValueError:
    return False  # happens on Windows if drive letters don't match
  return relpath == os.curdir or not relpath.startswith(os.pardir)
555340
def glob_if_windows_os(path, exact_num_args=False):
    """"""
    if system_os != "Windows": return [path]
    globbed = glob.glob(path)
    if not globbed:
        print("\nWarning in pdfCropMargins: The wildcards in the path\n   "
              + path + "\nfailed to expand.  Treating as literal.",
              file=sys.stderr)
        globbed = [path]
    if exact_num_args and len(globbed) != exact_num_args:
        print("\nError in pdfCropMargins: The wildcards in the path\n   "
              + path + "\nexpand to the wrong number of files.",
              file=sys.stderr)
        cleanup_and_exit(1)
    return globbed
963078
def path_locations(home_dir):
    """"""
    home_dir = os.path.abspath(home_dir)
    # XXX: We'd use distutils.sysconfig.get_python_inc/lib but its
    # prefix arg is broken: http://bugs.python.org/issue3386
    if is_win:
        # Windows has lots of problems with executables with spaces in
        # the name; this function will remove them (using the ~1
        # format):
        mkdir(home_dir)
        if ' ' in home_dir:
            import ctypes
            GetShortPathName = ctypes.windll.kernel32.GetShortPathNameW
            size = max(len(home_dir)+1, 256)
            buf = ctypes.create_unicode_buffer(size)
            try:
                u = unicode
            except NameError:
                u = str
            ret = GetShortPathName(u(home_dir), buf, size)
            if not ret:
                print('Error: the path "%s" has a space in it' % home_dir)
                print('We could not determine the short pathname for it.')
                print('Exiting.')
                sys.exit(3)
            home_dir = str(buf.value)
        lib_dir = join(home_dir, 'Lib')
        inc_dir = join(home_dir, 'Include')
        bin_dir = join(home_dir, 'Scripts')
    if is_jython:
        lib_dir = join(home_dir, 'Lib')
        inc_dir = join(home_dir, 'Include')
        bin_dir = join(home_dir, 'bin')
    elif is_pypy:
        lib_dir = home_dir
        inc_dir = join(home_dir, 'include')
        bin_dir = join(home_dir, 'bin')
    elif not is_win:
        lib_dir = join(home_dir, 'lib', py_version)
        inc_dir = join(home_dir, 'include', py_version + abiflags)
        bin_dir = join(home_dir, 'bin')
    return home_dir, lib_dir, inc_dir, bin_dir
902824
def process_path(label, pth):
   ""
   
   if pth is None:
      sys.exit("no %s path given" % label)
      
   if pth.startswith("/"):
      pass
   elif pth[0] in (".", "~"):
      pth = os.path.realpath(pth)
   else:
      pth = os.getcwd() + os.sep + pth
   
   if not os.path.exists(pth):
      sys.exit("%s path %s does not exist" % (label, pth))

   return pth
1158475
def find_executable(executable, path=None):
    
    if sys.platform != 'win32':
        return distutils.spawn.find_executable(executable, path)

    if path is None:
        path = os.environ['PATH']

    paths = path.split(os.pathsep)
    extensions = os.environ.get('PATHEXT', '.exe').split(os.pathsep)
    base, ext = os.path.splitext(executable)

    if not os.path.isfile(executable):
        for p in paths:
            for ext in extensions:
                f = os.path.join(p, base + ext)
                if os.path.isfile(f):
                    return f
        return None
    else:
        return executable
790907
def lookup_path(bin_name):
    
    paths = ('/usr/local/sbin/', '/usr/local/bin/', '/usr/sbin/', '/usr/bin/')
    for p in paths:
        fq_path = p + bin_name
        found = os.path.isfile(fq_path) and os.access(fq_path, os.X_OK)
        if found:
            return fq_path
    return False
1113011
function findPath(path, directories) {
  var cwd = directories[0];

  if (!cwd) {
    return null;
  }

  return findup(path, {cwd: cwd}) || findPath(path, slice.call(directories, 1));
}
937620
def path(self):
        """"""
        names = []
        obj = self
        while obj:
            names.insert(0, obj.name)
            obj = obj.parent_dir
        sep = self.filesystem._path_separator(self.name)
        if names[0] == sep:
            names.pop(0)
            dir_path = sep.join(names)
            # Windows paths with drive have a root separator entry
            # which should be removed
            is_drive = names and len(names[0]) == 2 and names[0][1] == ':'
            if not is_drive:
                dir_path = sep + dir_path
        else:
            dir_path = sep.join(names)
        dir_path = self.filesystem.absnormpath(dir_path)
        return dir_path
741342
def __get_path(path):
    """"""
    if not os.path.isabs(path):
        path = os.path.join(os.getcwd(), path)

    return os.path.normpath(path)
1212100
def os_path_transform(self, s, sep=os.path.sep):
        
        if sep == '/':
            return s
        else:
            return s.replace(sep, '/')
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
1045683
function (path) {
      // Counter for '/'.
      var standardFolderSepCount = 0;
      // Counter for '\' (windows folder separator).
      var windowsFolderSepCount = 0;
      // Loops index used for parsing chars of `path`and to add `../` to the result.
      var i;
      // Current char read from `path`.
      var c;
      // Counting folders' separators.
      for (i = 0; i < path.length; i++) {
        c = path.charAt(i);
        if (c == '/') standardFolderSepCount++;
        if (c == '\\') windowsFolderSepCount++;
      }
      var folderSepCount = Math.max(standardFolderSepCount, windowsFolderSepCount);
      if (folderSepCount == 0) {
        // There is no subfolder.
        return '';
      }

      var result = '';
      var folderSep = '/';  // windowsFolderSepCount > standardFolderSepCount ? '\\' : '/';
      for (i = 0; i < folderSepCount; i++) {
        result += '..' + folderSep;
      }
      return result;
    }
1207419
def cnormpath (path):
    """"""
    path = normpath(path)
    if os.name == 'nt':
        # replace slashes with backslashes
        path = path.replace("/", "\\")
    if not os.path.isabs(path):
        path = normpath(os.path.join(sys.prefix, path))
    return path