mirror of
https://github.com/versity/versitygw.git
synced 2026-09-06 16:16:53 +00:00
posix: add New(), Shutdown(), and String() methods
This commit is contained in:
@@ -22,6 +22,8 @@ import (
|
||||
)
|
||||
|
||||
type Posix struct {
|
||||
rootfd *os.File
|
||||
rootdir string
|
||||
backend.BackendUnsupported
|
||||
}
|
||||
|
||||
@@ -40,6 +42,28 @@ var (
|
||||
newObjGID = 0
|
||||
)
|
||||
|
||||
func New(rootdir string) (*Posix, error) {
|
||||
err := os.Chdir(rootdir)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("chdir %v: %w", rootdir, err)
|
||||
}
|
||||
|
||||
f, err := os.Open(rootdir)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("open %v: %w", rootdir, err)
|
||||
}
|
||||
|
||||
return &Posix{rootfd: f, rootdir: rootdir}, nil
|
||||
}
|
||||
|
||||
func (p *Posix) Shutdown() {
|
||||
p.rootfd.Close()
|
||||
}
|
||||
|
||||
func (p *Posix) Sring() string {
|
||||
return "Posix Gateway"
|
||||
}
|
||||
|
||||
func (p *Posix) ListBuckets() (*s3.ListBucketsOutput, error) {
|
||||
entries, err := os.ReadDir(".")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user