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.

28 lines
888 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. 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. }