You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
965 B

5 years ago
5 years ago
  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. }