MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / CopyDir

Method CopyDir

drivers/smb/util.go:91–120  ·  view source on GitHub ↗

CopyDir Dir copies a whole directory recursively

(src string, dst string)

Source from the content-addressed store, hash-verified

89
90// CopyDir Dir copies a whole directory recursively
91func (d *SMB) CopyDir(src string, dst string) error {
92 var err error
93 var fds []fs.FileInfo
94 var srcinfo fs.FileInfo
95
96 if srcinfo, err = d.fs.Stat(src); err != nil {
97 return err
98 }
99 if err = d.fs.MkdirAll(dst, srcinfo.Mode()); err != nil {
100 return err
101 }
102 if fds, err = d.fs.ReadDir(src); err != nil {
103 return err
104 }
105 for _, fd := range fds {
106 srcfp := filepath.Join(src, fd.Name())
107 dstfp := filepath.Join(dst, fd.Name())
108
109 if fd.IsDir() {
110 if err = d.CopyDir(srcfp, dstfp); err != nil {
111 return err
112 }
113 } else {
114 if err = d.CopyFile(srcfp, dstfp); err != nil {
115 return err
116 }
117 }
118 }
119 return nil
120}
121
122// Exists determine whether the file exists
123func (d *SMB) Exists(name string) bool {

Callers 1

CopyMethod · 0.95

Calls 7

CopyFileMethod · 0.95
NameMethod · 0.65
IsDirMethod · 0.65
StatMethod · 0.45
MkdirAllMethod · 0.45
ModeMethod · 0.45
ReadDirMethod · 0.45

Tested by

no test coverage detected