This commit is contained in:
Daniel Goc
2026-04-01 13:30:54 +02:00
parent 684f910090
commit b2acb8c922
14 changed files with 326 additions and 15 deletions

View File

@@ -0,0 +1,51 @@
package storageRepo
import (
"os"
"git.ma-al.com/goc_daniel/b2b/app/model"
)
type UIStorageRepo interface {
EntryInfo(absPath string) (os.FileInfo, error)
ListContent(absPath string) (*[]model.EntryInList, error)
OpenFile(absPath string) (*os.File, error)
CreateFolder(absPath string, name string) error
}
type StorageRepo struct{}
func New() UIStorageRepo {
return &StorageRepo{}
}
func (r *StorageRepo) EntryInfo(absPath string) (os.FileInfo, error) {
return os.Stat(absPath)
}
func (r *StorageRepo) ListContent(absPath string) (*[]model.EntryInList, error) {
entries, err := os.ReadDir(absPath)
if err != nil {
return nil, err
}
var entries_in_list []model.EntryInList
for _, entry := range entries {
var next_entry_in_list model.EntryInList
next_entry_in_list.Name = entry.Name()
next_entry_in_list.IsFolder = entry.IsDir()
entries_in_list = append(entries_in_list, next_entry_in_list)
}
return &entries_in_list, nil
}
func (r *StorageRepo) OpenFile(absPath string) (*os.File, error) {
return os.Open(absPath)
}
func (r *StorageRepo) CreateFolder(absPath string, name string) error {
os.(absPath)
}