| 125 | } |
| 126 | |
| 127 | int AP_Filesystem::open(const char *fname, int flags, bool allow_absolute_paths) |
| 128 | { |
| 129 | const Backend &backend = backend_by_path(fname); |
| 130 | int fd = backend.fs.open(fname, flags, allow_absolute_paths); |
| 131 | if (fd < 0) { |
| 132 | return -1; |
| 133 | } |
| 134 | if (uint32_t(fd) >= MAX_FD_PER_BACKEND) { |
| 135 | backend.fs.close(fd); |
| 136 | errno = ERANGE; |
| 137 | return -1; |
| 138 | } |
| 139 | // offset fd so we can recognise the backend |
| 140 | const uint8_t idx = (&backend - &backends[0]); |
| 141 | fd += idx * MAX_FD_PER_BACKEND; |
| 142 | return fd; |
| 143 | } |
| 144 | |
| 145 | int AP_Filesystem::close(int fd) |
| 146 | { |
no test coverage detected