From a679d4a95ec6401c4a6014b2bb61ceba215a5b9a Mon Sep 17 00:00:00 2001 From: Steve Francia Date: Mon, 11 Jan 2016 14:28:57 -0500 Subject: [PATCH] Add BADFD constant to permit compilation on darwin --- const_darwin.go | 21 +++++++++++++++++++++ const_win_unix.go | 21 +++++++++++++++++++++ union.go | 20 ++++++++++---------- 3 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 const_darwin.go create mode 100644 const_win_unix.go diff --git a/const_darwin.go b/const_darwin.go new file mode 100644 index 0000000..19c169a --- /dev/null +++ b/const_darwin.go @@ -0,0 +1,21 @@ +// Copyright © 2016 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +build darwin + +package afero + +import ( + "syscall" +) + +const BADFD = syscall.EBADF diff --git a/const_win_unix.go b/const_win_unix.go new file mode 100644 index 0000000..3d246ef --- /dev/null +++ b/const_win_unix.go @@ -0,0 +1,21 @@ +// Copyright © 2016 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +build !darwin + +package afero + +import ( + "syscall" +) + +const BADFD = syscall.EBADFD diff --git a/union.go b/union.go index bd6cff4..828cf0c 100644 --- a/union.go +++ b/union.go @@ -94,7 +94,7 @@ func (f *UnionFile) Close() error { if f.layer != nil { return f.layer.Close() } - return syscall.EBADFD + return BADFD } func (f *UnionFile) Read(s []byte) (int, error) { @@ -114,7 +114,7 @@ func (f *UnionFile) Read(s []byte) (int, error) { if f.base != nil { return f.base.Read(s) } - return 0, syscall.EBADFD + return 0, BADFD } func (f *UnionFile) ReadAt(s []byte, o int64) (int, error) { @@ -128,7 +128,7 @@ func (f *UnionFile) ReadAt(s []byte, o int64) (int, error) { if f.base != nil { return f.base.ReadAt(s, o) } - return 0, syscall.EBADFD + return 0, BADFD } func (f *UnionFile) Seek(o int64, w int) (pos int64, err error) { @@ -142,7 +142,7 @@ func (f *UnionFile) Seek(o int64, w int) (pos int64, err error) { if f.base != nil { return f.base.Seek(o, w) } - return 0, syscall.EBADFD + return 0, BADFD } func (f *UnionFile) Write(s []byte) (n int, err error) { @@ -156,7 +156,7 @@ func (f *UnionFile) Write(s []byte) (n int, err error) { if f.base != nil { return f.base.Write(s) } - return 0, syscall.EBADFD + return 0, BADFD } func (f *UnionFile) WriteAt(s []byte, o int64) (n int, err error) { @@ -170,7 +170,7 @@ func (f *UnionFile) WriteAt(s []byte, o int64) (n int, err error) { if f.base != nil { return f.base.WriteAt(s, o) } - return 0, syscall.EBADFD + return 0, BADFD } func (f *UnionFile) Name() string { @@ -234,7 +234,7 @@ func (f *UnionFile) Stat() (os.FileInfo, error) { if f.base != nil { return f.base.Stat() } - return nil, syscall.EBADFD + return nil, BADFD } func (f *UnionFile) Sync() (err error) { @@ -248,7 +248,7 @@ func (f *UnionFile) Sync() (err error) { if f.base != nil { return f.base.Sync() } - return syscall.EBADFD + return BADFD } func (f *UnionFile) Truncate(s int64) (err error) { @@ -262,7 +262,7 @@ func (f *UnionFile) Truncate(s int64) (err error) { if f.base != nil { return f.base.Truncate(s) } - return syscall.EBADFD + return BADFD } func (f *UnionFile) WriteString(s string) (n int, err error) { @@ -276,5 +276,5 @@ func (f *UnionFile) WriteString(s string) (n int, err error) { if f.base != nil { return f.base.WriteString(s) } - return 0, syscall.EBADFD + return 0, BADFD }