| 2333 | |
| 2334 | #ifndef _WIN32 |
| 2335 | static bool sync_parent_directory(const char *path) { |
| 2336 | char directory[CBM_SZ_2K]; |
| 2337 | int written = snprintf(directory, sizeof(directory), "%s", path ? path : ""); |
| 2338 | if (written <= 0 || (size_t)written >= sizeof(directory)) { |
| 2339 | return false; |
| 2340 | } |
| 2341 | char *slash = strrchr(directory, '/'); |
| 2342 | if (!slash) { |
| 2343 | snprintf(directory, sizeof(directory), "."); |
| 2344 | } else if (slash == directory) { |
| 2345 | slash[1] = '\0'; |
| 2346 | } else { |
| 2347 | *slash = '\0'; |
| 2348 | } |
| 2349 | int fd = open(directory, O_RDONLY | O_DIRECTORY); |
| 2350 | if (fd < 0) { |
| 2351 | return false; |
| 2352 | } |
| 2353 | int rc; |
| 2354 | do { |
| 2355 | rc = fsync(fd); |
| 2356 | } while (rc != 0 && errno == EINTR); |
| 2357 | (void)close(fd); |
| 2358 | return rc == 0; |
| 2359 | } |
| 2360 | #endif |
| 2361 | |
| 2362 | /* Publish only a fully closed SQLite snapshot, without ever replacing a prior |
no test coverage detected