datawriter/cmd/shell/main.go

56 lines
1021 B
Go

package main
import (
"fmt"
"os"
"runtime"
"gittea.marcokittel.de/elio/eliotools/logger"
"gittea.marcokittel.de/elio/eliotools/tools"
)
const (
NewDir = "/new"
ProcessedDir = "/processed"
Rights = 0755
StockMustHaveFileLen = 38
)
var filename = "2023-11-09T15:02:17+00:00-CH-stock.csv"
func main() {
x := tools.IsFilenameValid(filename)
ml := logger.NewMarcoLogger()
ml.Info(fmt.Sprint(x))
if runtime.GOOS == "windows" {
ml.Fatal("Einfach nein!")
}
path, _ := os.Getwd()
newDirExists, err := tools.CheckDir(path + NewDir)
if err != nil {
ml.Fatal(err.Error())
}
processedDirExists, err := tools.CheckDir(path + ProcessedDir)
if err != nil {
ml.Fatal(err.Error())
}
if !newDirExists {
err := tools.Createdir(path+NewDir, Rights)
if err == nil {
ml.Infof("%s created.", path+NewDir)
}
}
if !processedDirExists {
err := tools.Createdir(path+ProcessedDir, Rights)
if err == nil {
ml.Infof("%s created.", path+ProcessedDir)
}
}
}