posixpath

package
v0.0.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2022 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Overview

Package posixpath handles posix-path (Unix style; slash separeted path).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base(fname string) string

Base returns the last element of fname. If fname is empty, or ends with path separator, Base returns ".". If fname is "/" only, Base returns "/".

func Clean

func Clean(path string) string

Clean returns the shortest path name equivalent to path by purely lexical processing.

func Dir

func Dir(fname string) string

Dir returns all but the last element of path, typically the path's directory. Differnt from filepath.Dir, it won't clean ".." in the result. If path is empty, Dir returns ".".

func IsAbs

func IsAbs(fname string) bool

IsAbs returns true if fname is absolute path.

func Join

func Join(elem ...string) string

Join joins any number of path elements into a single path, adding a "/" if necessary. Different from filepath.Join, it won't clean ".." in the result. All empty strings are ignored.

func Rel

func Rel(basepath, targpath string) (string, error)

Rel returns a relative path that is lexically equivalent to targpath when joined to basepath with an intervening separator.

func SplitElem

func SplitElem(fname string) []string

SplitElem splits path into element, separated by "/". If fname is absolute path, first element is "/". If fname ends with "/" or "/.", last element is ".". Empty string, "/" or "." won't be appeared in other elements.

Types

type FilePath

type FilePath struct{}

FilePath provides posix filepath.

func (FilePath) Base

func (FilePath) Base(path string) string

func (FilePath) Clean

func (FilePath) Clean(path string) string

func (FilePath) Dir

func (FilePath) Dir(path string) string

func (FilePath) IsAbs

func (FilePath) IsAbs(path string) bool

func (FilePath) Join

func (FilePath) Join(elem ...string) string

func (FilePath) PathSep

func (FilePath) PathSep() string

func (FilePath) Rel

func (FilePath) Rel(basepath, targpath string) (string, error)

func (FilePath) SplitElem

func (FilePath) SplitElem(path string) []string

func (FilePath) String added in v0.0.18

func (FilePath) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL