fsmap

package
v0.0.0-...-15f74bb Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package fsmap implements DOS-style drive mappings over a Unix filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PathEntryToUnix

func PathEntryToUnix(dir string, dm *DriveMap) string

PathEntryToUnix converts a single PATH entry to a Unix directory path. Unix absolute paths (starting with '/') are returned unchanged. Everything else is resolved through the DriveMap (e.g. C:\usr\bin -> /usr/bin).

func SplitPath

func SplitPath(pathVal string) []string

SplitPath splits a PATH string using the appropriate separator. If the value contains ';' it is treated as DOS-style (';'-separated); otherwise filepath.SplitList (OS-native, ':' on Linux) is used.

Types

type DriveMap

type DriveMap struct {
	// contains filtered or unexported fields
}

DriveMap maps drive letters to Unix base paths and tracks per-drive working directories.

func New

func New() *DriveMap

New returns an empty DriveMap with no drives configured.

func (*DriveMap) AddDrive

func (dm *DriveMap) AddDrive(letter, unixPath string)

AddDrive registers a drive letter (e.g. "C") mapped to a Unix path. The path is cleaned and stored; the drive's initial CWD is its root.

func (*DriveMap) CurrentDOSPath

func (dm *DriveMap) CurrentDOSPath() string

CurrentDOSPath returns the DOS-style path of the current drive's CWD.

func (*DriveMap) CurrentDrive

func (dm *DriveMap) CurrentDrive() string

CurrentDrive returns the active drive letter.

func (*DriveMap) CurrentUnixPath

func (dm *DriveMap) CurrentUnixPath() string

CurrentUnixPath returns the Unix path of the current drive's CWD.

func (*DriveMap) GetCWD

func (dm *DriveMap) GetCWD(letter string) string

GetCWD returns the remembered Unix working directory for the given drive.

func (*DriveMap) ResolvePath

func (dm *DriveMap) ResolvePath(dosPath string) (string, error)

ResolvePath resolves a DOS path relative to the current drive and directory. This is the main entry point for path resolution; it delegates to ToUnix.

func (*DriveMap) SetCWD

func (dm *DriveMap) SetCWD(letter, unixPath string)

SetCWD updates the remembered working directory for the given drive.

func (*DriveMap) SetCurrentDrive

func (dm *DriveMap) SetCurrentDrive(letter string) error

SetCurrentDrive switches the active drive.

func (*DriveMap) ToDOS

func (dm *DriveMap) ToDOS(unixPath string) string

ToDOS converts a Unix path to a DOS-style path using the best matching drive. Returns the Unix path unchanged if no drive matches.

func (*DriveMap) ToUnix

func (dm *DriveMap) ToUnix(dosPath string) (string, error)

ToUnix converts a DOS-style path to an absolute Unix path.

Accepted forms:

NUL           -> /dev/null
C:\foo\bar    -> /<base>/foo/bar
C:relative    -> <drive-cwd>/relative
\absolute     -> <current-drive-base>/absolute
relative      -> <current-drive-cwd>/relative

Both \ and / are accepted as separators.

Jump to

Keyboard shortcuts

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