Add prepend

This commit is contained in:
Aoran Zeng 2024-07-03 13:59:06 +08:00
parent 4e58bd6260
commit 069f5fb827

View File

@ -7,7 +7,7 @@
* Contributors : Null Nil <null@nil.com>
* |
* Created on : <2023-08-29>
* Last modified : <2024-06-24>
* Last modified : <2024-07-03>
*
* chsrc
* ------------------------------------------------------------*/
@ -666,6 +666,25 @@ chsrc_append_to_file (const char *str, const char *file)
chsrc_run (cmd, RunOpt_Default);
}
static void
chsrc_prepend_to_file (const char *str, const char *file)
{
file = xy_uniform_path (file);
char *dir = xy_parent_dir (file);
chsrc_ensure_dir (dir);
char *cmd = NULL;
if (xy_on_windows)
{
xy_unimplement;
}
else
{
cmd = xy_strjoin (4, "sed -i '1i ", str, "'", file);
}
chsrc_run (cmd, RunOpt_Default);
}
static void
chsrc_overwrite_file (const char *str, const char *file)
{