move os_env from run to os-unix.c/os-windows.c
parent
02886132f3
commit
409d984c3c
10
vm/os-unix.c
10
vm/os-unix.c
|
@ -85,6 +85,16 @@ DEFINE_PRIMITIVE(read_dir)
|
||||||
dpush(result);
|
dpush(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_PRIMITIVE(os_env)
|
||||||
|
{
|
||||||
|
char *name = unbox_char_string();
|
||||||
|
char *value = getenv(name);
|
||||||
|
if(value == NULL)
|
||||||
|
dpush(F);
|
||||||
|
else
|
||||||
|
box_char_string(value);
|
||||||
|
}
|
||||||
|
|
||||||
DEFINE_PRIMITIVE(os_envs)
|
DEFINE_PRIMITIVE(os_envs)
|
||||||
{
|
{
|
||||||
GROWABLE_ARRAY(result);
|
GROWABLE_ARRAY(result);
|
||||||
|
|
|
@ -215,19 +215,34 @@ void sleep_millis(DWORD msec)
|
||||||
Sleep(msec);
|
Sleep(msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_PRIMITIVE(os_env)
|
||||||
|
{
|
||||||
|
F_CHAR *key = unbox_u16_string();
|
||||||
|
F_CHAR *value = safe_malloc(MAX_UNICODE_PATH);
|
||||||
|
int ret;
|
||||||
|
ret = GetEnvironmentVariable(key, value, MAX_UNICODE_PATH);
|
||||||
|
if(ret == 0)
|
||||||
|
dpush(F);
|
||||||
|
else
|
||||||
|
dpush(tag_object(from_u16_string(value)));
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
|
||||||
DEFINE_PRIMITIVE(set_os_env)
|
DEFINE_PRIMITIVE(set_os_env)
|
||||||
{
|
{
|
||||||
F_CHAR *key = unbox_u16_string();
|
F_CHAR *key = unbox_u16_string();
|
||||||
REGISTER_C_STRING(key);
|
REGISTER_C_STRING(key);
|
||||||
F_CHAR *value = unbox_u16_string();
|
F_CHAR *value = unbox_u16_string();
|
||||||
UNREGISTER_C_STRING(key);
|
UNREGISTER_C_STRING(key);
|
||||||
SetEnvironmentVariable(key, value);
|
if(!SetEnvironmentVariable(key, value))
|
||||||
|
general_error(ERROR_IO, tag_object(get_error_message()), F, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_PRIMITIVE(unset_os_env)
|
DEFINE_PRIMITIVE(unset_os_env)
|
||||||
{
|
{
|
||||||
F_CHAR *key = unbox_u16_string();
|
if(!SetEnvironmentVariable(unbox_u16_string(), NULL)
|
||||||
SetEnvironmentVariable(key, NULL);
|
&& GetLastError() != ERROR_ENVVAR_NOT_FOUND)
|
||||||
|
general_error(ERROR_IO, tag_object(get_error_message()), F, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_PRIMITIVE(set_os_envs)
|
DEFINE_PRIMITIVE(set_os_envs)
|
||||||
|
|
10
vm/run.c
10
vm/run.c
|
@ -280,16 +280,6 @@ DEFINE_PRIMITIVE(exit)
|
||||||
exit(to_fixnum(dpop()));
|
exit(to_fixnum(dpop()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_PRIMITIVE(os_env)
|
|
||||||
{
|
|
||||||
char *name = unbox_char_string();
|
|
||||||
char *value = getenv(name);
|
|
||||||
if(value == NULL)
|
|
||||||
dpush(F);
|
|
||||||
else
|
|
||||||
box_char_string(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_PRIMITIVE(eq)
|
DEFINE_PRIMITIVE(eq)
|
||||||
{
|
{
|
||||||
CELL lhs = dpop();
|
CELL lhs = dpop();
|
||||||
|
|
Loading…
Reference in New Issue