43 lines
688 B
Go
43 lines
688 B
Go
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
|
|
}
|