mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-09-16 15:56:08 -04:00
gzip, gunzip: warning rather than error when output file already exists
This matches the behavior of GNU gzip.
This commit is contained in:
parent
618958f4dd
commit
e4029d1e70
@ -234,6 +234,8 @@ xopen_for_read(const tchar *path, struct file_stream *strm)
|
|||||||
int
|
int
|
||||||
xopen_for_write(const tchar *path, bool overwrite, struct file_stream *strm)
|
xopen_for_write(const tchar *path, bool overwrite, struct file_stream *strm)
|
||||||
{
|
{
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
strm->mmap_mem = NULL;
|
strm->mmap_mem = NULL;
|
||||||
|
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
@ -263,6 +265,7 @@ retry:
|
|||||||
if (!isatty(STDERR_FILENO) || !isatty(STDIN_FILENO)) {
|
if (!isatty(STDERR_FILENO) || !isatty(STDIN_FILENO)) {
|
||||||
msg("%"TS" already exists; use -f to overwrite",
|
msg("%"TS" already exists; use -f to overwrite",
|
||||||
strm->name);
|
strm->name);
|
||||||
|
ret = -2; /* warning only */
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%"TS": %"TS" already exists; "
|
fprintf(stderr, "%"TS": %"TS" already exists; "
|
||||||
@ -284,7 +287,7 @@ retry:
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
free(strm->name);
|
free(strm->name);
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map the contents of a file into memory */
|
/* Map the contents of a file into memory */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user