Utility function for splitting off the very end part of a path.
764334
def _split_one_end(path):
        
        s = path.rsplit('/', 1)
        if len(s) == 1:
            return s[0], ''
        else:
            return tuple(s)
557567
function segments(filepath) {
  const parsed = path.parse(filepath);
  const dirWithoutRoot = parsed.dir.substring(parsed.root.length);

  return dirWithoutRoot
    .split(path.sep)
    .concat(parsed.name)
    .reverse();
}
62245
def rec_split_path(path):
    ''''''
    if len(path) > 1 and path.endswith('/'):
        path = path[:-1]
    if '/' not in path:
        return [path,]
    result = []
    while path != '/':
        parent, name = os.path.split(path)
        result.append((path, name))
        path = parent
    result.append(('/', '/'))
    result.reverse()
    return result
869840
private static String pathRemoveLast(String path, RefBoolean isOutSide) {
	if (path.length() == 0) {
	    isOutSide.setValue(true);
	    return "..";
	}
	else if (path.endsWith("..")) {
	    isOutSide.setValue(true);
	    return path.concat("/..");// path+"/..";
	}
	return path.substring(0, path.lastIndexOf('/'));
    }
820249
void dfsPathSplit(String path, String[] result)
    {
        int ri = 0, rlast = result.length - 1;
        int i = 0, b = 0, len = path.length();

        do {
            if (ri == rlast) {
                result[rlast] = path.substring(b);
                return;
            }
            if (i == len || path.charAt(i) == '\\') {
                result[ri++] = path.substring(b, i);
                b = i + 1;
            }
        } while (i++ < len);

        while (ri < result.length) {
            result[ri++] = "";
        }
    }
870234
def split_path(path):
    
    parts = []
    path, tail = os.path.split(path)
    while path and tail:
        parts.append(tail)
        path, tail = os.path.split(path)
    parts.append(os.path.join(path, tail))
    return map(os.path.normpath, parts)[::-1]
1218448
def split_path(path_):
    
    path = path_.lstrip('/')

    # Use partitition instead of split since it always returns 3 parts
    first, _, rest = path.partition('/')

    lang = first.lower()
    if lang in settings.LANGUAGE_URL_MAP:
        return settings.LANGUAGE_URL_MAP[lang], rest
    else:
        supported = find_supported(first)
        if len(supported):
            return supported[0], rest
        else:
            return '', path
214502
def path_join(*args):
    """"""
    return SEP.join((x for x in args if x not in (None, ''))).strip(SEP)
733114
def _split_path(path):
    
    # Get around a quirk in path_split where a / at the end will make the
    # dirname (split[0]) the entire path
    path = path[:-1] if path[-1] == '/' else path
    split = path_split(path)
    return split
240395
def splitext(path):
    ""
    sep = rightmost_separator(path, os.sep)
    dot = path.rfind('.')
    # An ext is only real if it has at least one non-digit char
    if dot > sep and not containsOnly(path[dot:], "0123456789."):
        return path[:dot],path[dot:]
    else:
        return path,""
818334
def path_to_parts(path)
      path.
        downcase.
        split('/').
        map { |part| part.empty? ? nil : part.strip }.
        compact
    end
1302233
def split_path(path)
      path = path.to_s
      extension = File.extname(path)[1..-1] || ""
      path_without_extension = path.sub(/\.#{Regexp.escape(extension)}\Z/, "")
      [extension, path_without_extension]
    end
9757
def split(path):
    
    if path == '/':
        return ('/', None)

    parent, child = path.rsplit('/', 1)

    if parent == '':
        parent = '/'

    return (parent, child)
55646
function splitPath(path) {
  if (Array.isArray(path)) {
    return path
  }
  if (path[0] === '/') {
    path = path.substr(1)
  }
  if (path[path.length-1] === '/') {
    path = path.substr(0, path.length-1)
  }
  return path.split('/')
}
1324590
def split(path)
      parts = []
      last_index = 0
      while index = path.index("/", last_index)
        if index == last_index
          parts << ""
        else
          parts << path[last_index...index]
        end
        last_index = index + 1
      end
      # and also get that last segment
      parts << path[last_index..-1]
      # it should begin with a blank segment from the leading "/"; kill that
      parts.shift
      parts
    end
1030969
def abspath(raw):
    """"""
    path_bits = []
    if raw.find('/') != -1:
        path_bits = raw.split('/')
    elif raw.find('\\') != -1:
        path_bits = raw.split('\\')
    else:
        path_bits = [raw]

    return os.path.abspath(os.sep.join(path_bits))
1117696
def TrimBeginningAndEndingSlashes(path):
    
    if path.startswith('/'):
        # Returns substring starting from index 1 to end of the string
        path = path[1:]

    if path.endswith('/'):
        # Returns substring starting from beginning to last but one char in the string
        path = path[:-1]

    return path