Branch data Line data Source code
1 : : #include "precizer.h"
2 : : #include <errno.h>
3 : :
4 : : /**
5 : : * @brief Classify a filesystem access errno value into FileAccessStatus
6 : : *
7 : : * Maps common filesystem errors to a stable, high-level status:
8 : : * - ENOENT, ENOTDIR -> FILE_NOT_FOUND
9 : : * - EACCES, EPERM -> FILE_ACCESS_DENIED
10 : : * - otherwise -> FILE_ACCESS_ERROR
11 : : *
12 : : * @param err errno value from a failed filesystem path operation
13 : : * @return FileAccessStatus classification
14 : : */
15 : 62 : FileAccessStatus file_access_status(const int err)
16 : : {
17 [ + + - + ]: 62 : if(err == ENOENT || err == ENOTDIR)
18 : : {
19 : 41 : return(FILE_NOT_FOUND);
20 : : }
21 : :
22 [ - + - - ]: 21 : if(err == EACCES || err == EPERM)
23 : : {
24 : 21 : return(FILE_ACCESS_DENIED);
25 : : }
26 : :
27 : 0 : return(FILE_ACCESS_ERROR);
28 : : }
|