add stat for file existant checks
This commit is contained in:
parent
5dbd59fe8f
commit
367f0c978e
@ -2,6 +2,7 @@ package photosapi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
@ -24,7 +25,7 @@ func (s *Storage) Create(paths ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) Exists(paths ...string) bool {
|
func (s *Storage) Exists(paths ...string) bool {
|
||||||
f, err := os.Stat(s.Join(paths...))
|
f, err := s.Stat(paths...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -38,3 +39,7 @@ func (s *Storage) Delete(paths ...string) error {
|
|||||||
return fmt.Errorf("%s doesn't exists", s.Join(paths...))
|
return fmt.Errorf("%s doesn't exists", s.Join(paths...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Storage) Stat(paths ...string) (fs.FileInfo, error) {
|
||||||
|
return os.Stat(s.Join(paths...))
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user