From 505b14895e11f1f5b4c91aabf94c247d8e0c7b7c Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 22 Nov 2024 00:57:30 +0800 Subject: [PATCH] Not write to file when dry run [GitHub #76] --- src/framework/core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/framework/core.c b/src/framework/core.c index 580c8b0..fe19d72 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -1092,6 +1092,11 @@ chsrc_ensure_dir (const char *dir) static void chsrc_append_to_file (const char *str, const char *filename) { + if (CliOpt_DryRun) + { + return; + } + char *file = xy_normalize_path (filename); char *dir = xy_parent_dir (file); chsrc_ensure_dir (dir); @@ -1135,6 +1140,11 @@ chsrc_append_to_file (const char *str, const char *filename) static void chsrc_prepend_to_file (const char *str, const char *file) { + if (CliOpt_DryRun) + { + return; + } + file = xy_normalize_path (file); char *dir = xy_parent_dir (file); chsrc_ensure_dir (dir); @@ -1154,6 +1164,11 @@ chsrc_prepend_to_file (const char *str, const char *file) static void chsrc_overwrite_file (const char *str, const char *file) { + if (CliOpt_DryRun) + { + return; + } + file = xy_normalize_path (file); char *dir = xy_parent_dir (file); chsrc_ensure_dir (dir); @@ -1173,6 +1188,11 @@ chsrc_overwrite_file (const char *str, const char *file) static void chsrc_backup (const char *path) { + if (CliOpt_DryRun) + { + return; + } + char *cmd = NULL; bool exist = xy_file_exist (path);