github.com/IBM/fsgo@v0.0.0-20220920202152-e16fd2119d49/symlink.go (about)

     1  // Copyright 2022 IBM Inc. All rights reserved
     2  // Copyright © 2014 Steve Francia <spf@spf13.com>
     3  //
     4  // SPDX-License-Identifier: Apache2.0
     5  package fsgo
     6  
     7  import (
     8  	"errors"
     9  )
    10  
    11  // Symlinker is an optional interface in Fsgo. It is only implemented by the
    12  // filesystems saying so.
    13  // It indicates support for 3 symlink related interfaces that implement the
    14  // behaviors of the os methods:
    15  //   - Lstat
    16  //   - Symlink, and
    17  //   - Readlink
    18  type Symlinker interface {
    19  	Lstater
    20  	Linker
    21  	LinkReader
    22  }
    23  
    24  // Linker is an optional interface in Fsgo. It is only implemented by the
    25  // filesystems saying so.
    26  // It will call Symlink if the filesystem itself is, or it delegates to, the os filesystem,
    27  // or the filesystem otherwise supports Symlink's.
    28  type Linker interface {
    29  	SymlinkIfPossible(oldname, newname string) error
    30  }
    31  
    32  // ErrNoSymlink is the error that will be wrapped in an os.LinkError if a file system
    33  // does not support Symlink's either directly or through its delegated filesystem.
    34  // As expressed by support for the Linker interface.
    35  var ErrNoSymlink = errors.New("symlink not supported")
    36  
    37  // LinkReader is an optional interface in Fsgo. It is only implemented by the
    38  // filesystems saying so.
    39  type LinkReader interface {
    40  	ReadlinkIfPossible(name string) (string, error)
    41  }
    42  
    43  // ErrNoReadlink is the error that will be wrapped in an os.Path if a file system
    44  // does not support the readlink operation either directly or through its delegated filesystem.
    45  // As expressed by support for the LinkReader interface.
    46  var ErrNoReadlink = errors.New("readlink not supported")