Debian Codegraph @

in_toto/util_windows.go

raw
1 package in_toto
2
3 import (
4 "errors"
5 "os"
6 )
7
8 func isWritable(path string) error {
9 // get fileInfo
10 info, err := os.Stat(path)
11 if err != nil {
12 return err
13 }
14
15 // check if path is a directory
16 if !info.IsDir() {
17 return errors.New("not a directory")
18 }
19
20 // Check if the user bit is enabled in file permission
21 if info.Mode().Perm()&(1<<(uint(7))) == 0 {
22 return errors.New("not writable")
23 }
24 return nil
25 }