NewFsFile creates an Fs from a name but may point to a file. It returns a string with the file name if points to a file otherwise "".
(remote string)
| 83 | // It returns a string with the file name if points to a file |
| 84 | // otherwise "". |
| 85 | func NewFsFile(remote string) (fs.Fs, string) { |
| 86 | ctx := context.Background() |
| 87 | _, fsPath, err := fspath.SplitFs(remote) |
| 88 | if err != nil { |
| 89 | err = fs.CountError(ctx, err) |
| 90 | fs.Fatalf(nil, "Failed to create file system for %q: %v", remote, err) |
| 91 | } |
| 92 | f, err := cache.Get(ctx, remote) |
| 93 | switch err { |
| 94 | case fs.ErrorIsFile: |
| 95 | cache.Pin(f) // pin indefinitely since it was on the CLI |
| 96 | return f, path.Base(fsPath) |
| 97 | case nil: |
| 98 | cache.Pin(f) // pin indefinitely since it was on the CLI |
| 99 | return f, "" |
| 100 | default: |
| 101 | err = fs.CountError(ctx, err) |
| 102 | fs.Fatalf(nil, "Failed to create file system for %q: %v", remote, err) |
| 103 | } |
| 104 | return nil, "" |
| 105 | } |
| 106 | |
| 107 | // newFsFileAddFilter creates an src Fs from a name |
| 108 | // |
no test coverage detected
searching dependent graphs…