-
-
Save andrestc/a0d290ac7200c51760792334caaffe1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i, holes = 0; | |
while ((numRead = read(inputFd, buf, BUF_SIZE)) > 0) | |
{ | |
if (keepHoles == 1) { | |
for (i = 0; i < numRead; i++) { | |
if (buf[i] == '\0') { | |
holes++; | |
continue; | |
} else if (holes > 0) { | |
lseek(outputFd, holes, SEEK_CUR); | |
holes = 0; | |
} | |
if (write(outputFd, &buf[i], 1) != 1) | |
fatal("couldnt write char to file"); | |
} | |
} else { | |
if (write(outputFd, buf, numRead) != numRead) | |
fatal("couldn't write whole buffer to file"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment