summaryrefslogtreecommitdiff
path: root/sponge.c
Commit message (Collapse)AuthorAgeFilesLines
* sponge: Fix bug in -a mode that doubled original content of fileJoey Hess2019-01-091-1/+1
| | | | | | | | Occurred when the temp file is located on a different filesystem. It seems that append mode was put in on that file open without realizing the consequences of it. Bug has been present since the first -a patch. This commit was sponsored by Peter on Patreon.
* make -a create the file atomicallyJoey Hess2015-01-191-13/+25
| | | | | Ie, copy existing file content to temp file, then append sponged input, then rename over.
* switch to getoptJoey Hess2015-01-191-12/+14
|
* sponge: add append option '-a' (Closes: #623197)Nicolas Schier2015-01-191-2/+10
| | | | | | | | With this patch, option '-a' is introduced to append to the output file instead of doing backup and recreation. Original-by: Michael Stummvoll <michael@stummi.org> Signed-off-by: Nicolas Schier <nicolas@hjem.rpa.no>
* sponge: Check fclose to detect certian short reads. Closes: #704453Joey Hess2013-04-021-2/+8
|
* minorJoey Hess2010-09-131-7/+7
|
* put back optimisation when outputting to stdoutJoey Hess2010-09-131-9/+21
| | | | | | Recent changes made it always write to the tmp file, even if it was just going to send a small quantity of data to stdout. Bring back optimisation to avoid temp file in that case.
* sponge: Ensure that output file permissions are always preserved if it ↵Joey Hess2010-09-131-28/+30
| | | | already exists.
* indentation changeJoey Hess2010-09-131-42/+42
|
* sponge: Guarantee that output file is always updated atomically, by renaming ↵Joey Hess2010-09-131-22/+5
| | | | a temp file into place. Closes: #592144
* sponge: Correct bad use of fread that caused a trailing quantity of soaked ↵Joey Hess2010-09-021-4/+5
| | | | | | | | | data to be silently discarded when a temp file was used and sponge output to stdout. Closes: #595220 This bug was sorta introduced by 6f31909ff74c064ea0b5126219b3e8f7b8826bee. Actually, the buggy fread was there before also, and would have happened on quantities of data not evenly divisible by 8.
* fix mode of new file renamed from temp fileJoey Hess2008-04-111-3/+13
|
* minor changesJoey Hess2008-04-111-5/+7
|
* honor TMPDIRJoey Hess2008-04-111-6/+19
|
* optimize tempfile copyingJoey Hess2008-04-111-7/+5
| | | | Reuse the buffer and copy in chunks that are the full buffer size.
* more fixes to tempfile writebackJoey Hess2008-04-111-21/+33
| | | | | | Avoid overwriting symlinks with the temp file. When renaming the temp file, restore the original file's permissions after.
* set umask before calling mkstempJoey Hess2008-04-111-1/+3
| | | | | | This is a POSIX portability thing. Restore the original umask after.
* fix two bugs writing the output fileJoey Hess2008-04-111-15/+18
| | | | | | | | If the output file doesn't exist, the new code was buggy and did not create it. Also, the rename could fail (ie, /tmp on another filesystem). So if it falls fall back to the manual copy.
* move code into a functionJoey Hess2008-04-111-14/+24
|
* fix edge casesJoey Hess2008-04-111-5/+10
| | | | | | | | | If a file an exact multiple of the max buffer size were sponged, it would fail at the end due to trying to write 0 remaining bytes from the buffer to the temp file. A similar bug occurred if sponge's input was empty. Amazing how such a seemingly simple thing can get so tricky.. Also added check for read error from the temp file, just in case.
* reorder definesJoey Hess2008-04-111-1/+1
|
* set up signal handlers before creating temp fileJoey Hess2008-04-111-3/+6
| | | | Avoids a small race..
* another round of whitespace fixesJoey Hess2008-04-111-54/+55
|
* remove debugBrock Noland2008-04-111-1/+0
| | | | Signed-off-by: Brock Noland <brockn@gmail.com>
* sponge fixesBrock Noland2008-04-111-47/+67
| | | | | | | | | | | *Fixed many bugs relating to renaming of temp file to output file *Doesn't set umask, not sure what correct behavior is *Does not try and delete /tmp/sponge.XXXXXX on exit if there was no temporary file used *Uses temporary file when buffer * 2 is >= mem_available as the buffer will double shortly after this operation *Only traps signals if we are creating a temporary file *Cleaned up error messages Signed-off-by: Brock Noland <brockn@gmail.com>
* better usage messageJoey Hess2008-04-111-1/+1
|
* first pass thru the codeJoey Hess2008-04-101-183/+170
| | | | | Mostly limited to layout consistency changes, but I also moved a block of code into a function, and removed a funky use of enum.
* make sponge use a temp file if the input is largeJoey Hess2008-04-101-21/+232
| | | | patch from Brock Noland
* sponge: Ensure that suspending/resuming doesn't result in partial writes of ↵Joey Hess2008-04-101-10/+8
| | | | the data, by using fwrite() rather than write().
* * spongs: Output to stdout if no file is specified, useful in a pipelinejoeyh2006-09-141-5/+10
| | | | | such as: cvs diff | sponge | patch -R -p0 Closes: #387501
* * Add missing \n to sponge usage. Closes: #383944joeyh2006-08-201-1/+1
|
* * Back to Mithandir's C sponge, now fixed.joeyh2006-03-231-0/+90
|
* releasing version 0.60.6joeyh2006-03-131-91/+0
|
* * Indentation improvements.joeyh2006-03-081-48/+48
|
* * Switch sponge to a C implementation by mithandir.joeyh2006-03-031-0/+91
* Build dep on docbook-xml.