Returns the long path name for a Windows path, i.e. the properly cased
  path of an existing file or directory.
433901
def _get_long_path_name(path):
  

  # Thanks to http://stackoverflow.com/a/3694799/791713
  buf = ctypes.create_unicode_buffer(len(path) + 1)
  GetLongPathNameW = ctypes.windll.kernel32.GetLongPathNameW
  res = GetLongPathNameW(path, buf, len(path) + 1)
  if res == 0 or res > 260:
    return path
  else:
    return buf.value
669349
def abspath(self, path):
        """"""

        def getcwd():
            """Return the current working directory."""
            # pylint: disable=undefined-variable
            if IS_PY2 and isinstance(path, text_type):
                return self.os.getcwdu()
            elif not IS_PY2 and isinstance(path, bytes):
                return self.os.getcwdb()
            else:
                return self.os.getcwd()

        path = make_string_path(path)
        sep = self.filesystem._path_separator(path)
        altsep = self.filesystem._alternative_path_separator(path)
        if not self.isabs(path):
            path = self.join(getcwd(), path)
        elif (self.filesystem.is_windows_fs and
              path.startswith(sep) or altsep is not None and
              path.startswith(altsep)):
            cwd = getcwd()
            if self.filesystem._starts_with_drive_letter(cwd):
                path = self.join(cwd[:2], path)
        return self.normpath(path)
969431
public static String normalizePath(String path)
    {
        StringBuilder sb = new StringBuilder(path);
        int lastToken = -1;
        for (int i = 0; i < sb.length(); i++)
        {
            if ((sb.charAt(i) == File.separatorChar)
                || (sb.charAt(i) == '/'))
            {
                if (lastToken != -1)
                {
                    if (i < sb.length() - 2)
                        if (sb.charAt(i + 1) == '.')
                            if (sb.charAt(i + 2) == '.')
                    {   // Remove last directory name from path
                        sb.delete(lastToken, i + 3);
                        i = lastToken;
                    }
                }
                lastToken = i;
            }
        }
        return sb.toString();
    }
519319
def __get_windows_path(self):
        """"""
        if OS_SEP == '\\':
            return self
        else:
            entry = self.get()
            r = entry.get_path().replace(OS_SEP, '\\')
            return SCons.Subst.SpecialAttrWrapper(r, entry.name + "_windows")
9888
public static String getFilename(String path) {
        //The filename is after the last slash
        final int index = path != null ? path.lastIndexOf("/") : -1;
        if (index == -1) {
            IOException ioe = new IOException(TraceNLS.getFormattedMessage(FileTransferHelper.class,
                                                                           APIConstants.TRACE_BUNDLE_FILE_TRANSFER,
                                                                           "PATH_NOT_VALID",
                                                                           new String[] { path },
                                                                           "CWWKX0127E: The path " + path + " is not valid."));
            throw ErrorHelper.createRESTHandlerJsonException(ioe, null, APIConstants.STATUS_BAD_REQUEST);
        }

        return path.substring(index + 1);
    }
218581
def canonical_path(path)
      if Gem.win_platform?
        unless File.exist?(path)
          raise PDK::CLI::FatalError, _("Cannot resolve a full path to '%{path}', as it does not currently exist.") % { path: path }
        end
        PDK::Util::Windows::File.get_long_pathname(path)
      else
        File.expand_path(path)
      end
    end
356916
function getPathVariableName() {
    // windows calls it's path 'Path' usually, but this is not guaranteed.
    if (process.platform === 'win32') {
        for (const key of Object.keys(process.env))
            if (key.match(/^PATH$/i))
                return key;
        return 'Path';
    }
    return "PATH";
}
1085244
def generic_filename(path):
    '''
    
    '''

    for sep in common_path_separators:
        if sep in path:
            _, path = path.rsplit(sep, 1)
    return path
1072995
function getPathToRoot(filePath) {
	filePath = filePath.replace(/\\/g, "/");

	var lastSlash = filePath.lastIndexOf("/");
	// strip out file name from the path
	filePath = lastSlash >= 0 ? filePath.slice(0, lastSlash + 1) : "";

	if (!filePath) {
		return "";
	}
    // now "folder1/folder2/file.ext" became "folder1/folder2/"
	filePath = filePath.replace(/[^/]+/g, "..");
	if (filePath.charAt(0) === "/") {
		filePath = filePath.slice(1);
	}
	return filePath;
}
398199
def get_expanded_path(self, path):
        
        if path.startswith('~'):
            return os.path.expanduser('~') + path[1:]
        else:
            return path
159728
function basename (filePath) {
  if (isWindows) {
    // Windows executables must have an extension, so strip it away
    return path.basename(filePath, path.extname(filePath))
  }
  return path.basename(filePath)
}
372617
def get_nt_filename (path):
    """"""
    unc, rest = os.path.splitunc(path)
    head, tail = os.path.split(rest)
    if not tail:
        return path
    for fname in os.listdir(unc+head):
        if fname.lower() == tail.lower():
            return os.path.join(get_nt_filename(unc+head), fname)
    log.error(LOG_CHECK, "could not find %r in %r", tail, head)
    return path
1298779
def validate_pathname(filepath):
    '''

    '''
    if filepath == '/':
        return ValidatePathState.OK
    if len(filepath) > 1000:
        return ValidatePathState.LENGTH_ERROR
    filter2 = '\\?|"><:*'
    for c in filter2:
        if c in filepath:
            return ValidatePathState.CHAR_ERROR2
    paths = rec_split_path(filepath)
    filter3 = '.\r\n\t \0\x0b'
    for path in paths:
        if path[0] in filter3 or path[-1] in filter3:
            return ValidatePathState.CHAR_ERROR3
    return ValidatePathState.OK
237298
def full_path_str(self):
        ''''''
        with self._mutex:
            if self._parent:
                if self._parent._name == '/':
                    return self._parent.full_path_str + self._name
                else:
                    return self._parent.full_path_str + '/' + self._name
            else:
                return self._name
835706
def get_fullpath(self, fullname=None, relative_to=None):
        
        # if is an empty path
        if not fullname:
            return fullname

        isabs = os.path.isabs(fullname)

        path, name = os.path.split(fullname)

        if not name:  # path to a folder
            return None
        else:  # path to a file
            if isabs:
                return fullname
            else:
                return os.path.join(self.case_path, path, name)
54517
public static String getPathFromString(String filePath) {
        String newPath = filePath;

        int forwardInd = filePath.lastIndexOf("/");
        int backInd = filePath.lastIndexOf("\\");

        if (forwardInd > backInd) {
            newPath = filePath.substring(0, forwardInd + 1);
        } else {
            newPath = filePath.substring(0, backInd + 1);
        }

        // still original if no occurance of "/" or "\"
        return newPath;
    }
1163589
def full_path(self):
        """"""

        if self.parent:
            return os.path.join(self.parent.full_path, self.name)
        return self.name