@@ -41,6 +41,7 @@ type filesMkdir struct{}
41
41
type filesRead struct {}
42
42
type filesWrite struct {}
43
43
type filesStat struct {}
44
+ type filesCp struct {}
44
45
45
46
var (
46
47
FilesLs filesLs
49
50
FilesRead filesRead
50
51
FilesWrite filesWrite
51
52
FilesStat filesStat
53
+ FilesCp filesCp
52
54
)
53
55
54
56
// Stat use long listing format
@@ -203,6 +205,14 @@ func (filesWrite) Hash(hash string) FilesOpt {
203
205
}
204
206
}
205
207
208
+ // Parents make parent directories as needed
209
+ func (filesCp ) Parents (parents bool ) FilesOpt {
210
+ return func (rb * RequestBuilder ) error {
211
+ rb .Option ("parents" , parents )
212
+ return nil
213
+ }
214
+ }
215
+
206
216
// FilesChcid change the cid version or hash function of the root node of a given path
207
217
func (s * Shell ) FilesChcid (ctx context.Context , path string , options ... FilesOpt ) error {
208
218
if len (path ) == 0 {
@@ -220,8 +230,14 @@ func (s *Shell) FilesChcid(ctx context.Context, path string, options ...FilesOpt
220
230
}
221
231
222
232
// FilesCp copy any IPFS files and directories into MFS (or copy within MFS)
223
- func (s * Shell ) FilesCp (ctx context.Context , src string , dest string ) error {
224
- return s .Request ("files/cp" , src , dest ).Exec (ctx , nil )
233
+ func (s * Shell ) FilesCp (ctx context.Context , src string , dest string , options ... FilesOpt ) error {
234
+ rb := s .Request ("files/cp" , src , dest )
235
+ for _ , opt := range options {
236
+ if err := opt (rb ); err != nil {
237
+ return err
238
+ }
239
+ }
240
+ return rb .Exec (ctx , nil )
225
241
}
226
242
227
243
// FilesFlush flush a given path's data to disk
0 commit comments