Rename xy function

This commit is contained in:
Aoran Zeng 2024-11-21 20:17:24 +08:00
parent 5d7a13a56b
commit d7cc74c494
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
7 changed files with 18 additions and 18 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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"

View File

@ -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;
}

View File

@ -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);

View 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);
}

View File

@ -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 ("测试完成", "测试全部通过");