// Programs, for Windows. The same functions as proc.fch (that file is for Linux and macOS). import "stdlib.h" import "process.h" import "direct.h" import "time.h" fn run(str command) -> int { return shell(command) } fn output(str command) -> str! { tmp := proc_env("TEMP", ".") + "\\finch_out_" + str(getpid()) + "_" + str(int(time(null))) code := shell(command + " > \"" + tmp + "\" 2>&1") text := read_file(tmp) or "" delete_file(tmp) if code != 0 { return error("'" + command + "' exited with code " + str(code) + ": " + text.trim()) } return text } fn proc_env(str name, str fallback) -> str { v := getenv(name) if v.len == 0 { return fallback } return v } fn env(str name, str fallback) -> str { return proc_env(name, fallback) } fn pid() -> int { return int(getpid()) } fn cwd() -> str { []char buf for i in 0..4096 { buf.push(char(0)) } getcwd(buf.ptr, 4096) return str(buf.ptr) }