github.com/zuoyebang/bitalostable@v1.0.1-0.20240229032404-e3b99a834294/vfs/dir_windows.go (about)

     1  // Copyright 2014 The LevelDB-Go and Pebble Authors. All rights reserved. Use
     2  // of this source code is governed by a BSD-style license that can be found in
     3  // the LICENSE file.
     4  
     5  //go:build windows
     6  // +build windows
     7  
     8  package vfs
     9  
    10  import (
    11  	"os"
    12  	"syscall"
    13  
    14  	"github.com/cockroachdb/errors"
    15  )
    16  
    17  type windowsDir struct {
    18  	File
    19  }
    20  
    21  func (windowsDir) Sync() error {
    22  	// Silently ignore Sync() on Windows. This is the same behavior as
    23  	// RocksDB. See port/win/io_win.cc:WinDirectory::Fsync().
    24  	return nil
    25  }
    26  
    27  func (defaultFS) OpenDir(name string) (File, error) {
    28  	f, err := os.OpenFile(name, syscall.O_CLOEXEC, 0)
    29  	if err != nil {
    30  		return nil, errors.WithStack(err)
    31  	}
    32  	return windowsDir{f}, nil
    33  }