mirror of
https://github.com/RubyMetric/chsrc.git
synced 2025-01-22 12:49:56 +08:00
Rename to uniform path
This commit is contained in:
parent
87858ed7a8
commit
fe7e08c6a5
16
chsrc.c
16
chsrc.c
|
@ -434,7 +434,7 @@ pl_java_check_cmd_(bool* maven_exist, bool* gradle_exist)
|
||||||
*gradle_exist = does_the_program_exist (check_cmd, "gradle");
|
*gradle_exist = does_the_program_exist (check_cmd, "gradle");
|
||||||
|
|
||||||
if (! *maven_exist && ! *gradle_exist) {
|
if (! *maven_exist && ! *gradle_exist) {
|
||||||
chsrc_error ("maven 与 gradle 命令均未找到,请检查是否存在(其一)");
|
chsrc_error ("maven 与 gradle 命令均未找到,请检查是否存在其一");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,13 +452,7 @@ pl_java_find_maven_config_ ()
|
||||||
// xy_info (buf);
|
// xy_info (buf);
|
||||||
maven_home = xy_str_strip(maven_home);
|
maven_home = xy_str_strip(maven_home);
|
||||||
|
|
||||||
char* maven_config = NULL;
|
char* maven_config = xy_uniform_path(xy_2strjoin(maven_home, "/conf/settings.xml"));
|
||||||
|
|
||||||
if (xy_on_windows)
|
|
||||||
maven_config = xy_2strjoin(maven_home, "\\conf\\settings.xml");
|
|
||||||
else
|
|
||||||
maven_config = xy_2strjoin(maven_home, "/conf/settings.xml");
|
|
||||||
|
|
||||||
return maven_config;
|
return maven_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,15 +607,15 @@ pl_haskell_setsrc(char* option)
|
||||||
|
|
||||||
char* config = NULL;
|
char* config = NULL;
|
||||||
if (xy_on_windows) {
|
if (xy_on_windows) {
|
||||||
config = xy_2strjoin(xy_os_home, "\\AppData\\Roaming\\cabal\\config");
|
config = xy_uniform_path ("~/AppData/Roaming/cabal/config");
|
||||||
} else {
|
} else {
|
||||||
config = xy_2strjoin(xy_os_home, "/.cabal/config");
|
config = "~/.cabal/config";
|
||||||
}
|
}
|
||||||
|
|
||||||
xy_info(xy_strjoin(3,"chsrc: 请向 ", config, " 中手动添加:"));
|
xy_info(xy_strjoin(3,"chsrc: 请向 ", config, " 中手动添加:"));
|
||||||
puts(file); puts("");
|
puts(file); puts("");
|
||||||
|
|
||||||
config = xy_2strjoin(xy_os_home, "/.stack/config.yaml");
|
config = xy_uniform_path ("~/.stack/config.yaml");
|
||||||
file = xy_strjoin(3, "package-indices:\n"
|
file = xy_strjoin(3, "package-indices:\n"
|
||||||
" - download-prefix: ", source.url,
|
" - download-prefix: ", source.url,
|
||||||
"\n hackage-security:\n"
|
"\n hackage-security:\n"
|
||||||
|
|
4
chsrc.h
4
chsrc.h
|
@ -289,8 +289,8 @@ static void
|
||||||
chsrc_check_file (const char* path)
|
chsrc_check_file (const char* path)
|
||||||
{
|
{
|
||||||
char* cmd = NULL;
|
char* cmd = NULL;
|
||||||
|
path = xy_uniform_path (path);
|
||||||
if(xy_on_windows) {
|
if(xy_on_windows) {
|
||||||
path = xy_unix_path_to_win (path);
|
|
||||||
cmd = xy_2strjoin ("type ", path);
|
cmd = xy_2strjoin ("type ", path);
|
||||||
} else {
|
} else {
|
||||||
cmd = xy_2strjoin ("cat ", path);
|
cmd = xy_2strjoin ("cat ", path);
|
||||||
|
@ -301,6 +301,7 @@ chsrc_check_file (const char* path)
|
||||||
static void
|
static void
|
||||||
chsrc_append_to_file (const char* str, const char* file)
|
chsrc_append_to_file (const char* str, const char* file)
|
||||||
{
|
{
|
||||||
|
file = xy_uniform_path (file);
|
||||||
char* cmd = NULL;
|
char* cmd = NULL;
|
||||||
if (xy_on_windows) {
|
if (xy_on_windows) {
|
||||||
cmd = xy_strjoin (4, "echo ", str, " >> ", file);
|
cmd = xy_strjoin (4, "echo ", str, " >> ", file);
|
||||||
|
@ -313,6 +314,7 @@ chsrc_append_to_file (const char* str, const char* file)
|
||||||
static void
|
static void
|
||||||
chsrc_overwrite_file (const char* str, const char* file)
|
chsrc_overwrite_file (const char* str, const char* file)
|
||||||
{
|
{
|
||||||
|
file = xy_uniform_path (file);
|
||||||
char* cmd = NULL;
|
char* cmd = NULL;
|
||||||
if (xy_on_windows) {
|
if (xy_on_windows) {
|
||||||
cmd = xy_strjoin (4, "echo ", str, " > ", file);
|
cmd = xy_strjoin (4, "echo ", str, " > ", file);
|
||||||
|
|
|
@ -91,7 +91,7 @@ main (int argc, char const *argv[])
|
||||||
assert(xy_file_exist(xy_win_powershell_profile));
|
assert(xy_file_exist(xy_win_powershell_profile));
|
||||||
assert(false==xy_file_exist(xy_win_powershellv5_profile));
|
assert(false==xy_file_exist(xy_win_powershellv5_profile));
|
||||||
|
|
||||||
puts (xy_unix_path_to_win_if_on_win(" \n ~/haha/test/123 \n\r "));
|
puts (xy_uniform_path(" \n ~/haha/test/123 \n\r "));
|
||||||
|
|
||||||
xy_success("测试全部通过");
|
xy_success("测试全部通过");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
2
xy.h
2
xy.h
|
@ -534,7 +534,7 @@ xy_file_exist (const char* path)
|
||||||
* 该函数即使在非Windows下也可调用,作用是删除路径左右两边多出来的空白符
|
* 该函数即使在非Windows下也可调用,作用是删除路径左右两边多出来的空白符
|
||||||
*/
|
*/
|
||||||
static char*
|
static char*
|
||||||
xy_unix_path_to_win_if_on_win (const char* path)
|
xy_uniform_path (const char* path)
|
||||||
{
|
{
|
||||||
char* new = xy_str_strip(path); // 防止开发者多写了空白符
|
char* new = xy_str_strip(path); // 防止开发者多写了空白符
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user