Imported Upstream version 1.0.1

This commit is contained in:
Sébastien Delafond
2017-07-04 14:45:08 +02:00
parent 056c3d6dad
commit c926f2bf05
5531 changed files with 1834599 additions and 742844 deletions
+24
View File
@@ -0,0 +1,24 @@
// Package utils collects various services: simple operations, compression, etc.
package utils
import (
"fmt"
"os"
"golang.org/x/sys/unix"
)
// DirIsAccessible verifies that directory exists and is accessible
func DirIsAccessible(filename string) error {
_, err := os.Stat(filename)
if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("Something went wrong, %v", err)
}
} else {
if unix.Access(filename, unix.W_OK) != nil {
return fmt.Errorf("'%s' is inaccessible, check access rights", filename)
}
}
return nil
}