- // Give the file a proper name, making it visible in the file system.
- // TODO: It would be nice to be able to do this atomically, like with rename.
- unlink(outfile.c_str());
- char procpath[256];
- snprintf(procpath, sizeof(procpath), "/proc/self/fd/%d", fileno(outfp));
- if (linkat(AT_FDCWD, procpath, AT_FDCWD, outfile.c_str(), AT_SYMLINK_FOLLOW) == -1) {
- perror("linkat");
- exit(1);
- }
-#else
- if (rename(temp_filename.c_str(), outfile.c_str()) == -1) {
- perror("rename");
- exit(1);
- }
+ // Give the file a proper name, making it visible in the file system.
+ // TODO: It would be nice to be able to do this atomically, like with rename.
+ unlink(outfile.c_str());
+ char procpath[256];
+ snprintf(procpath, sizeof(procpath), "/proc/self/fd/%d", fileno(outfp));
+ if (linkat(AT_FDCWD, procpath, AT_FDCWD, outfile.c_str(), AT_SYMLINK_FOLLOW) == -1) {
+ perror("linkat");
+ exit(1);
+ }