1 // Copyright © 2014 Steve Francia <spf@spf13.com>.
2 // Copyright 2013 tsuru authors. All rights reserved.
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 // Package afero provides types and methods for interacting with the filesystem,
16 // as an abstraction layer.
18 // Afero also provides a few implementations that are mostly interoperable. One that
19 // uses the operating system filesystem, one that uses memory to store files
20 // (cross platform) and an interface that should be implemented if you want to
21 // provide your own filesystem.
36 // File represents a file in the filesystem.
46 Readdir(count int) ([]os.FileInfo, error)
47 Readdirnames(n int) ([]string, error)
48 Stat() (os.FileInfo, error)
50 Truncate(size int64) error
51 WriteString(s string) (ret int, err error)
54 // Fs is the filesystem interface.
56 // Any simulated or real filesystem should implement this interface.
58 // Create creates a file in the filesystem, returning the file and an
59 // error, if any happens.
60 Create(name string) (File, error)
62 // Mkdir creates a directory in the filesystem, return an error if any
64 Mkdir(name string, perm os.FileMode) error
66 // MkdirAll creates a directory path and all parents that does not exist
68 MkdirAll(path string, perm os.FileMode) error
70 // Open opens a file, returning it or an error, if any happens.
71 Open(name string) (File, error)
73 // OpenFile opens a file using the given flags and the given mode.
74 OpenFile(name string, flag int, perm os.FileMode) (File, error)
76 // Remove removes a file identified by name, returning an error, if any
78 Remove(name string) error
80 // RemoveAll removes a directory path and any children it contains. It
81 // does not fail if the path does not exist (return nil).
82 RemoveAll(path string) error
84 // Rename renames a file.
85 Rename(oldname, newname string) error
87 // Stat returns a FileInfo describing the named file, or an error, if any
89 Stat(name string) (os.FileInfo, error)
91 // The name of this FileSystem
94 //Chmod changes the mode of the named file to mode.
95 Chmod(name string, mode os.FileMode) error
97 //Chtimes changes the access and modification times of the named file
98 Chtimes(name string, atime time.Time, mtime time.Time) error
102 ErrFileClosed = errors.New("File is closed")
103 ErrOutOfRange = errors.New("Out of range")
104 ErrTooLarge = errors.New("Too large")
105 ErrFileNotFound = os.ErrNotExist
106 ErrFileExists = os.ErrExist
107 ErrDestinationExists = os.ErrExist