mirror of
https://github.com/RubyMetric/chsrc.git
synced 2025-02-02 06:54:01 +08:00
Use chsrc_check_file()
This commit is contained in:
parent
eb0bd01d4c
commit
f1ec6f8399
33
chsrc.c
33
chsrc.c
|
@ -368,13 +368,11 @@ pl_go_setsrc (char* option)
|
||||||
void
|
void
|
||||||
pl_rust_getsrc (char* option)
|
pl_rust_getsrc (char* option)
|
||||||
{
|
{
|
||||||
char* cmd = NULL;
|
|
||||||
if(xy_on_windows) {
|
if(xy_on_windows) {
|
||||||
cmd = "type %USERPROFILE%\\.cargo";
|
chsrc_check_file ("%USERPROFILE%\\.cargo");
|
||||||
} else {
|
} else {
|
||||||
cmd = "cat ~/.cargo";
|
chsrc_check_file ("~/.cargo");
|
||||||
}
|
}
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -728,13 +726,11 @@ pl_r_getsrc (char* option)
|
||||||
// options()$repos
|
// options()$repos
|
||||||
// options()$BioC_mirror
|
// options()$BioC_mirror
|
||||||
//
|
//
|
||||||
char* cmd = NULL;
|
|
||||||
if(xy_on_windows) {
|
if(xy_on_windows) {
|
||||||
cmd = "type %USERPROFILE%\\Documents\\.Rprofile";
|
chsrc_check_file ("%USERPROFILE%\\Documents\\.Rprofile");
|
||||||
} else {
|
} else {
|
||||||
cmd = "cat ~/.Rprofile";
|
chsrc_check_file ("~/.Rprofile");
|
||||||
}
|
}
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -787,13 +783,11 @@ pl_r_setsrc (char* option)
|
||||||
void
|
void
|
||||||
pl_julia_getsrc (char* option)
|
pl_julia_getsrc (char* option)
|
||||||
{
|
{
|
||||||
char* cmd = NULL;
|
|
||||||
if(xy_on_windows) {
|
if(xy_on_windows) {
|
||||||
cmd = "type %USERPROFILE%\\.julia\\config\\startup.jl";
|
chsrc_check_file ("%USERPROFILE%\\.julia\\config\\startup.jl");
|
||||||
} else {
|
} else {
|
||||||
cmd = "cat ~/.julia/config/startup.jl";
|
chsrc_check_file ("~/.julia/config/startup.jl");
|
||||||
}
|
}
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -838,8 +832,7 @@ pl_julia_setsrc (char* option)
|
||||||
void
|
void
|
||||||
os_ubuntu_getsrc(char* option)
|
os_ubuntu_getsrc(char* option)
|
||||||
{
|
{
|
||||||
char* cmd = "cat /etc/apt/sources.list";
|
chsrc_check_file ("/etc/apt/sources.list");
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -894,8 +887,7 @@ os_ubuntu_setsrc (char* option)
|
||||||
void
|
void
|
||||||
os_debian_getsrc(char* option)
|
os_debian_getsrc(char* option)
|
||||||
{
|
{
|
||||||
char* cmd = "cat /etc/apt/sources.list";
|
chsrc_check_file ("/etc/apt/sources.list");
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -942,8 +934,7 @@ os_debian_setsrc (char* option)
|
||||||
void
|
void
|
||||||
os_deepin_getsrc(char* option)
|
os_deepin_getsrc(char* option)
|
||||||
{
|
{
|
||||||
char* cmd = "cat /etc/apt/sources.list";
|
chsrc_check_file ("/etc/apt/sources.list");
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1613,8 +1604,7 @@ os_freebsd_setsrc (char* option)
|
||||||
void
|
void
|
||||||
os_netbsd_getsrc (char* option)
|
os_netbsd_getsrc (char* option)
|
||||||
{
|
{
|
||||||
char* cmd = "cat /usr/pkg/etc/pkgin/repositories.conf";
|
chsrc_check_file ("/usr/pkg/etc/pkgin/repositories.conf");
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1663,8 +1653,7 @@ os_netbsd_setsrc(char* option)
|
||||||
void
|
void
|
||||||
os_openbsd_getsrc (char* option)
|
os_openbsd_getsrc (char* option)
|
||||||
{
|
{
|
||||||
char* cmd = "cat /etc/installurl";
|
chsrc_check_file ("/etc/installurl");
|
||||||
chsrc_run(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
13
chsrc.h
13
chsrc.h
|
@ -272,7 +272,6 @@ not_root:
|
||||||
#define chsrc_warn(str) xy_warn(xy_2strjoin(App_Prefix, (str)))
|
#define chsrc_warn(str) xy_warn(xy_2strjoin(App_Prefix, (str)))
|
||||||
#define chsrc_error(str) xy_error(xy_2strjoin(App_Prefix, (str)))
|
#define chsrc_error(str) xy_error(xy_2strjoin(App_Prefix, (str)))
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chsrc_run (const char* cmd)
|
chsrc_run (const char* cmd)
|
||||||
{
|
{
|
||||||
|
@ -280,6 +279,18 @@ chsrc_run (const char* cmd)
|
||||||
system(cmd);
|
system(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chsrc_check_file (const char* path)
|
||||||
|
{
|
||||||
|
char* cmd = NULL;
|
||||||
|
if(xy_on_windows) {
|
||||||
|
cmd = xy_2strjoin ("type ", path);
|
||||||
|
} else {
|
||||||
|
cmd = xy_2strjoin ("cat ", path);
|
||||||
|
}
|
||||||
|
chsrc_run (cmd);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chsrc_append_to_file (const char* str, const char* file)
|
chsrc_append_to_file (const char* str, const char* file)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user