| 251 | } |
| 252 | |
| 253 | void throwError() |
| 254 | { |
| 255 | auto message = |
| 256 | fmt::format("HFS error: {}", hfs_error ? hfs_error : "unknown"); |
| 257 | switch (errno) |
| 258 | { |
| 259 | case ENOTDIR: |
| 260 | case ENAMETOOLONG: |
| 261 | if (hfs_error) |
| 262 | throw BadPathException(message); |
| 263 | else |
| 264 | throw BadPathException(); |
| 265 | |
| 266 | case ENOENT: |
| 267 | if (hfs_error) |
| 268 | throw FileNotFoundException(message); |
| 269 | else |
| 270 | throw FileNotFoundException(); |
| 271 | |
| 272 | case EEXIST: |
| 273 | throw BadPathException("That already exists"); |
| 274 | |
| 275 | case ENOTEMPTY: |
| 276 | throw BadPathException("Directory is not empty"); |
| 277 | |
| 278 | case EISDIR: |
| 279 | throw BadPathException("That's a directory"); |
| 280 | |
| 281 | case EIO: |
| 282 | case EINVAL: |
| 283 | if (hfs_error) |
| 284 | throw BadFilesystemException(message); |
| 285 | else |
| 286 | throw BadFilesystemException(); |
| 287 | |
| 288 | case ENOSPC: |
| 289 | case ENOMEM: |
| 290 | if (hfs_error) |
| 291 | throw DiskFullException(message); |
| 292 | else |
| 293 | throw DiskFullException(); |
| 294 | |
| 295 | case EROFS: |
| 296 | if (hfs_error) |
| 297 | throw ReadOnlyFilesystemException(message); |
| 298 | else |
| 299 | throw ReadOnlyFilesystemException(); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | private: |
| 304 | Bytes readBytes(hfsfile* file) |
nothing calls this directly
no test coverage detected