diff options
author | Santiago M. Mola <santi@mola.io> | 2016-10-31 16:11:07 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-10-31 15:11:07 +0000 |
commit | 5078f52a9f2217027b0f475d5a91e677b3228588 (patch) | |
tree | ad42e162e131456052938d77977c1030281126b9 /utils/fs/fs.go | |
parent | 659386309f36c482ddc0bb9e854ebda3da216491 (diff) | |
download | go-git-5078f52a9f2217027b0f475d5a91e677b3228588.tar.gz |
utils/fs: add OpenFile method to filesystem interface. (#104)
* utils/fs: add OpenFile method to filesystem interface.
* added OpenFile to fs.Filesystem interface.
* added OpenFile implementation to 'os' filesystem.
* bring back BaseFile.
* utils/fs/os: do not use wildcard import.
* utils/fs/os: implement Open and Create using OpenFile.
Diffstat (limited to 'utils/fs/fs.go')
-rw-r--r-- | utils/fs/fs.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/utils/fs/fs.go b/utils/fs/fs.go index 463425c..7e6c01f 100644 --- a/utils/fs/fs.go +++ b/utils/fs/fs.go @@ -14,10 +14,9 @@ var ( ) type Filesystem interface { - //Create opens a file in write-only mode. Create(filename string) (File, error) - //Open opens a file in read-only mode. Open(filename string) (File, error) + OpenFile(filename string, flag int, perm os.FileMode) (File, error) Stat(filename string) (FileInfo, error) ReadDir(path string) ([]FileInfo, error) TempFile(dir, prefix string) (File, error) @@ -38,3 +37,16 @@ type File interface { } type FileInfo os.FileInfo + +type BaseFile struct { + BaseFilename string + Closed bool +} + +func (f *BaseFile) Filename() string { + return f.BaseFilename +} + +func (f *BaseFile) IsClosed() bool { + return f.Closed +} |