github.com/docker/engine@v22.0.0-20211208180946-d456264580cf+incompatible/volume/local/local_windows.go (about)

     1  // Package local provides the default implementation for volumes. It
     2  // is used to mount data volume containers and directories local to
     3  // the host server.
     4  package local // import "github.com/docker/docker/volume/local"
     5  
     6  import (
     7  	"os"
     8  	"path/filepath"
     9  	"strings"
    10  	"syscall"
    11  	"time"
    12  
    13  	"github.com/docker/docker/errdefs"
    14  	"github.com/pkg/errors"
    15  )
    16  
    17  type optsConfig struct{}
    18  
    19  // scopedPath verifies that the path where the volume is located
    20  // is under Docker's root and the valid local paths.
    21  func (r *Root) scopedPath(realPath string) bool {
    22  	if strings.HasPrefix(realPath, filepath.Join(r.scope, volumesPathName)) && realPath != filepath.Join(r.scope, volumesPathName) {
    23  		return true
    24  	}
    25  	return false
    26  }
    27  
    28  func setOpts(v *localVolume, opts map[string]string) error {
    29  	if len(opts) > 0 {
    30  		return errdefs.InvalidParameter(errors.New("options are not supported on this platform"))
    31  	}
    32  	return nil
    33  }
    34  
    35  func (v *localVolume) needsMount() bool {
    36  	return false
    37  }
    38  
    39  func (v *localVolume) mount() error {
    40  	return nil
    41  }
    42  func (v *localVolume) unmount() error {
    43  	return nil
    44  }
    45  
    46  func unmount(_ string) {}
    47  
    48  func (v *localVolume) postMount() error {
    49  	return nil
    50  }
    51  
    52  func (v *localVolume) CreatedAt() (time.Time, error) {
    53  	fileInfo, err := os.Stat(v.path)
    54  	if err != nil {
    55  		return time.Time{}, err
    56  	}
    57  	ft := fileInfo.Sys().(*syscall.Win32FileAttributeData).CreationTime
    58  	return time.Unix(0, ft.Nanoseconds()), nil
    59  }