aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/osutil
diff options
context:
space:
mode:
authorNazime Hande Harputluoglu <handeharputlu@google.com>2020-10-01 21:53:57 +0000
committerAndrey Konovalov <andreyknvl@gmail.com>2020-10-02 22:00:33 +0200
commit5910646c6c6fbb5e48801342677bff9c4609a2ea (patch)
treeb6f4779d08ce53f9c7e046054ad7c2c78890a652 /pkg/osutil
parent4969d6ca0dd952b9193c3546571a4e19a3b86718 (diff)
sys/linux: descriptions for USB/IP
Diffstat (limited to 'pkg/osutil')
-rw-r--r--pkg/osutil/osutil.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go
index b50b6e45b..5a7a342b1 100644
--- a/pkg/osutil/osutil.go
+++ b/pkg/osutil/osutil.go
@@ -127,6 +127,16 @@ func IsAccessible(name string) error {
return nil
}
+// IsWritable checks if the file can be written.
+func IsWritable(name string) error {
+ f, err := os.OpenFile(name, os.O_WRONLY, DefaultFilePerm)
+ if err != nil {
+ return fmt.Errorf("%v can't be written (%v)", name, err)
+ }
+ f.Close()
+ return nil
+}
+
// FilesExist returns true if all files exist in dir.
// Files are assumed to be relative names in slash notation.
func FilesExist(dir string, files map[string]bool) bool {