mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 16:07:01 +00:00
96 lines
1.4 KiB
Plaintext
96 lines
1.4 KiB
Plaintext
// os.vr — operating system and filesystem helpers (part of the VuurRaaf stdlib).
|
|
//
|
|
// import os
|
|
// if os.exists("build.vrmm") {
|
|
// for f in os.list_dir(".") {
|
|
// println(f)
|
|
// }
|
|
// }
|
|
|
|
fn exists(path) {
|
|
return build_exists(path)
|
|
}
|
|
|
|
fn is_dir(path) {
|
|
return build_is_dir(path)
|
|
}
|
|
|
|
fn is_file(path) {
|
|
return build_exists(path) and not build_is_dir(path)
|
|
}
|
|
|
|
fn mkdir(path) {
|
|
build_mkdir(path)
|
|
return 0
|
|
}
|
|
|
|
fn remove(path) {
|
|
return build_rm(path)
|
|
}
|
|
|
|
fn copy(src, dst) {
|
|
build_copy(src, dst)
|
|
return 0
|
|
}
|
|
|
|
fn list_dir(path) {
|
|
return build_ls(path)
|
|
}
|
|
|
|
fn glob(pattern) {
|
|
return build_glob(pattern)
|
|
}
|
|
|
|
fn join(a, b) {
|
|
return build_join(a, b)
|
|
}
|
|
|
|
fn base(path) {
|
|
return build_base(path)
|
|
}
|
|
|
|
fn dir(path) {
|
|
return build_dir(path)
|
|
}
|
|
|
|
fn read_lines(path) {
|
|
return split_lines(read_file(path))
|
|
}
|
|
|
|
fn write_lines(path, lines) {
|
|
write_file(path, join(lines, "\n") + "\n")
|
|
return 0
|
|
}
|
|
|
|
fn cwd() {
|
|
return cwd()
|
|
}
|
|
|
|
fn env(name) {
|
|
return getenv(name)
|
|
}
|
|
|
|
fn exec(cmd) {
|
|
return build_exec(cmd)
|
|
}
|
|
|
|
// ext returns the file extension including the dot ("file.txt" -> ".txt").
|
|
fn ext(path) {
|
|
return path_ext(path)
|
|
}
|
|
|
|
// abs converts a path to an absolute one.
|
|
fn abs(path) {
|
|
return path_abs(path)
|
|
}
|
|
|
|
// rel returns path relative to base ("a/b/c.txt" relative to "a" -> "b/c.txt").
|
|
fn rel(path, base) {
|
|
return path_rel(path, base)
|
|
}
|
|
|
|
// exec_full runs a shell command and returns {code, stdout, stderr}.
|
|
fn exec_full(cmd) {
|
|
return exec_full(cmd)
|
|
}
|