This repository has been archived by the owner on Jun 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
unixfs.go
95 lines (82 loc) · 2.54 KB
/
unixfs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package iface
import (
"context"
"github.com/ipfs/interface-go-ipfs-core/options"
path "github.com/ipfs/interface-go-ipfs-core/path"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-libipfs/files"
)
// Deprecated: use github.com/ipfs/boxo/coreiface.AddEvent
type AddEvent struct {
Name string
Path path.Resolved `json:",omitempty"`
Bytes int64 `json:",omitempty"`
Size string `json:",omitempty"`
}
// FileType is an enum of possible UnixFS file types.
//
// Deprecated: use github.com/ipfs/boxo/coreiface.FileType
type FileType int32
const (
// TUnknown means the file type isn't known (e.g., it hasn't been
// resolved).
//
// Deprecated: use github.com/ipfs/boxo/coreiface.TUnknown
TUnknown FileType = iota
// TFile is a regular file.
//
// Deprecated: use github.com/ipfs/boxo/coreiface.TFile
TFile
// TDirectory is a directory.
//
// Deprecated: use github.com/ipfs/boxo/coreiface.TDirectory
TDirectory
// TSymlink is a symlink.
//
// Deprecated: use github.com/ipfs/boxo/coreiface.TSymlink
TSymlink
)
func (t FileType) String() string {
switch t {
case TUnknown:
return "unknown"
case TFile:
return "file"
case TDirectory:
return "directory"
case TSymlink:
return "symlink"
default:
return "<unknown file type>"
}
}
// DirEntry is a directory entry returned by `Ls`.
//
// Deprecated: use github.com/ipfs/boxo/coreiface.DirEntry
type DirEntry struct {
Name string
Cid cid.Cid
// Only filled when asked to resolve the directory entry.
Size uint64 // The size of the file in bytes (or the size of the symlink).
Type FileType // The type of the file.
Target string // The symlink target (if a symlink).
Err error
}
// UnixfsAPI is the basic interface to immutable files in IPFS
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
//
// Deprecated: use github.com/ipfs/boxo/coreiface.UnixfsAPI
type UnixfsAPI interface {
// Add imports the data from the reader into merkledag file
//
// TODO: a long useful comment on how to use this for many different scenarios
Add(context.Context, files.Node, ...options.UnixfsAddOption) (path.Resolved, error)
// Get returns a read-only handle to a file tree referenced by a path
//
// Note that some implementations of this API may apply the specified context
// to operations performed on the returned file
Get(context.Context, path.Path) (files.Node, error)
// Ls returns the list of links in a directory. Links aren't guaranteed to be
// returned in order
Ls(context.Context, path.Path, ...options.UnixfsLsOption) (<-chan DirEntry, error)
}