upath

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: BSD-3-Clause Imports: 5 Imported by: 35

Documentation

Overview

Package upath contains utilities for dealing with symlinked paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsSymlink(originalFile, target string) string

AbsSymlink returns an absolute path for the link from a file to a target.

func IsTargetSymlink(originalFile, target string) bool

IsTargetSymlink returns true if a target of a symlink is also a symlink.

func ResolveUntilLastSymlink(p string) string

ResolveUntilLastSymlink resolves until the last symlink.

This is needed when we have a chain of symlinks and want the last symlink, not the file pointed to (which is why we don't use filepath.EvalSymlinks)

I.e.

/foo/bar -> ../baz/foo /baz/foo -> bla

ResolveUntilLastSymlink(/foo/bar) returns /baz/foo.

func SafeFilepathJoin added in v0.9.0

func SafeFilepathJoin(path1, path2 string) (string, error)

SafeFilepathJoin safely joins two paths path1+path2. The resulting path will always be contained within path1 even if path2 tries to escape with "../". If that path is not possible, an error is returned. The resulting path is cleaned.

func UrootPath

func UrootPath(n ...string) string

UrootPath returns the absolute path for a uroot file with the UROOT_ROOT environment variable taken into account.

It returns a proper value if UROOT_ROOT is not set. u-root was built to assume everything is rooted at /, and in most cases that is still true. But in hosted mode, e.g. on developer mode chromebooks, it's far better if u-root can be rooted in /usr/local, so successive kernel/root file system upgrades do not wipe it out.

Types

This section is empty.

Jump to

Keyboard shortcuts

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