File tree 2 files changed +21
-6
lines changed
2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change
1
+ package tailpipe
2
+
3
+ import "errors"
4
+
5
+ var (
6
+ // ErrNotSupported is returned when an operation is attempted on an underlying stream that does not support it.
7
+ ErrNotSupported = errors .New ("operation not supported by underlying stream" )
8
+
9
+ // ErrNotRegularFile is returned when a provided file is not a regular file.
10
+ ErrNotRegularFile = errors .New ("provided file is not a regular file" )
11
+ )
Original file line number Diff line number Diff line change 5
5
package tailpipe
6
6
7
7
import (
8
- "errors"
9
8
"io"
10
9
"os"
11
10
"sync"
12
11
"time"
13
12
)
14
13
15
- // The Follow function allows for the creation of a File with an underlying
16
- // stream that may not implement all interfaces which a File implements. Such
17
- // Files will return ErrNotSupported when this is the case.
18
- var ErrNotSupported = errors .New ("Operation not supported by underlying stream" )
19
-
20
14
// A File represents an open normal file. A File is effectively of infinite
21
15
// length; all reads to the file will block until data are available,
22
16
// even if EOF on the underlying file is reached.
@@ -102,6 +96,16 @@ func Open(path string) (*File, error) {
102
96
if err != nil {
103
97
return nil , err
104
98
}
99
+
100
+ fi , err := f .Stat ()
101
+ if err != nil {
102
+ return nil , err
103
+ }
104
+
105
+ if ! fi .Mode ().IsRegular () {
106
+ return nil , ErrNotRegularFile
107
+ }
108
+
105
109
return Follow (f ), err
106
110
}
107
111
You can’t perform that action at this time.
0 commit comments