xref: /aosp_15_r20/build/soong/cmd/find_input_delta/find_input_delta_lib/fs.go (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1// Copyright 2024 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package find_input_delta_lib
16
17import (
18	"io/fs"
19	"os"
20)
21
22// OsFs provides a minimal implementation so that we can use testing/fstest for
23// unit tests.
24var OsFs fileSystem = osFS{}
25
26type fileSystem interface {
27	Open(path string) (fs.File, error)
28	Stat(path string) (os.FileInfo, error)
29	ReadFile(path string) ([]byte, error)
30}
31
32// osFS implements fileSystem using the local disk.
33type osFS struct{}
34
35func (osFS) Open(path string) (fs.File, error)     { return os.Open(path) }
36func (osFS) Stat(path string) (os.FileInfo, error) { return os.Stat(path) }
37func (osFS) ReadFile(path string) ([]byte, error)  { return os.ReadFile(path) }
38