// +build go1.16

package smb2

import (
	
)

type wfs struct {
	root  string
	share *Share
}

func ( *Share) ( string) fs.FS {
	return &wfs{
		root:  normPath(),
		share: ,
	}
}

func ( *wfs) ( string) string {
	 = normPath()

	if .root != "" {
		if  != "" {
			 = .root + "\\" + 
		} else {
			 = .root
		}
	}

	return 
}

func ( *wfs) ( string) string {
	 = normPattern()

	if .root != "" {
		 = .root + "\\" + 
	}

	return 
}

func ( *wfs) ( string) (fs.File, error) {
	,  := .share.Open(.path())
	if  != nil {
		return nil, 
	}
	return &wfile{}, nil
}

func ( *wfs) ( string) (fs.FileInfo, error) {
	return .share.Stat(.path())
}

func ( *wfs) ( string) ([]byte, error) {
	return .share.ReadFile(.path())
}

func ( *wfs) ( string) ( []string,  error) {
	,  = .share.Glob(.pattern())
	if  != nil {
		return nil, 
	}

	if .root == "" {
		return , nil
	}

	for ,  := range  {
		[] = [len(.root)+1:]
	}

	return , nil
}

// dirInfo is a DirEntry based on a FileInfo.
type dirInfo struct {
	fileInfo fs.FileInfo
}

func ( dirInfo) () bool {
	return .fileInfo.IsDir()
}

func ( dirInfo) () fs.FileMode {
	return .fileInfo.Mode().Type()
}

func ( dirInfo) () (fs.FileInfo, error) {
	return .fileInfo, nil
}

func ( dirInfo) () string {
	return .fileInfo.Name()
}

func fileInfoToDirEntry( fs.FileInfo) fs.DirEntry {
	if  == nil {
		return nil
	}
	return dirInfo{fileInfo: }
}

type wfile struct {
	*File
}

func ( *wfile) ( int) ( []fs.DirEntry,  error) {
	,  := .Readdir()
	if  != nil {
		return nil, 
	}
	 = make([]fs.DirEntry, len())
	for ,  := range  {
		[] = fileInfoToDirEntry()
	}
	return , nil
}