| 2000 | } |
| 2001 | |
| 2002 | static void |
| 2003 | FIO_fwriteSparseEnd(const FIO_prefs_t* const prefs, FILE* file, unsigned storedSkips) |
| 2004 | { |
| 2005 | if (prefs->testMode) assert(storedSkips == 0); |
| 2006 | if (storedSkips>0) { |
| 2007 | assert(prefs->sparseFileSupport > 0); /* storedSkips>0 implies sparse support is enabled */ |
| 2008 | (void)prefs; /* assert can be disabled, in which case prefs becomes unused */ |
| 2009 | if (LONG_SEEK(file, storedSkips-1, SEEK_CUR) != 0) |
| 2010 | EXM_THROW(69, "Final skip error (sparse file support)"); |
| 2011 | /* last zero must be explicitly written, |
| 2012 | * so that skipped ones get implicitly translated as zero by FS */ |
| 2013 | { const char lastZeroByte[1] = { 0 }; |
| 2014 | if (fwrite(lastZeroByte, 1, 1, file) != 1) |
| 2015 | EXM_THROW(69, "Write error : cannot write last zero : %s", strerror(errno)); |
| 2016 | } } |
| 2017 | } |
| 2018 | |
| 2019 | |
| 2020 | /** FIO_passThrough() : just copy input into output, for compatibility with gzip -df mode |
no test coverage detected