func (f *Fs) CopyDir(src string, dst string) error {
	srcInfo, err := f.AferoFs.Stat(src)
	if err != nil {
		return errors.Wrap(err, "stat src dir")
	}

	dir, err := f.AferoFs.Open(src)
	if err != nil {
		return errors.Wrap(err, "open src dir")
	}
	defer dir.Close()

	entries, err := dir.Readdir(-1)
	if err != nil {
		return errors.Wrap(err, "read src dir")
	}

	dstExists, err := f.Exists(dst)
	if err != nil {
		return errors.Wrap(err, "checking if dst dir exists")
	}

	if !dstExists {
		if err = f.MkdirAll(dst, srcInfo.Mode()); err != nil {
			return errors.Wrap(err, "make dst dir")
		}
	}

	for _, e := range entries {
		srcFullPath := filepath.Join(src, e.Name())
		dstFullPath := filepath.Join(dst, e.Name())

		if e.IsDir() {
			if err = f.CopyDir(srcFullPath, dstFullPath); err != nil {
				return errors.Wrap(err, "copy dir")
			}
		} else {
			if err = f.CopyFile(srcFullPath, dstFullPath); err != nil {
				return errors.Wrap(err, "copy file")
			}
		}
	}

	return nil
}
// CopyDir copies the contents of the given directory to another directory on the same filesystem.
CopyDir copies the contents of the given directory to another directory on the same filesystem.
// CopyDir copies the contents of the given directory to another directory on the same filesystem .
func (f *Fs) CopyDir(src string, dst string) error {
	srcInfo, err := f.AferoFs.Stat(src)
	if err != nil {
		return errors.Wrap(err, "stat src dir")
	}
	dir, err := f.AferoFs.Open(src)
	if err != nil {
		return errors.Wrap(err, "open src dir")
	}
	defer dir.Close()
	entries, err := dir.Readdir(-1)
	if err != nil {
		return errors.Wrap(err, "read src dir")
	}
	dstExists, err := f.Exists(dst)
	if err != nil {
		return errors.Wrap(err, "checking if dst dir exists")
	}
	if !dstExists {
		if err = f.MkdirAll(dst, srcInfo.Mode()); err != nil {
			return errors.Wrap(err, "make dst dir")
		}
	}
	for _, e := range entries {
		srcFullPath := filepath.Join(src, e.Name())
		dstFullPath := filepath.Join(dst, e.Name())
		if e.IsDir() {
			if err = f.CopyDir(srcFullPath, dstFullPath); err != nil {
				return errors.Wrap(err, "copy dir")
			}
		} else {
			if err = f.CopyFile(srcFullPath, dstFullPath); err != nil {
				return errors.Wrap(err, "copy file")
			}
		}
	}
	return nil
}
func ( f * Fs ) CopyDir ( src string , dst string ) error { srcInfo , err := f . AferoFs . Stat ( src ) if err != nil { return errors . Wrap ( err , " " ) } dir , err := f . AferoFs . Open ( src ) if err != nil { return errors . Wrap ( err , " " ) } defer dir . Close ( ) entries , err := dir . Readdir ( - 1 ) if err != nil { return errors . Wrap ( err , " " ) } dstExists , err := f . Exists ( dst ) if err != nil { return errors . Wrap ( err , " " ) } if ! dstExists { if err = f . MkdirAll ( dst , srcInfo . Mode ( ) ) ; err != nil { return errors . Wrap ( err , " " ) } } for _ , e := range entries { srcFullPath := filepath . Join ( src , e . Name ( ) ) dstFullPath := filepath . Join ( dst , e . Name ( ) ) if e . IsDir ( ) { if err = f . CopyDir ( srcFullPath , dstFullPath ) ; err != nil { return errors . Wrap ( err , " " ) } } else { if err = f . CopyFile ( srcFullPath , dstFullPath ) ; err != nil { return errors . Wrap ( err , " " ) } } } return nil }
CopyDir copies the contents of the given directory to another directory on the same filesystem.
CopyDir copies the contents of the given directory to another directory on the same filesystem .