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

     1  // Copyright 2019 The LevelDB-Go and Pebble and Bitalostored 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  package bitalostable
     6  
     7  import "github.com/zuoyebang/bitalostable/vfs"
     8  
     9  // syncingFS wraps a vfs.FS with one that wraps newly created files with
    10  // vfs.NewSyncingFile.
    11  type syncingFS struct {
    12  	vfs.FS
    13  	syncOpts vfs.SyncingFileOptions
    14  }
    15  
    16  func (fs syncingFS) Create(name string) (vfs.File, error) {
    17  	f, err := fs.FS.Create(name)
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  	return vfs.NewSyncingFile(f, fs.syncOpts), nil
    22  }