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.

38 lines
1016 B

  1. // +build windows
  2. package storage
  3. import (
  4. "os"
  5. "github.com/chrislusf/seaweedfs/weed/storage/memory_map"
  6. "golang.org/x/sys/windows"
  7. "github.com/chrislusf/seaweedfs/weed/glog"
  8. "github.com/chrislusf/seaweedfs/weed/os_overloads"
  9. )
  10. func createVolumeFile(fileName string, preallocate int64, memoryMapSizeMB uint32) (*os.File, error) {
  11. mMap, exists := memory_map.FileMemoryMap[fileName]
  12. if !exists {
  13. if preallocate > 0 {
  14. glog.V(0).Infof("Preallocated disk space for %s is not supported", fileName)
  15. }
  16. if memoryMapSizeMB > 0 {
  17. file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT, 0644, true)
  18. memory_map.FileMemoryMap[fileName] = new(memory_map.MemoryMap)
  19. new_mMap := memory_map.FileMemoryMap[fileName]
  20. new_mMap.CreateMemoryMap(file, 1024*1024*uint64(memoryMapSizeMB))
  21. return file, e
  22. } else {
  23. file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT|windows.O_TRUNC, 0644, false)
  24. return file, e
  25. }
  26. } else {
  27. return mMap.File, nil
  28. }
  29. }