package gopathrs

import "github.com/cyphar/filepath-securejoin/pathrs-lite/internal/gopathrs"

Package gopathrs is a less complete pure Go implementation of some of the APIs provided by libpathrs.

Index

Variables

var ErrInvalidMode = errors.New("invalid permission mode")

ErrInvalidMode is returned from [MkdirAll] when the requested mode is invalid.

Functions

func MkdirAllHandle

func MkdirAllHandle(root *os.File, unsafePath string, mode os.FileMode) (_ *os.File, Err error)

MkdirAllHandle is equivalent to [MkdirAll], except that it is safer to use in two respects:

In addition, the returned handle is obtained far more efficiently than doing a brand new lookup of unsafePath (such as with SecureJoin or openat2) after doing [MkdirAll]. If you intend to open the directory after creating it, you should use MkdirAllHandle.

func OpenatInRoot

func OpenatInRoot(root *os.File, unsafePath string) (*os.File, error)

OpenatInRoot is equivalent to [OpenInRoot], except that the root is provided using an *os.File handle, to ensure that the correct root directory is used.

func PartialLookupInRoot

func PartialLookupInRoot(root fd.Fd, unsafePath string) (*os.File, string, error)

PartialLookupInRoot tries to lookup as much of the request path as possible within the provided root (a-la RESOLVE_IN_ROOT) and opens the final existing component of the requested path, returning a file handle to the final existing component and a string containing the remaining path components.

Source Files

doc.go lookup_linux.go mkdir_linux.go open_linux.go openat2_linux.go

Version
v0.6.1 (latest)
Published
Nov 19, 2025
Platform
linux/amd64
Imports
13 packages
Last checked
47 minutes ago

Tools for package owners.