MCPcopy Create free account
hub / github.com/F-Stack/f-stack / FIO_fwriteSparseEnd

Function FIO_fwriteSparseEnd

freebsd/contrib/zstd/programs/fileio.c:2002–2017  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2000}
2001
2002static void
2003FIO_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

Callers 5

FIO_passThroughFunction · 0.85
FIO_decompressZstdFrameFunction · 0.85
FIO_decompressGzFrameFunction · 0.85
FIO_decompressLzmaFrameFunction · 0.85
FIO_decompressLz4FrameFunction · 0.85

Calls 1

LONG_SEEKFunction · 0.85

Tested by

no test coverage detected