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.
22 // OsFs is a Fs implementation that uses functions provided by the os package.
24 // For details in any method, check the documentation of the os package
25 // (http://golang.org/pkg/os/).
32 func (OsFs) Name() string { return "OsFs" }
34 func (OsFs) Create(name string) (File, error) {
35 f, e := os.Create(name)
37 // while this looks strange, we need to return a bare nil (of type nil) not
38 // a nil value of type *os.File or nil won't be nil
44 func (OsFs) Mkdir(name string, perm os.FileMode) error {
45 return os.Mkdir(name, perm)
48 func (OsFs) MkdirAll(path string, perm os.FileMode) error {
49 return os.MkdirAll(path, perm)
52 func (OsFs) Open(name string) (File, error) {
55 // while this looks strange, we need to return a bare nil (of type nil) not
56 // a nil value of type *os.File or nil won't be nil
62 func (OsFs) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
63 f, e := os.OpenFile(name, flag, perm)
65 // while this looks strange, we need to return a bare nil (of type nil) not
66 // a nil value of type *os.File or nil won't be nil
72 func (OsFs) Remove(name string) error {
73 return os.Remove(name)
76 func (OsFs) RemoveAll(path string) error {
77 return os.RemoveAll(path)
80 func (OsFs) Rename(oldname, newname string) error {
81 return os.Rename(oldname, newname)
84 func (OsFs) Stat(name string) (os.FileInfo, error) {
88 func (OsFs) Chmod(name string, mode os.FileMode) error {
89 return os.Chmod(name, mode)
92 func (OsFs) Chtimes(name string, atime time.Time, mtime time.Time) error {
93 return os.Chtimes(name, atime, mtime)