Path: blob/main/vendor/github.com/spf13/afero/symlink.go
2875 views
// Copyright © 2018 Steve Francia <[email protected]>.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5// http://www.apache.org/licenses/LICENSE-2.06//7// Unless required by applicable law or agreed to in writing, software8// distributed under the License is distributed on an "AS IS" BASIS,9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.10// See the License for the specific language governing permissions and11// limitations under the License.1213package afero1415import (16"errors"17)1819// Symlinker is an optional interface in Afero. It is only implemented by the20// filesystems saying so.21// It indicates support for 3 symlink related interfaces that implement the22// behaviors of the os methods:23// - Lstat24// - Symlink, and25// - Readlink26type Symlinker interface {27Lstater28Linker29LinkReader30}3132// Linker is an optional interface in Afero. It is only implemented by the33// filesystems saying so.34// It will call Symlink if the filesystem itself is, or it delegates to, the os filesystem,35// or the filesystem otherwise supports Symlink's.36type Linker interface {37SymlinkIfPossible(oldname, newname string) error38}3940// ErrNoSymlink is the error that will be wrapped in an os.LinkError if a file system41// does not support Symlink's either directly or through its delegated filesystem.42// As expressed by support for the Linker interface.43var ErrNoSymlink = errors.New("symlink not supported")4445// LinkReader is an optional interface in Afero. It is only implemented by the46// filesystems saying so.47type LinkReader interface {48ReadlinkIfPossible(name string) (string, error)49}5051// ErrNoReadlink is the error that will be wrapped in an os.Path if a file system52// does not support the readlink operation either directly or through its delegated filesystem.53// As expressed by support for the LinkReader interface.54var ErrNoReadlink = errors.New("readlink not supported")555657