1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-19 21:20:31 +08:00
Files
kubo/commands/files/linkfile.go
Jeromy d993bc04d6 implement symlinks in unixfs, first draft
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-08-30 13:33:42 -07:00

51 lines
717 B
Go

package files
import (
"io"
"os"
"strings"
)
type Symlink struct {
name string
path string
Target string
stat os.FileInfo
reader io.Reader
}
func NewLinkFile(name, path, target string, stat os.FileInfo) File {
return &Symlink{
name: name,
path: path,
Target: target,
stat: stat,
reader: strings.NewReader(target),
}
}
func (lf *Symlink) IsDirectory() bool {
return false
}
func (lf *Symlink) NextFile() (File, error) {
return nil, io.EOF
}
func (f *Symlink) FileName() string {
return f.name
}
func (f *Symlink) Close() error {
return nil
}
func (f *Symlink) FullPath() string {
return f.path
}
func (f *Symlink) Read(b []byte) (int, error) {
return f.reader.Read(b)
}