mirror of
https://github.com/RubyMetric/chsrc.git
synced 2025-03-08 19:35:15 +08:00
Add xy_run()
, xy_append_to_file()
and xy_overwrite_file()
This commit is contained in:
parent
31a3004aed
commit
57bf9f86a4
37
xy.h
37
xy.h
@ -3,13 +3,13 @@
|
|||||||
* License : MIT
|
* License : MIT
|
||||||
* Authors : Aoran Zeng <ccmywish@qq.com>
|
* Authors : Aoran Zeng <ccmywish@qq.com>
|
||||||
* Created on : <2023-08-28>
|
* Created on : <2023-08-28>
|
||||||
* Last modified : <2023-09-22>
|
* Last modified : <2023-09-26>
|
||||||
*
|
*
|
||||||
* xy:
|
* xy:
|
||||||
*
|
*
|
||||||
* y = f(x)
|
* y = f(x)
|
||||||
*
|
*
|
||||||
* Corss-Platform C utilities in Ruby flavor
|
* Corss-Platform C utilities for CLI applications in Ruby flavor
|
||||||
*
|
*
|
||||||
* 该文件采用 MIT 许可证,请查阅 LICENSE.txt 文件
|
* 该文件采用 MIT 许可证,请查阅 LICENSE.txt 文件
|
||||||
* ------------------------------------------------------------*/
|
* ------------------------------------------------------------*/
|
||||||
@ -525,4 +525,37 @@ xy_file_exist(char* path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
xy_run (const char* cmd)
|
||||||
|
{
|
||||||
|
char* log = App_Log_Prefix;
|
||||||
|
xy_info (xy_2strjoin (log, cmd));
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
xy_append_to_file (char* str, char* file)
|
||||||
|
{
|
||||||
|
char* cmd = NULL;
|
||||||
|
if (xy_on_windows) {
|
||||||
|
cmd = xy_strjoin (4, "echo ", str, " >> ", file);
|
||||||
|
} else {
|
||||||
|
cmd = xy_strjoin (4, "echo '", str, "' >> ", file);
|
||||||
|
}
|
||||||
|
xy_run(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xy_overwrite_file (char* str, char* file)
|
||||||
|
{
|
||||||
|
char* cmd = NULL;
|
||||||
|
if (xy_on_windows) {
|
||||||
|
cmd = xy_strjoin (4, "echo ", str, " > ", file);
|
||||||
|
} else {
|
||||||
|
cmd = xy_strjoin (4, "echo '", str, "' > ", file);
|
||||||
|
}
|
||||||
|
xy_run(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user