summaryrefslogtreecommitdiff
path: root/file.go
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2022-08-15 00:15:04 +0300
committerMarin Ivanov <[email protected]>2022-08-15 00:15:04 +0300
commitb135dcf644394394e3250188dea39ff4e91f0e06 (patch)
treefa5946e5ee66c39fde185dc145274c4e85d36d51 /file.go
parentde77a507ecfe16a9538b20c66ca075a7f780428b (diff)
Add Fs.Open() and read file test
Diffstat (limited to 'file.go')
-rw-r--r--file.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/file.go b/file.go
index c20ab62..2498bd8 100644
--- a/file.go
+++ b/file.go
@@ -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")
}