mirror of
https://github.com/janet-lang/janet
synced 2024-11-29 03:19:54 +00:00
Add os/remove.
This commit is contained in:
parent
178d175bcf
commit
fd2d706e33
@ -26,7 +26,7 @@
|
|||||||
#include "fiber.h"
|
#include "fiber.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static JanetBuildConfig *api_build_config = &(JanetBuildConfig){
|
static JanetBuildConfig *api_build_config = &(JanetBuildConfig) {
|
||||||
.api_version = JANET_API_VERSION,
|
.api_version = JANET_API_VERSION,
|
||||||
.single_threaded = JANET_SINGLE_THREADED_BIT,
|
.single_threaded = JANET_SINGLE_THREADED_BIT,
|
||||||
.nanbox = JANET_NANBOX_BIT
|
.nanbox = JANET_NANBOX_BIT
|
||||||
|
@ -607,6 +607,17 @@ static Janet os_dir(int32_t argc, Janet *argv) {
|
|||||||
return janet_wrap_array(paths);
|
return janet_wrap_array(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Janet os_rename(int32_t argc, Janet *argv) {
|
||||||
|
janet_fixarity(argc, 2);
|
||||||
|
const char *src = janet_getcstring(argv, 0);
|
||||||
|
const char *dest = janet_getcstring(argv, 1);
|
||||||
|
int status = rename(src, dest);
|
||||||
|
if (status) {
|
||||||
|
janet_panic(strerror(errno));
|
||||||
|
}
|
||||||
|
return janet_wrap_nil();
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* JANET_REDUCED_OS */
|
#endif /* JANET_REDUCED_OS */
|
||||||
|
|
||||||
static const JanetReg os_cfuns[] = {
|
static const JanetReg os_cfuns[] = {
|
||||||
@ -742,6 +753,11 @@ static const JanetReg os_cfuns[] = {
|
|||||||
"\t:year-day - day of the year [0-365]\n"
|
"\t:year-day - day of the year [0-365]\n"
|
||||||
"\t:dst - If Day Light Savings is in effect")
|
"\t:dst - If Day Light Savings is in effect")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"os/rename", os_rename,
|
||||||
|
JDOC("(os/rename oldname newname)\n\n"
|
||||||
|
"Rename a file on disk to a new path. Returns nil.")
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user