X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fsync%2Ffiletest%2Ffiletest.go;h=370ca10edfa4744aa41318397cf7af56782c51ec;hb=6d78cccd689fd81a08851b95a03fea608f497e16;hp=6a594e6ac37b13b0d77c87048ab0e86243293bbd;hpb=583a2695a3ddc9c98e0a03d9f1bad8df30afe887;p=safcm%2Fsafcm.git diff --git a/cmd/safcm-remote/sync/filetest/filetest.go b/cmd/safcm-remote/sync/filetest/filetest.go index 6a594e6..370ca10 100644 --- a/cmd/safcm-remote/sync/filetest/filetest.go +++ b/cmd/safcm-remote/sync/filetest/filetest.go @@ -34,7 +34,9 @@ type File struct { func WalkDir(basePath string) ([]File, error) { var res []File - err := filepath.WalkDir(basePath, func(path string, d fs.DirEntry, err error) error { + err := filepath.WalkDir(basePath, func(path string, + d fs.DirEntry, err error) error { + if err != nil { return err } @@ -95,7 +97,7 @@ func CurrentUserAndGroup() (string, int, string, int) { } func CreateFile(path string, data string, mode fs.FileMode) { - err := os.WriteFile(path, []byte(data), 0644) + err := os.WriteFile(path, []byte(data), 0600) if err != nil { panic(err) } @@ -123,6 +125,17 @@ func CreateDirectory(path string, mode fs.FileMode) { } } +func CreateDirectoryExists(path string, mode fs.FileMode) { + err := os.Mkdir(path, 0700) + if err != nil && !os.IsExist(err) { + panic(err) + } + err = os.Chmod(path, mode) + if err != nil { + panic(err) + } +} + func CreateFifo(path string, mode fs.FileMode) { err := syscall.Mkfifo(path, 0600) if err != nil {