mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-10-20 10:57:09 +00:00
Refactor
This commit is contained in:
1 parent
970b1a424a
commit
4456f8da57
4 files changed
+27
-22
No files matched your search
@@ -1,2 +1,23 @@
|
||||
// Package utils collects various services: simple operations, compression, etc.
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// check if 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
|
||||
}
|
||||
Reference in new issue
Block a user