open opens a file in the configuration directory, creating all intermediate directories.
(path string, flag int, mode os.FileMode)
| 107 | // open opens a file in the configuration directory, |
| 108 | // creating all intermediate directories. |
| 109 | func open(path string, flag int, mode os.FileMode) (*os.File, error) { |
| 110 | err := os.MkdirAll(filepath.Dir(path), 0o750) |
| 111 | if err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | |
| 115 | return os.OpenFile(path, flag, mode) |
| 116 | } |
| 117 | |
| 118 | func write(path string, mode os.FileMode, dat []byte) error { |
| 119 | fi, err := open(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, mode) |