]> git.seodisparate.com - SimpleArchiver/commit
Fix/refactor created temp file when compressing
authorStephen Seo <seo.disparate@gmail.com>
Fri, 21 Feb 2025 07:26:32 +0000 (16:26 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 21 Feb 2025 07:30:40 +0000 (16:30 +0900)
commit64f2294d1e6353369893da97a00ae9634e910c55
tree95e3fdd824dd84d420647198f7f4f33f5f298298
parent263920876075cb8b26c81fc5456c2d8c23ce2576
Fix/refactor created temp file when compressing

Before this commit, archived files using compression would use a
temporary file in the current-working-directory (usually the same
directory specified by "-C <dir>") to store compressed files. This is
required by design as the file-size of the compressed file/chunk is
required before storing the data. In other words, the size is stored
before the data without seeking so that output can be streamable (in
case of "-f -" or "-f /dev/stdout" when compressing).

This commit changes the behavior of creating temporary files for
compression by placing them in the same directory as the output file
(specified by "-f <output_file>"), or using "tmpfile()" if that should
fail. Note that the `--temp-files-dir <dir>` option exists, and
"tmpfile()" is used as a fallback in case writing to
`--temp-files-dir <dir>` fails.
src/archiver.c
src/helpers.c
src/helpers.h
src/parser.c
src/parser.h