From f86d4f1992cfdab602aae644a4ff5fee3fa6707f Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Fri, 17 Nov 2000 18:17:04 +0000 Subject: [PATCH] Don't compress write protected files unless we make a backup. committer: mfx 974485024 +0000 --- src/work.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/work.cpp b/src/work.cpp index ccfed7c2..33fef897 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -75,6 +75,17 @@ void do_one_file(const char *iname, char *oname) #endif if (st.st_size <= 0) throwIOException("empty file -- skipped"); + if ((st.st_mode & S_IWUSR) == 0) + { + if (opt->output_name) + nop; + else if (opt->to_stdout) + nop; + else if (opt->backup) + nop; + else + throwIOException("file is write protected -- skipped"); + } InputFile fi; fi.st = st;