volume_create_windows.go 894 B

1234567891011121314151617181920212223242526272829303132
  1. // +build windows
  2. package backend
  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/memory_map/os_overloads"
  8. )
  9. func CreateVolumeFile(fileName string, preallocate int64, memoryMapSizeMB uint32) (BackendStorageFile, error) {
  10. if preallocate > 0 {
  11. glog.V(0).Infof("Preallocated disk space for %s is not supported", fileName)
  12. }
  13. if memoryMapSizeMB > 0 {
  14. file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT, 0644, true)
  15. if e != nil {
  16. return nil, e
  17. }
  18. return memory_map.NewMemoryMappedFile(file, memoryMapSizeMB), nil
  19. } else {
  20. file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT|windows.O_TRUNC, 0644, false)
  21. if e != nil {
  22. return nil, e
  23. }
  24. return NewDiskFile(file), nil
  25. }
  26. }