idun/pkg/storage/localefilesystem.go

44 lines
688 B
Go
Raw Permalink Normal View History

2023-10-12 08:20:53 +00:00
package storage
import (
"io/ioutil"
"os"
)
type LocaleFileSystem struct {
Config map[string]string
}
func (l LocaleFileSystem) ListFiles() ([]File, error) {
files, err := ioutil.ReadDir(l.Config["path"])
if err != nil {
return []File{}, err
}
var filelist []File
for _, file := range files {
g := GeneralFile{
name: l.Config["path"] + "/" + file.Name(),
time: file.ModTime(),
}
filelist = append(filelist, g)
}
return filelist, nil
}
func (I LocaleFileSystem) Delete(files []File) error {
for _, f := range files {
name, err := f.GetName()
if err != nil {
return err
}
err = os.Remove(name)
if err != nil {
return err
}
}
return nil
}