LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This file defines types for abstract file system access and | 5 // This file defines types for abstract file system access and |
6 // provides an implementation accessing the file system of the | 6 // provides an implementation accessing the file system of the |
7 // underlying OS. | 7 // underlying OS. |
8 | 8 |
9 package main | 9 package main |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 func (osFS) Open(path string) (io.ReadCloser, error) { | 45 func (osFS) Open(path string) (io.ReadCloser, error) { |
46 f, err := os.Open(path) | 46 f, err := os.Open(path) |
47 if err != nil { | 47 if err != nil { |
48 return nil, err | 48 return nil, err |
49 } | 49 } |
50 fi, err := f.Stat() | 50 fi, err := f.Stat() |
51 if err != nil { | 51 if err != nil { |
52 return nil, err | 52 return nil, err |
53 } | 53 } |
54 » if fi.Mode().IsDir() { | 54 » if fi.IsDir() { |
55 return nil, fmt.Errorf("Open: %s is a directory", path) | 55 return nil, fmt.Errorf("Open: %s is a directory", path) |
56 } | 56 } |
57 return f, nil | 57 return f, nil |
58 } | 58 } |
59 | 59 |
60 func (osFS) Lstat(path string) (os.FileInfo, error) { | 60 func (osFS) Lstat(path string) (os.FileInfo, error) { |
61 return os.Lstat(path) | 61 return os.Lstat(path) |
62 } | 62 } |
63 | 63 |
64 func (osFS) Stat(path string) (os.FileInfo, error) { | 64 func (osFS) Stat(path string) (os.FileInfo, error) { |
65 return os.Stat(path) | 65 return os.Stat(path) |
66 } | 66 } |
67 | 67 |
68 func (osFS) ReadDir(path string) ([]os.FileInfo, error) { | 68 func (osFS) ReadDir(path string) ([]os.FileInfo, error) { |
69 return ioutil.ReadDir(path) // is sorted | 69 return ioutil.ReadDir(path) // is sorted |
70 } | 70 } |
LEFT | RIGHT |