client io architecture

This commit is contained in:
Ilia Denisov
2026-03-12 18:45:46 +02:00
committed by GitHub
parent 2dafa69b93
commit 079b9facb0
36 changed files with 1810 additions and 460 deletions
+23
View File
@@ -1,6 +1,7 @@
package util
import (
"fmt"
"os"
"testing"
)
@@ -17,3 +18,25 @@ func CreateWorkDir(t *testing.T) (string, func()) {
}
}
}
func DirExists(path string) (bool, error) {
return PathExists(path, true)
}
func FileExists(path string) (bool, error) {
return PathExists(path, false)
}
func PathExists(path string, isDir bool) (bool, error) {
if fi, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
} else {
if isDir != fi.IsDir() {
return false, fmt.Errorf("wrong type: "+path+" mode=%s isDir=%t", fi.Mode(), isDir)
}
return true, nil
}
}