fs

package
v0.19.9 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterFileClose added in v0.6.28

func AfterFileClose()

func BeforeFileOpen added in v0.6.28

func BeforeFileOpen()

func CheckIfWindows added in v0.8.43

func CheckIfWindows() bool

func MkdirAll added in v0.12.11

func MkdirAll(fs FS, path string, perm os.FileMode) error

This is a fork of "os.MkdirAll" to work around bugs with the WebAssembly build target. More information here: https://github.com/golang/go/issues/43768.

func ParseYarnPnPVirtualPath added in v0.15.1

func ParseYarnPnPVirtualPath(path string) (string, string, bool)

Types

type DifferentCase added in v0.8.47

type DifferentCase struct {
	Dir    string
	Query  string
	Actual string
}

type DirEntries added in v0.8.47

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

func MakeEmptyDirEntries added in v0.9.1

func MakeEmptyDirEntries(dir string) DirEntries

func (DirEntries) Get added in v0.8.47

func (entries DirEntries) Get(query string) (*Entry, *DifferentCase)

func (DirEntries) PeekEntryCount added in v0.15.14

func (entries DirEntries) PeekEntryCount() int

This function lets you "peek" at the number of entries without watch mode considering the number of entries as having been observed. This is used when generating debug log messages to log the number of entries without causing watch mode to rebuild when the number of entries has been changed.

func (DirEntries) SortedKeys added in v0.13.5

func (entries DirEntries) SortedKeys() (keys []string)

type Entry

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

func (*Entry) Kind

func (e *Entry) Kind(fs FS) EntryKind
func (e *Entry) Symlink(fs FS) string

type EntryKind

type EntryKind uint8
const (
	DirEntry  EntryKind = 1
	FileEntry EntryKind = 2
)

type FS

type FS interface {
	// The returned map is immutable and is cached across invocations. Do not
	// mutate it.
	ReadDirectory(path string) (entries DirEntries, canonicalError error, originalError error)
	ReadFile(path string) (contents string, canonicalError error, originalError error)
	OpenFile(path string) (result OpenedFile, canonicalError error, originalError error)

	// This is a key made from the information returned by "stat". It is intended
	// to be different if the file has been edited, and to otherwise be equal if
	// the file has not been edited. It should usually work, but no guarantees.
	//
	// See https://apenwarr.ca/log/20181113 for more information about why this
	// can be broken. For example, writing to a file with mmap on WSL on Windows
	// won't change this key. Hopefully this isn't too much of an issue.
	//
	// Additional reading:
	// - https://github.com/npm/npm/pull/20027
	// - https://github.com/golang/go/commit/7dea509703eb5ad66a35628b12a678110fbb1f72
	ModKey(path string) (ModKey, error)

	// This is part of the interface because the mock interface used for tests
	// should not depend on file system behavior (i.e. different slashes for
	// Windows) while the real interface should.
	IsAbs(path string) bool
	Abs(path string) (string, bool)
	Dir(path string) string
	Base(path string) string
	Ext(path string) string
	Join(parts ...string) string
	Cwd() string
	Rel(base string, target string) (string, bool)

	// This is a set of all files used and all directories checked. The build
	// must be invalidated if any of these watched files change.
	WatchData() WatchData
	// contains filtered or unexported methods
}

func MockFS

func MockFS(input map[string]string, kind MockKind, absWorkingDir string) FS

func RealFS

func RealFS(options RealFSOptions) (FS, error)

type InMemoryOpenedFile added in v0.12.22

type InMemoryOpenedFile struct {
	Contents []byte
}

func (*InMemoryOpenedFile) Close added in v0.12.22

func (f *InMemoryOpenedFile) Close() error

func (*InMemoryOpenedFile) Len added in v0.12.22

func (f *InMemoryOpenedFile) Len() int

func (*InMemoryOpenedFile) Read added in v0.12.22

func (f *InMemoryOpenedFile) Read(start int, end int) ([]byte, error)

type MockKind added in v0.15.3

type MockKind uint8
const (
	MockUnix MockKind = iota
	MockWindows
)

type ModKey added in v0.8.12

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

type OpenedFile added in v0.12.22

type OpenedFile interface {
	Len() int
	Read(start int, end int) ([]byte, error)
	Close() error
}

type RealFSOptions added in v0.8.38

type RealFSOptions struct {
	AbsWorkingDir string
	WantWatchData bool
	DoNotCache    bool
}

type WatchData added in v0.8.38

type WatchData struct {
	// These functions return a non-empty path as a string if the file system
	// entry has been modified. For files, the returned path is the same as the
	// file path. For directories, the returned path is either the directory
	// itself or a file in the directory that was changed.
	Paths map[string]func() string
}

Jump to

Keyboard shortcuts

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