filename

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package filename fits the file names a run derives from qualified names into what every common filesystem takes, and keeps a set of them apart: a name too long for one path component is cut and tagged with a hash of the whole, names that meet letter case aside are tagged until no two meet, and a stem a filesystem reads as a device is told so its caller can encode it.

Index

Constants

View Source
const (
	Max      = 255
	TagBytes = 8
)

Max is the longest name every common filesystem takes for one path component; TagBytes of the encoded name's hash keep a cut name apart from its neighbours.

Variables

This section is empty.

Functions

func CaseFolded

func CaseFolded(text string) string

CaseFolded is text under simple Unicode case folding, the key two files of a Plan meet under: two texts fold alike exactly when strings.EqualFold holds of them.

func DeviceStem

func DeviceStem(name string) bool

DeviceStem reports whether the stem of name, what precedes its first `.`, is one Windows reads as a device whatever the extension, trailing spaces and letter case aside.

func Fit

func Fit(name, ext string, escape byte, tagged bool) string

Fit is name+ext, cut to Max bytes and tagged with `~` and a hash of the whole name when tagged or when it is too long. The cut splits neither a UTF-8 sequence nor a trailing three-byte escape, `escape` being the byte the name's encoding opens one with (`%` in `%2F`).

func Plan

func Plan(names []string, file func(name string, tagged bool) string) (map[string]string, error)

Plan is the file each name is written to, by name: file gives a name's file, tagged or not, and the files that meet letter case aside are tagged until no two meet. Two names whose tagged files still meet are a CollisionError.

Types

type CollisionError

type CollisionError struct {
	Names [2]string
	File  string
}

CollisionError reports two names whose files meet even when tagged, which only names that are the same, or differ in bytes the encoding drops, can.

func (*CollisionError) Error

func (e *CollisionError) Error() string

Jump to

Keyboard shortcuts

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