filepath

package
v0.0.0-...-0fedc61 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2015 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnixSeparator     = '/' // OS-specific path separator
	UnixListSeparator = ':' // OS-specific path list separator
)
View Source
const (
	WindowsSeparator     = '\\' // OS-specific path separator
	WindowsListSeparator = ';'  // OS-specific path list separator
)

Variables

This section is empty.

Functions

func Base

func Base(sep uint8, volumeName func(string) string, path string) string

Base mimics path/filepath for the given path separator.

func Clean

func Clean(sep uint8, volumeName func(string) string, path string) string

Clean mimics path/filepath for the given path separator.

func Dir

func Dir(sep uint8, volumeName func(string) string, path string) string

Dir mimics path/filepath for the given path separator.

func Ext

func Ext(sep uint8, path string) string

Ext mimics path/filepath for the given path separator.

func FromSlash

func FromSlash(sep uint8, path string) string

FromSlash mimics path/filepath for the given path separator.

func Join

func Join(sep uint8, volumeName func(string) string, elem ...string) string

Join mimics path/filepath for the given path separator.

func Match

func Match(sep uint8, pattern, name string) (matched bool, err error)

Match returns true if name matches the shell file name pattern. The pattern syntax is:

pattern:
    { term }
term:
    '*'         matches any sequence of non-Separator characters
    '?'         matches any single non-Separator character
    '[' [ '^' ] { character-range } ']'
                character class (must be non-empty)
    c           matches character c (c != '*', '?', '\\', '[')
    '\\' c      matches character c

character-range:
    c           matches character c (c != '\\', '-', ']')
    '\\' c      matches character c
    lo '-' hi   matches character c for lo <= c <= hi

Match requires pattern to match all of name, not just a substring. The only possible returned error is ErrBadPattern, when pattern is malformed.

On Windows, escaping is disabled. Instead, '\\' is treated as path separator.

func Split

func Split(sep uint8, volumeName func(string) string, path string) (dir, file string)

Split mimics path/filepath for the given path separator.

func ToSlash

func ToSlash(sep uint8, path string) string

ToSlash mimics path/filepath for the given path separator.

Types

type Renderer

type Renderer interface {
	// Base mimics path/filepath.
	Base(path string) string

	// Clean mimics path/filepath.
	Clean(path string) string

	// Dir mimics path/filepath.
	Dir(path string) string

	// Ext mimics path/filepath.
	Ext(path string) string

	// FromSlash mimics path/filepath.
	FromSlash(path string) string

	// IsAbs mimics path/filepath.
	IsAbs(path string) bool

	// Join mimics path/filepath.
	Join(path ...string) string

	// Match mimics path/filepath.
	Match(pattern, name string) (matched bool, err error)

	// Split mimics path/filepath.
	Split(path string) (dir, file string)

	// SplitList mimics path/filepath.
	SplitList(path string) []string

	// ToSlash mimics path/filepath.
	ToSlash(path string) string

	// VolumeName mimics path/filepath.
	VolumeName(path string) string
}

Renderer provides methods for the different functions in the stdlib path/filepath package that don't relate to a concrete filesystem. So Abs, EvalSymlinks, Glob, Rel, and Walk are not included. Also, while the functions in path/filepath relate to the current host, the PathRenderer methods relate to the renderer's target platform. So for example, a windows-oriented implementation will give windows-specific results even when used on linux.

func NewRenderer

func NewRenderer(os string) (Renderer, error)

NewRenderer returns a Renderer for the given os.

type UnixRenderer

type UnixRenderer struct{}

UnixRenderer is a Renderer implementation for most flavors of Unix.

func (UnixRenderer) Base

func (ur UnixRenderer) Base(path string) string

Base implements Renderer.

func (UnixRenderer) Clean

func (ur UnixRenderer) Clean(path string) string

Clean implements Renderer.

func (UnixRenderer) Dir

func (ur UnixRenderer) Dir(path string) string

Dir implements Renderer.

func (UnixRenderer) Ext

func (UnixRenderer) Ext(path string) string

Ext implements Renderer.

func (UnixRenderer) FromSlash

func (UnixRenderer) FromSlash(path string) string

FromSlash implements Renderer.

func (UnixRenderer) IsAbs

func (UnixRenderer) IsAbs(path string) bool

IsAbs implements Renderer.

func (UnixRenderer) Join

func (ur UnixRenderer) Join(path ...string) string

Join implements Renderer.

func (UnixRenderer) Match

func (UnixRenderer) Match(pattern, name string) (matched bool, err error)

Match implements Renderer.

func (UnixRenderer) Split

func (ur UnixRenderer) Split(path string) (dir, file string)

Split implements Renderer.

func (UnixRenderer) SplitList

func (UnixRenderer) SplitList(path string) []string

SplitList implements Renderer.

func (UnixRenderer) ToSlash

func (UnixRenderer) ToSlash(path string) string

ToSlash implements Renderer.

func (UnixRenderer) VolumeName

func (UnixRenderer) VolumeName(path string) string

VolumeName implements Renderer.

type WindowsRenderer

type WindowsRenderer struct{}

WindowsRenderer is a Renderer implementation for Windows.

func (WindowsRenderer) Base

func (ur WindowsRenderer) Base(path string) string

Base implements Renderer.

func (WindowsRenderer) Clean

func (ur WindowsRenderer) Clean(path string) string

Clean implements Renderer.

func (WindowsRenderer) Dir

func (ur WindowsRenderer) Dir(path string) string

Dir implements Renderer.

func (WindowsRenderer) Ext

func (WindowsRenderer) Ext(path string) string

Ext implements Renderer.

func (WindowsRenderer) FromSlash

func (WindowsRenderer) FromSlash(path string) string

FromSlash implements Renderer.

func (WindowsRenderer) IsAbs

func (WindowsRenderer) IsAbs(path string) bool

IsAbs implements Renderer.

func (WindowsRenderer) Join

func (ur WindowsRenderer) Join(path ...string) string

Join implements Renderer.

func (WindowsRenderer) Match

func (WindowsRenderer) Match(pattern, name string) (matched bool, err error)

Match implements Renderer.

func (WindowsRenderer) Split

func (ur WindowsRenderer) Split(path string) (dir, file string)

Split implements Renderer.

func (WindowsRenderer) SplitList

func (WindowsRenderer) SplitList(path string) []string

SplitList implements Renderer.

func (WindowsRenderer) ToSlash

func (WindowsRenderer) ToSlash(path string) string

ToSlash implements Renderer.

func (WindowsRenderer) VolumeName

func (WindowsRenderer) VolumeName(path string) string

VolumeName implements Renderer.

Jump to

Keyboard shortcuts

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