Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Feb 27, 2023
1 parent d25020e commit c8cc742
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions filesystem/fllesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (this *Fllesystem) Has(path string) bool {
return false
}

return this.GetAdapter().Has(path)
return this.adapter.Has(path)
}

// 写入文件
Expand All @@ -92,7 +92,7 @@ func (this *Fllesystem) Write(path string, contents string, conf ...map[string]a

configs := this.PrepareConfig(newConf)

if _, err := this.GetAdapter().Write(path, contents, configs); err != nil {
if _, err := this.adapter.Write(path, contents, configs); err != nil {
return false, err
}

Expand All @@ -110,7 +110,7 @@ func (this *Fllesystem) WriteStream(path string, resource io.Reader, conf ...map

configs := this.PrepareConfig(newConf)

if _, err := this.GetAdapter().WriteStream(path, resource, configs); err != nil {
if _, err := this.adapter.WriteStream(path, resource, configs); err != nil {
return false, err
}

Expand All @@ -129,14 +129,14 @@ func (this *Fllesystem) Put(path string, contents string, conf ...map[string]any
configs := this.PrepareConfig(newConf)

if this.Has(path) {
if _, err := this.GetAdapter().Update(path, contents, configs); err != nil {
if _, err := this.adapter.Update(path, contents, configs); err != nil {
return false, err
}

return true, nil
}

if _, err := this.GetAdapter().Write(path, contents, configs); err != nil {
if _, err := this.adapter.Write(path, contents, configs); err != nil {
return false, err
}

Expand All @@ -155,14 +155,14 @@ func (this *Fllesystem) PutStream(path string, resource io.Reader, conf ...map[s
configs := this.PrepareConfig(newConf)

if this.Has(path) {
if _, err := this.GetAdapter().UpdateStream(path, resource, configs); err != nil {
if _, err := this.adapter.UpdateStream(path, resource, configs); err != nil {
return false, err
}

return true, nil
}

if _, err := this.GetAdapter().WriteStream(path, resource, configs); err != nil {
if _, err := this.adapter.WriteStream(path, resource, configs); err != nil {
return false, err
}

Expand Down Expand Up @@ -194,7 +194,7 @@ func (this *Fllesystem) Update(path string, contents string, conf ...map[string]

configs := this.PrepareConfig(newConf)

if _, err := this.GetAdapter().Update(path, contents, configs); err != nil {
if _, err := this.adapter.Update(path, contents, configs); err != nil {
return false, err
}

Expand All @@ -212,7 +212,7 @@ func (this *Fllesystem) UpdateStream(path string, resource io.Reader, conf ...ma

configs := this.PrepareConfig(newConf)

if _, err := this.GetAdapter().WriteStream(path, resource, configs); err != nil {
if _, err := this.adapter.WriteStream(path, resource, configs); err != nil {
return false, err
}

Expand All @@ -222,7 +222,7 @@ func (this *Fllesystem) UpdateStream(path string, resource io.Reader, conf ...ma
// 文件到字符
func (this *Fllesystem) Read(path string) (string, error) {
path = util.NormalizePath(path)
object, err := this.GetAdapter().Read(path)
object, err := this.adapter.Read(path)

if err != nil {
return "", err
Expand All @@ -234,7 +234,7 @@ func (this *Fllesystem) Read(path string) (string, error) {
// 读取成数据流
func (this *Fllesystem) ReadStream(path string) (*os.File, error) {
path = util.NormalizePath(path)
object, err := this.GetAdapter().ReadStream(path)
object, err := this.adapter.ReadStream(path)

if err != nil {
return nil, err
Expand All @@ -248,7 +248,7 @@ func (this *Fllesystem) Rename(path string, newpath string) (bool, error) {
path = util.NormalizePath(path)
newpath = util.NormalizePath(newpath)

if err := this.GetAdapter().Rename(path, newpath); err != nil {
if err := this.adapter.Rename(path, newpath); err != nil {
return false, err
}

Expand All @@ -260,7 +260,7 @@ func (this *Fllesystem) Copy(path string, newpath string) (bool, error) {
path = util.NormalizePath(path)
newpath = util.NormalizePath(newpath)

if err := this.GetAdapter().Copy(path, newpath); err != nil {
if err := this.adapter.Copy(path, newpath); err != nil {
return false, err
}

Expand All @@ -271,7 +271,7 @@ func (this *Fllesystem) Copy(path string, newpath string) (bool, error) {
func (this *Fllesystem) Delete(path string) (bool, error) {
path = util.NormalizePath(path)

if err := this.GetAdapter().Delete(path); err != nil {
if err := this.adapter.Delete(path); err != nil {
return false, err
}

Expand All @@ -285,7 +285,7 @@ func (this *Fllesystem) DeleteDir(dirname string) (bool, error) {
return false, errors.New("文件夹路径错误")
}

if err := this.GetAdapter().DeleteDir(dirname); err != nil {
if err := this.adapter.DeleteDir(dirname); err != nil {
return false, err
}

Expand All @@ -303,7 +303,7 @@ func (this *Fllesystem) CreateDir(dirname string, conf ...map[string]any) (bool,

configs := this.PrepareConfig(newConf)

if _, err := this.GetAdapter().CreateDir(dirname, configs); err != nil {
if _, err := this.adapter.CreateDir(dirname, configs); err != nil {
return false, err
}

Expand All @@ -314,7 +314,7 @@ func (this *Fllesystem) CreateDir(dirname string, conf ...map[string]any) (bool,
func (this *Fllesystem) ListContents(dirname string, recursive ...bool) ([]map[string]any, error) {
dirname = util.NormalizePath(dirname)

result, err := this.GetAdapter().ListContents(dirname, recursive...)
result, err := this.adapter.ListContents(dirname, recursive...)
if err != nil {
return nil, err
}
Expand All @@ -325,7 +325,7 @@ func (this *Fllesystem) ListContents(dirname string, recursive ...bool) ([]map[s
// 类型
func (this *Fllesystem) GetMimetype(path string) (string, error) {
path = util.NormalizePath(path)
object, err := this.GetAdapter().GetMimetype(path)
object, err := this.adapter.GetMimetype(path)

if err != nil {
return "", err
Expand All @@ -337,7 +337,7 @@ func (this *Fllesystem) GetMimetype(path string) (string, error) {
// 时间戳
func (this *Fllesystem) GetTimestamp(path string) (int64, error) {
path = util.NormalizePath(path)
object, err := this.GetAdapter().GetTimestamp(path)
object, err := this.adapter.GetTimestamp(path)

if err != nil {
return 0, err
Expand All @@ -349,7 +349,7 @@ func (this *Fllesystem) GetTimestamp(path string) (int64, error) {
// 权限
func (this *Fllesystem) GetVisibility(path string) (string, error) {
path = util.NormalizePath(path)
object, err := this.GetAdapter().GetVisibility(path)
object, err := this.adapter.GetVisibility(path)

if err != nil {
return "", err
Expand All @@ -361,7 +361,7 @@ func (this *Fllesystem) GetVisibility(path string) (string, error) {
// 大小
func (this *Fllesystem) GetSize(path string) (int64, error) {
path = util.NormalizePath(path)
object, err := this.GetAdapter().GetSize(path)
object, err := this.adapter.GetSize(path)

if err != nil {
return 0, err
Expand All @@ -374,7 +374,7 @@ func (this *Fllesystem) GetSize(path string) (int64, error) {
func (this *Fllesystem) SetVisibility(path string, visibility string) (bool, error) {
path = util.NormalizePath(path)

if _, err := this.GetAdapter().SetVisibility(path, visibility); err != nil {
if _, err := this.adapter.SetVisibility(path, visibility); err != nil {
return false, err
}

Expand All @@ -385,7 +385,7 @@ func (this *Fllesystem) SetVisibility(path string, visibility string) (bool, err
func (this *Fllesystem) GetMetadata(path string) (map[string]any, error) {
path = util.NormalizePath(path)

if info, err := this.GetAdapter().GetMetadata(path); err != nil {
if info, err := this.adapter.GetMetadata(path); err != nil {
return nil, err
} else {
return info, nil
Expand Down

0 comments on commit c8cc742

Please sign in to comment.