mirror of
https://github.com/RubyMetric/chsrc.git
synced 2024-11-23 01:55:35 +08:00
Add prepend
This commit is contained in:
parent
4e58bd6260
commit
069f5fb827
|
@ -7,7 +7,7 @@
|
||||||
* Contributors : Null Nil <null@nil.com>
|
* Contributors : Null Nil <null@nil.com>
|
||||||
* |
|
* |
|
||||||
* Created on : <2023-08-29>
|
* Created on : <2023-08-29>
|
||||||
* Last modified : <2024-06-24>
|
* Last modified : <2024-07-03>
|
||||||
*
|
*
|
||||||
* chsrc 头文件
|
* chsrc 头文件
|
||||||
* ------------------------------------------------------------*/
|
* ------------------------------------------------------------*/
|
||||||
|
@ -666,6 +666,25 @@ chsrc_append_to_file (const char *str, const char *file)
|
||||||
chsrc_run (cmd, RunOpt_Default);
|
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
|
static void
|
||||||
chsrc_overwrite_file (const char *str, const char *file)
|
chsrc_overwrite_file (const char *str, const char *file)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user