1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-13 14:00:25 +00:00
mycorrhiza/hyphae/deprecated.go

36 lines
737 B
Go
Raw Normal View History

2022-06-06 14:41:33 +00:00
package hyphae
import (
"os"
)
// FetchMycomarkupFile tries to read text file of the given hypha. If there is no file, empty string is returned.
//
// TODO: Get rid of this function.
func FetchMycomarkupFile(h Hypha) (string, error) {
switch h := h.(type) {
case *EmptyHypha:
2022-06-11 09:36:45 +00:00
return "", nil
2022-06-06 14:41:33 +00:00
case *MediaHypha:
if !h.HasTextFile() {
return "", nil
}
text, err := os.ReadFile(h.TextFilePath())
if os.IsNotExist(err) {
return "", nil
} else if err != nil {
return "", err
}
return string(text), nil
case *TextualHypha:
text, err := os.ReadFile(h.TextFilePath())
if os.IsNotExist(err) {
return "", nil
} else if err != nil {
return "", err
}
return string(text), nil
}
panic("unreachable")
}