diff --git a/man/mu-extract.1.org b/man/mu-extract.1.org index d7fb759b..5892eca1 100644 --- a/man/mu-extract.1.org +++ b/man/mu-extract.1.org @@ -51,6 +51,11 @@ directory. overwrite existing files with the same name; by default overwriting is not allowed. +** -u,--uncooked +by default, ~mu~ transforms the attachment filenames a bit (such as by replacing +spaces by dashes); with this option, leave that to the minimum for creating +a legal filename in the target directory. + ** --play Try to 'play' (open) the attachment with the default application for the particular file type. On MacOS, this uses the *open* program, on other platforms diff --git a/mu/mu-cmd-extract.cc b/mu/mu-cmd-extract.cc index 80d47192..504330c9 100644 --- a/mu/mu-cmd-extract.cc +++ b/mu/mu-cmd-extract.cc @@ -33,8 +33,12 @@ save_part(const Message::Part& part, size_t idx, const Options& opts) const auto tdir{opts.extract.targetdir}; return tdir.empty() ? tdir : tdir + G_DIR_SEPARATOR_S; }); + + /* 'uncooked' isn't really _raw_; it means only doing some _minimal_ + * cooking */ const auto path{targetdir + - part.cooked_filename().value_or(format("part-%zu", idx))}; + part.cooked_filename(opts.extract.uncooked) + .value_or(format("part-%zu", idx))}; if (auto&& res{part.to_file(path, opts.extract.overwrite)}; !res) return Err(res.error()); diff --git a/mu/mu-options.cc b/mu/mu-options.cc index 99e8efe4..4f8dc752 100644 --- a/mu/mu-options.cc +++ b/mu/mu-options.cc @@ -222,6 +222,8 @@ sub_extract(CLI::App& sub, Options& opts) sub.add_option("message", opts.extract.message, "Path to message file")->required() ->type_name(""); + sub.add_flag("--uncooked,-u", opts.extract.uncooked, + "Avoid massaging extracted file-names"); sub.add_option("filename-rx", opts.extract.filename_rx, "Regular expression for files to save") ->type_name("") diff --git a/mu/mu-options.hh b/mu/mu-options.hh index 79366177..25210fd4 100644 --- a/mu/mu-options.hh +++ b/mu/mu-options.hh @@ -126,6 +126,8 @@ struct Options { bool overwrite; /**< overwrite same-named files */ bool play; /**< try to 'play' attachment */ std::string filename_rx; /**< Filename rx to save */ + bool uncooked{}; /**< Whether to avoid massaging + * output filename */ } extract; /*