volume_create_windows.go 965 B

123456789101112131415161718192021222324252627282930313233
  1. // +build windows
  2. package storage
  3. import (
  4. "github.com/chrislusf/seaweedfs/weed/storage/backend/memory_map"
  5. "golang.org/x/sys/windows"
  6. "github.com/chrislusf/seaweedfs/weed/glog"
  7. "github.com/chrislusf/seaweedfs/weed/storage/backend"
  8. "github.com/chrislusf/seaweedfs/weed/storage/backend/memory_map/os_overloads"
  9. )
  10. func createVolumeFile(fileName string, preallocate int64, memoryMapSizeMB uint32) (backend.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 backend.NewDiskFile(file), nil
  26. }
  27. }