Skip to content

Commit

Permalink
fix(file): fix arguments of pp.Errorf
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Jun 23, 2022
1 parent d1decdf commit 55c5988
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import (
"github.com/favonia/cloudflare-ddns/internal/pp"
)

var FS = os.DirFS("/") //nolint:gochecknoglobals
const LinuxRoot string = "/"

var FS = os.DirFS(LinuxRoot) //nolint:gochecknoglobals

func ReadString(ppfmt pp.PP, path string) (string, bool) {
// os.DirFS(...).Open() does not accept absolute paths
if filepath.IsAbs(path) {
newpath, err := filepath.Rel("/", path)
newpath, err := filepath.Rel(LinuxRoot, path)
if err != nil {
ppfmt.Errorf(pp.EmojiImpossible, `%q is an absolute path but does not start with "/": %v`, err)
ppfmt.Errorf(pp.EmojiImpossible, `%q is an absolute path but does not start with %q: %v`, path, LinuxRoot, err)
return "", false
}
path = newpath
Expand Down

0 comments on commit 55c5988

Please sign in to comment.