Line data Source code
1 : // Copyright 2023 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 : // Package vfstest provides facilities for interacting with or faking 6 : // filesystems during tests and benchmarks. 7 : package vfstest 8 : 9 : import ( 10 : "os" 11 : 12 : "github.com/cockroachdb/pebble/vfs" 13 : ) 14 : 15 : // DiscardFile implements vfs.File but discards all written data and reads 16 : // without mutating input buffers. 17 : var DiscardFile vfs.File = (*discardFile)(nil) 18 : 19 : type discardFile struct{} 20 : 21 1 : func (*discardFile) Close() error { return nil } 22 0 : func (*discardFile) Read(p []byte) (int, error) { return len(p), nil } 23 0 : func (*discardFile) ReadAt(p []byte, off int64) (int, error) { return len(p), nil } 24 1 : func (*discardFile) Write(p []byte) (int, error) { return len(p), nil } 25 0 : func (*discardFile) WriteAt(p []byte, ofs int64) (int, error) { return len(p), nil } 26 0 : func (*discardFile) Preallocate(offset, length int64) error { return nil } 27 0 : func (*discardFile) Stat() (os.FileInfo, error) { return nil, nil } 28 1 : func (*discardFile) Sync() error { return nil } 29 0 : func (*discardFile) SyncTo(length int64) (fullSync bool, err error) { return false, nil } 30 0 : func (*discardFile) SyncData() error { return nil } 31 0 : func (*discardFile) Prefetch(offset int64, length int64) error { return nil } 32 0 : func (*discardFile) Fd() uintptr { return 0 }