mirror of
https://github.com/RubyMetric/chsrc.git
synced 2024-11-25 16:22:38 +08:00
Rename xy function
This commit is contained in:
parent
5d7a13a56b
commit
d7cc74c494
10
include/xy.h
10
include/xy.h
@ -8,7 +8,7 @@
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* |
|
||||
* Created On : <2023-08-28>
|
||||
* Last Modified : <2024-08-23>
|
||||
* Last Modified : <2024-11-21>
|
||||
*
|
||||
* xy: 襄阳、咸阳
|
||||
* Corss-Platform C utilities for CLI applications in Ruby flavor
|
||||
@ -17,7 +17,7 @@
|
||||
#ifndef XY_H
|
||||
#define XY_H
|
||||
|
||||
#define _XY_Version "v0.1.4.2-2024/08/23"
|
||||
#define _XY_Version "v0.1.4.3-2024/11/21"
|
||||
#define _XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/include/xy.h"
|
||||
|
||||
#include <assert.h>
|
||||
@ -683,7 +683,7 @@ xy_file_exist (const char *path)
|
||||
|
||||
/**
|
||||
* @note xy_file_exist() 和 xy_dir_exist() 两个函数在所有平台默认都支持使用 '~',
|
||||
* 但实现中都没有调用 xy_uniform_path(),以防万一,调用前可能需要用户手动调用它
|
||||
* 但实现中都没有调用 xy_normalize_path(),以防万一,调用前可能需要用户手动调用它
|
||||
*/
|
||||
static bool
|
||||
xy_dir_exist (const char *path)
|
||||
@ -733,7 +733,7 @@ xy_dir_exist (const char *path)
|
||||
* 该函数即使在非Windows下也可调用,作用是删除路径左右两边多出来的空白符
|
||||
*/
|
||||
static char *
|
||||
xy_uniform_path (const char *path)
|
||||
xy_normalize_path (const char *path)
|
||||
{
|
||||
char *new = xy_str_strip (path); // 防止开发者多写了空白符
|
||||
|
||||
@ -755,7 +755,7 @@ xy_uniform_path (const char *path)
|
||||
static char *
|
||||
xy_parent_dir (const char *path)
|
||||
{
|
||||
char *dir = xy_uniform_path (path);
|
||||
char *dir = xy_normalize_path (path);
|
||||
char *last = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
|
@ -1039,7 +1039,7 @@ static void
|
||||
chsrc_view_file (const char *path)
|
||||
{
|
||||
char *cmd = NULL;
|
||||
path = xy_uniform_path (path);
|
||||
path = xy_normalize_path (path);
|
||||
if (xy_on_windows)
|
||||
{
|
||||
cmd = xy_2strjoin ("type ", path);
|
||||
@ -1054,7 +1054,7 @@ chsrc_view_file (const char *path)
|
||||
static void
|
||||
chsrc_ensure_dir (const char *dir)
|
||||
{
|
||||
dir = xy_uniform_path (dir);
|
||||
dir = xy_normalize_path (dir);
|
||||
|
||||
if (xy_dir_exist (dir))
|
||||
{
|
||||
@ -1081,7 +1081,7 @@ chsrc_ensure_dir (const char *dir)
|
||||
static void
|
||||
chsrc_append_to_file (const char *str, const char *file)
|
||||
{
|
||||
file = xy_uniform_path (file);
|
||||
file = xy_normalize_path (file);
|
||||
char *dir = xy_parent_dir (file);
|
||||
chsrc_ensure_dir (dir);
|
||||
|
||||
@ -1100,7 +1100,7 @@ chsrc_append_to_file (const char *str, const char *file)
|
||||
static void
|
||||
chsrc_prepend_to_file (const char *str, const char *file)
|
||||
{
|
||||
file = xy_uniform_path (file);
|
||||
file = xy_normalize_path (file);
|
||||
char *dir = xy_parent_dir (file);
|
||||
chsrc_ensure_dir (dir);
|
||||
|
||||
@ -1119,7 +1119,7 @@ chsrc_prepend_to_file (const char *str, const char *file)
|
||||
static void
|
||||
chsrc_overwrite_file (const char *str, const char *file)
|
||||
{
|
||||
file = xy_uniform_path (file);
|
||||
file = xy_normalize_path (file);
|
||||
char *dir = xy_parent_dir (file);
|
||||
chsrc_ensure_dir (dir);
|
||||
|
||||
|
@ -33,7 +33,7 @@ pl_haskell_setsrc (char *option)
|
||||
char *config = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
config = xy_uniform_path ("~/AppData/Roaming/cabal/config");
|
||||
config = xy_normalize_path ("~/AppData/Roaming/cabal/config");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -43,7 +43,7 @@ pl_haskell_setsrc (char *option)
|
||||
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
|
||||
puts (file); br();
|
||||
|
||||
config = xy_uniform_path ("~/.stack/config.yaml");
|
||||
config = xy_normalize_path ("~/.stack/config.yaml");
|
||||
file = xy_strjoin (3, "package-indices:\n"
|
||||
" - download-prefix: ", source.url,
|
||||
"\n hackage-security:\n"
|
||||
|
@ -41,7 +41,7 @@ pl_java_find_maven_config ()
|
||||
char *maven_home = xy_str_delete_prefix (buf, "Maven home: ");
|
||||
maven_home = xy_str_strip (maven_home);
|
||||
|
||||
char *maven_config = xy_uniform_path (xy_2strjoin (maven_home, "/conf/settings.xml"));
|
||||
char *maven_config = xy_normalize_path (xy_2strjoin (maven_home, "/conf/settings.xml"));
|
||||
return maven_config;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ pl_nodejs_bun_setsrc (char *option)
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_uniform_path ("~/.bunfig.toml"), " 文件中"));
|
||||
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中"));
|
||||
}
|
||||
|
||||
puts (file);
|
||||
|
@ -54,7 +54,7 @@ pl_rust_cargo_setsrc (char *option)
|
||||
"[source.mirror]\n"
|
||||
"registry = \"sparse+", source.url, "\"");
|
||||
|
||||
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_uniform_path ("~/.cargo/config.toml"), " 文件中:"));
|
||||
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:"));
|
||||
puts (file);
|
||||
chsrc_conclude (&source, SetsrcType_Manual);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* File Name : xy.c
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Created On : <2023-08-30>
|
||||
* Last Modified : <2024-08-17>
|
||||
* Last Modified : <2024-11-21>
|
||||
*
|
||||
* 测试 xy.h
|
||||
* ------------------------------------------------------------*/
|
||||
@ -98,8 +98,8 @@ main (int argc, char const *argv[])
|
||||
}
|
||||
|
||||
|
||||
puts (xy_uniform_path (" \n ~/haha/test/123 \n\r "));
|
||||
assert_str (xy_uniform_path ("~/haha/test"), xy_parent_dir (" ~/haha/test/123"));
|
||||
puts (xy_normalize_path (" \n ~/haha/test/123 \n\r "));
|
||||
assert_str (xy_normalize_path ("~/haha/test"), xy_parent_dir (" ~/haha/test/123"));
|
||||
|
||||
xy_succ ("测试完成", "测试全部通过");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user