- DEBUG("Closing output file.");
- wimlib_assert(w->out_fp != NULL);
- if (fclose(w->out_fp) != 0) {
+ if (write_flags & WIMLIB_WRITE_FLAG_FSYNC) {
+ DEBUG("fsync output WIM file");
+ if (fflush(out) != 0
+ || fsync(fileno(out)) != 0)
+ {
+ ERROR_WITH_ERRNO("Error flushing data to WIM file");
+ ret = WIMLIB_ERR_WRITE;
+ }
+ }
+
+ DEBUG("Closing output WIM file.");
+
+ if (fclose(out) != 0) {