volume_create_windows.go 913 B

123456789101112131415161718192021222324252627282930313233
  1. //go:build windows
  2. // +build windows
  3. package backend
  4. import (
  5. "github.com/seaweedfs/seaweedfs/weed/storage/backend/memory_map"
  6. "golang.org/x/sys/windows"
  7. "github.com/seaweedfs/seaweedfs/weed/glog"
  8. "github.com/seaweedfs/seaweedfs/weed/storage/backend/memory_map/os_overloads"
  9. )
  10. func CreateVolumeFile(fileName string, preallocate int64, memoryMapSizeMB uint32) (BackendStorageFile, error) {
  11. if preallocate > 0 {
  12. glog.V(0).Infof("Preallocated disk space for %s is not supported", fileName)
  13. }
  14. if memoryMapSizeMB > 0 {
  15. file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT, 0644, true)
  16. if e != nil {
  17. return nil, e
  18. }
  19. return memory_map.NewMemoryMappedFile(file, memoryMapSizeMB), nil
  20. } else {
  21. file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT|windows.O_TRUNC, 0644, false)
  22. if e != nil {
  23. return nil, e
  24. }
  25. return NewDiskFile(file), nil
  26. }
  27. }