isDirWritable checks if the specified directory exists and is writable by attempting to create and remove a test file.
(dir string)
| 117 | |
| 118 | // isDirWritable checks if the specified directory exists and is writable by attempting to create and remove a test file. |
| 119 | func isDirWritable(dir string) bool { |
| 120 | info, err := os.Stat(dir) |
| 121 | if err != nil || !info.IsDir() { |
| 122 | return false |
| 123 | } |
| 124 | |
| 125 | testFile := filepath.Join(dir, ".perm_test") |
| 126 | f, err := os.Create(testFile) |
| 127 | if err != nil { |
| 128 | return false |
| 129 | } |
| 130 | |
| 131 | defer func() { |
| 132 | _ = f.Close() |
| 133 | _ = os.Remove(testFile) |
| 134 | }() |
| 135 | return true |
| 136 | } |
| 137 | |
| 138 | // ResolveLogDirectory determines the directory used for application logs. |
| 139 | func ResolveLogDirectory(cfg *config.Config) string { |
no test coverage detected