func (fs *fileSystem) RemoveAll(ctx context.Context, path string) error {
	st, err := fs.Stat(ctx, path)
	if err != nil {
		return err
	}
	switch {
	case st.IsDir():
		entries, err := fs.Dirlist(ctx, path)
		if err != nil {
			return err
		}
		for _, e := range entries {
			name := stdpath.Join(path, e.Name())
			err := fs.RemoveAll(ctx, name)
			if err != nil {
				return err
			}
		}
		return fs.RemoveDir(ctx, path)
	default:
		return fs.RemoveFile(ctx, path)
	}
}
// RemoveAll removes path and any children it contains.
// It removes everything it can but returns the first error it encounters.
// If the path does not exist, RemoveAll returns nil (no error.)
RemoveAll removes path and any children it contains.
It removes everything it can but returns the first error it encounters.
If the path does not exist, RemoveAll returns nil (no error.)
// RemoveAll removes path and any children it contains . // It removes everything it can but returns the first error it encounters . // If the path does not exist RemoveAll returns nil ( no error . )
func (fs *fileSystem) RemoveAll(ctx context.Context, path string) error {
	st, err := fs.Stat(ctx, path)
	if err != nil {
		return err
	}
	switch {
	case st.IsDir():
		entries, err := fs.Dirlist(ctx, path)
		if err != nil {
			return err
		}
		for _, e := range entries {
			name := stdpath.Join(path, e.Name())
			err := fs.RemoveAll(ctx, name)
			if err != nil {
				return err
			}
		}
		return fs.RemoveDir(ctx, path)
	default:
		return fs.RemoveFile(ctx, path)
	}
}
func ( fs * fileSystem ) RemoveAll ( ctx context . Context , path string ) error { st , err := fs . Stat ( ctx , path ) if err != nil { return err } switch { case st . IsDir ( ) : entries , err := fs . Dirlist ( ctx , path ) if err != nil { return err } for _ , e := range entries { name := stdpath . Join ( path , e . Name ( ) ) err := fs . RemoveAll ( ctx , name ) if err != nil { return err } } return fs . RemoveDir ( ctx , path ) default : return fs . RemoveFile ( ctx , path ) } }
RemoveAll removes path and any children it contains.
RemoveAll removes path and any children it contains .