1 // Copyright © 2015 Jerry Jacobs <jerry.jacobs@xor-gate.org>.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
25 func FileOpen(s *sftp.Client, name string) (*File, error) {
26 fd, err := s.Open(name)
30 return &File{fd: fd}, nil
33 func FileCreate(s *sftp.Client, name string) (*File, error) {
34 fd, err := s.Create(name)
38 return &File{fd: fd}, nil
41 func (f *File) Close() error {
45 func (f *File) Name() string {
49 func (f *File) Stat() (os.FileInfo, error) {
53 func (f *File) Sync() error {
57 func (f *File) Truncate(size int64) error {
58 return f.fd.Truncate(size)
61 func (f *File) Read(b []byte) (n int, err error) {
66 func (f *File) ReadAt(b []byte, off int64) (n int, err error) {
71 func (f *File) Readdir(count int) (res []os.FileInfo, err error) {
76 func (f *File) Readdirnames(n int) (names []string, err error) {
80 func (f *File) Seek(offset int64, whence int) (int64, error) {
81 return f.fd.Seek(offset, whence)
84 func (f *File) Write(b []byte) (n int, err error) {
89 func (f *File) WriteAt(b []byte, off int64) (n int, err error) {
93 func (f *File) WriteString(s string) (ret int, err error) {
94 return f.fd.Write([]byte(s))