If the specified file is compressed, return a pipe that * uncompresses it. */
| 187 | * uncompresses it. |
| 188 | */ |
| 189 | int open(const char *path, int flags, mode_t mode) |
| 190 | { |
| 191 | static open_t real_open; |
| 192 | if (real_open == NULL) |
| 193 | real_open = (open_t)dlsym(RTLD_NEXT, "open"); |
| 194 | if (real_open == NULL) { |
| 195 | fprintf(stderr, "error: dlsym open: %s\n", dlerror()); |
| 196 | exit(EXIT_FAILURE); |
| 197 | } |
| 198 | |
| 199 | // open a web address |
| 200 | if (wgetExec(path) != NULL) |
| 201 | return uncompress(path); |
| 202 | |
| 203 | // to check if the file exists, we need to attempt to open it |
| 204 | int filedesc = real_open(path, flags, mode); |
| 205 | if (mode != ios_base::in || filedesc < 0 |
| 206 | || zcatExec(path) == NULL) |
| 207 | return filedesc; |
| 208 | else { |
| 209 | close(filedesc); |
| 210 | return uncompress(path); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | } // extern "C" |
| 215 |
nothing calls this directly
no test coverage detected