volume_create_windows.go 888 B

12345678910111213141516171819202122232425262728
  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.DataStorageBackend, 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. return memory_map.NewMemoryMappedFile(file, memoryMapSizeMB), e
  17. } else {
  18. file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT|windows.O_TRUNC, 0644, false)
  19. return backend.NewDiskFile(file), e
  20. }
  21. }