- * <WIM> element not the <IMAGE> element, is the size of the WIM file
- * excluding the XML data and integrity table. Which is the current
- * offset, since the XML data goes at the end of the WIM file before the
- * integrity table. */
- total_bytes = ftello(out);
- if (total_bytes == -1)
- return WIMLIB_ERR_WRITE;
+ * <WIM> element not the <IMAGE> element, is (for non-spit WIMs) the
+ * size of the WIM file excluding the XML data and integrity table,
+ * which is the current offset, since the XML data goes at the end of
+ * the WIM file before the integrity table. */
+ if (total_bytes == 0) {
+ total_bytes = ftello(out);
+ if (total_bytes == (u64)-1)
+ return WIMLIB_ERR_WRITE;
+ }