MCPcopy
hub / github.com/rclone/rclone / NewFsSrcDstFiles

Function NewFsSrcDstFiles

cmd/cmd.go:180–212  ·  view source on GitHub ↗

NewFsSrcDstFiles creates a new src and dst fs from the arguments If src is a file then srcFileName and dstFileName will be non-empty

(args []string)

Source from the content-addressed store, hash-verified

178// NewFsSrcDstFiles creates a new src and dst fs from the arguments
179// If src is a file then srcFileName and dstFileName will be non-empty
180func NewFsSrcDstFiles(args []string) (fsrc fs.Fs, srcFileName string, fdst fs.Fs, dstFileName string) {
181 ctx := context.Background()
182 fsrc, srcFileName = newFsFileAddFilter(args[0])
183 // If copying a file...
184 dstRemote := args[1]
185 // If file exists then srcFileName != "", however if the file
186 // doesn't exist then we assume it is a directory...
187 if srcFileName != "" {
188 var err error
189 dstRemote, dstFileName, err = fspath.Split(dstRemote)
190 if err != nil {
191 fs.Fatalf(nil, "Parsing %q failed: %v", args[1], err)
192 }
193 if dstRemote == "" {
194 dstRemote = "."
195 }
196 if dstFileName == "" {
197 fs.Fatalf(nil, "%q is a directory", args[1])
198 }
199 }
200 fdst, err := cache.Get(ctx, dstRemote)
201 switch err {
202 case fs.ErrorIsFile:
203 _ = fs.CountError(ctx, err)
204 fs.Fatalf(nil, "Source doesn't exist or is a directory and destination is a file")
205 case nil:
206 default:
207 _ = fs.CountError(ctx, err)
208 fs.Fatalf(nil, "Failed to create file system for destination %q: %v", dstRemote, err)
209 }
210 cache.Pin(fdst) // pin indefinitely since it was on the CLI
211 return
212}
213
214// NewFsDstFile creates a new dst fs with a destination file name from the arguments
215func NewFsDstFile(args []string) (fdst fs.Fs, dstFileName string) {

Callers 3

moveto.goFile · 0.92
cmd.goFile · 0.92
copyto.goFile · 0.92

Calls 5

SplitFunction · 0.92
FatalfFunction · 0.92
GetFunction · 0.92
PinFunction · 0.92
newFsFileAddFilterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…