var _ … var _ … type fsNode … // MakeEmptyDirInMemory returns an empty directory. // The paths of nodes in this object will never // report a leading Separator, meaning they // aren't "absolute" in the sense defined by // https://golang.org/pkg/path/filepath/#IsAbs. func MakeEmptyDirInMemory() *fsNode { … } // MakeFsInMemory returns an empty 'file system'. // The paths of nodes in this object will always // report a leading Separator, meaning they // are "absolute" in the sense defined by // https://golang.org/pkg/path/filepath/#IsAbs. // This is a relevant difference when using Walk, // Glob, Match, etc. func MakeFsInMemory() FileSystem { … } // Name returns the name of the node. func (n *fsNode) Name() string { … } // Path returns the full path to the node. func (n *fsNode) Path() string { … } // mySplit trims trailing separators from the directory // result of filepath.Split. func mySplit(s string) (string, string) { … } func (n *fsNode) addFile(name string, c []byte) (result *fsNode, err error) { … } // Create implements FileSystem. // Create makes an empty file. func (n *fsNode) Create(path string) (result File, err error) { … } // WriteFile implements FileSystem. func (n *fsNode) WriteFile(path string, d []byte) error { … } // AddFile adds a file and any necessary containing // directories to the node. func (n *fsNode) AddFile( name string, c []byte) (result *fsNode, err error) { … } func (n *fsNode) addDir(path string) (result *fsNode, err error) { … } // Mkdir implements FileSystem. // Mkdir creates a directory. func (n *fsNode) Mkdir(path string) error { … } // MkdirAll implements FileSystem. // MkdirAll creates a directory. func (n *fsNode) MkdirAll(path string) error { … } // AddDir adds a directory to the node, not complaining // if it is already there. func (n *fsNode) AddDir(path string) (result *fsNode, err error) { … } // CleanedAbs implements FileSystem. func (n *fsNode) CleanedAbs(path string) (ConfirmedDir, string, error) { … } // Exists implements FileSystem. // Exists returns true if the path exists. func (n *fsNode) Exists(path string) bool { … } func cleanQueryPath(path string) string { … } // Find finds the given node, else nil if not found. // Return error on structural/argument errors. func (n *fsNode) Find(path string) (*fsNode, error) { … } func (n *fsNode) findIt(path string) (result *fsNode, err error) { … } // RemoveAll implements FileSystem. // RemoveAll removes an item and everything it contains. func (n *fsNode) RemoveAll(path string) error { … } // Remove drop the node, and everything it contains, from its parent. func (n *fsNode) Remove() error { … } // isNodeADir returns true if the node is a directory. // Cannot collide with the poorly named "IsDir". func (n *fsNode) isNodeADir() bool { … } // IsDir implements FileSystem. // IsDir returns true if the argument resolves // to a directory rooted at the node. func (n *fsNode) IsDir(path string) bool { … } // ReadDir implements FileSystem. func (n *fsNode) ReadDir(path string) ([]string, error) { … } // Size returns the size of the node. func (n *fsNode) Size() int64 { … } // Open implements FileSystem. // Open opens the node in read-write mode and sets the offset its start. // Writing right after opening the file will replace the original content // and move the offset forward, as with a file opened with O_RDWR | O_CREATE. // // As an example, let's consider a file with content "content": // - open: sets offset to start, content is "content" // - write "@": offset increases by one, the content is now "@ontent" // - read the rest: since offset is 1, the read operation returns "ontent" // - write "$": offset is at EOF, so "$" is appended and content is now "@ontent$" // - read the rest: returns 0 bytes and EOF // - close: the content is still "@ontent$" func (n *fsNode) Open(path string) (File, error) { … } // Close marks the node closed. func (n *fsNode) Close() error { … } // ReadFile implements FileSystem. func (n *fsNode) ReadFile(path string) (c []byte, err error) { … } // Read returns the content of the file node. func (n *fsNode) Read(d []byte) (c int, err error) { … } // Write saves the contents of the argument to the file node. func (n *fsNode) Write(p []byte) (c int, err error) { … } // ContentMatches returns true if v matches fake file's content. func (n *fsNode) ContentMatches(v []byte) bool { … } // GetContent the content of a fake file. func (n *fsNode) GetContent() []byte { … } // Stat returns an instance of FileInfo. func (n *fsNode) Stat() (os.FileInfo, error) { … } // Walk implements FileSystem. func (n *fsNode) Walk(path string, walkFn filepath.WalkFunc) error { … } // Walk runs the given walkFn on each node. func (n *fsNode) WalkMe(walkFn filepath.WalkFunc) error { … } func (n *fsNode) sortedDirEntries() []string { … } // FileCount returns a count of files. // Directories, empty or otherwise, not counted. func (n *fsNode) FileCount() int { … } func (n *fsNode) DebugPrint() { … } var legalFileNamePattern … // This rules enforced here should be simpler and tighter // than what's allowed on a real OS. // Should be fine for testing or in-memory purposes. func isLegalFileNameForCreation(n string) bool { … } // RegExpGlob returns a list of file paths matching the regexp. // Excludes directories. func (n *fsNode) RegExpGlob(pattern string) ([]string, error) { … } // Glob implements FileSystem. // Glob returns the list of file paths matching // per filepath.Match semantics, i.e. unlike RegExpGlob, // Match("foo/a*") will not match sub-sub directories of foo. // This is how /bin/ls behaves. func (n *fsNode) Glob(pattern string) ([]string, error) { … } type notExistError … func (err notExistError) Error() string { … } func (err notExistError) Unwrap() error { … }