(write_path string)
| 121 | } |
| 122 | |
| 123 | func checkFile(write_path string) error { |
| 124 | dirname := filepath.Dir(write_path) |
| 125 | st, err := os.Lstat(dirname) |
| 126 | if err != nil { |
| 127 | if os.IsNotExist(err) { |
| 128 | return fmt.Errorf("Directory %v does not exist", dirname) |
| 129 | } |
| 130 | if os.IsPermission(err) { |
| 131 | return fmt.Errorf("Directory %v is not accessibile: %w", |
| 132 | dirname, err) |
| 133 | } |
| 134 | |
| 135 | return fmt.Errorf("Directory %v is not valid", dirname) |
| 136 | } |
| 137 | |
| 138 | if !st.IsDir() { |
| 139 | return fmt.Errorf("Directory %v is not a valid directory", dirname) |
| 140 | } |
| 141 | |
| 142 | st, err = os.Lstat(write_path) |
| 143 | if err != nil { |
| 144 | if os.IsNotExist(err) { |
| 145 | return fileDoesNotExist |
| 146 | } |
| 147 | |
| 148 | if os.IsPermission(err) { |
| 149 | return fmt.Errorf("Unable to create file: %w", err) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if st.IsDir() { |
| 154 | return fmt.Errorf("Path %v is a directory", write_path) |
| 155 | } |
| 156 | |
| 157 | return nil |
| 158 | } |
no test coverage detected