diff options
Diffstat (limited to 'file.go')
| -rw-r--r-- | file.go | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -1,21 +1,29 @@ package s3 import ( + "context" + "io" "os" + "path" ) type File struct { - name string + fs *Fs + key string + r io.ReadCloser + w io.WriteCloser + cancel context.CancelFunc } // implements io.Closer func (f *File) Close() error { - panic("not implemented") + f.cancel() + return nil } // implements io.Reader func (f *File) Read(b []byte) (int, error) { - panic("not implemented") + return f.r.Read(b) } // implements io.ReaderAt @@ -25,7 +33,7 @@ func (f *File) ReadAt(p []byte, off int64) (int, error) { // implements io.Writer func (f *File) Write(p []byte) (int, error) { - panic("not implemented") + return f.w.Write(p) } // implements io.WriterAt @@ -34,7 +42,7 @@ func (f *File) WriteAt(p []byte, off int64) (int, error) { } func (f *File) Name() string { - return f.name + return path.Base(f.key) } func (f *File) Readdir(count int) ([]os.FileInfo, error) { @@ -45,10 +53,14 @@ func (f *File) Readdirnames(n int) ([]string, error) { panic("not implemented") } -func (f *File) Stat() (os.FileInfo, error) { +func (f *File) Seek(offset int64, whence int) (int64, error) { panic("not implemented") } +func (f *File) Stat() (os.FileInfo, error) { + return f.fs.Stat(f.key) +} + func (f *File) Sync() error { panic("not implemented") } |
