2018-05-22 19:43:54 -04:00
|
|
|
import str:*
|
2016-01-04 02:00:06 -05:00
|
|
|
import mem:*
|
2016-07-06 00:16:39 -07:00
|
|
|
import io:*
|
2016-01-04 02:00:06 -05:00
|
|
|
|
2018-05-22 19:43:54 -04:00
|
|
|
fun system(call_string: str):int {
|
2016-01-04 02:00:06 -05:00
|
|
|
var c_call_string = call_string.toCharArray()
|
|
|
|
|
var result = system(c_call_string)
|
|
|
|
|
delete(c_call_string)
|
|
|
|
|
return result
|
|
|
|
|
}
|
2016-04-30 15:38:28 -04:00
|
|
|
ext fun system(call_string: *char): int
|
|
|
|
|
ext fun exit(code: int):void
|
2016-07-06 00:16:39 -07:00
|
|
|
fun exit() exit(0)
|
2016-01-04 02:00:06 -05:00
|
|
|
|
2016-07-06 00:16:39 -07:00
|
|
|
ext fun popen(command: *char, mode: *char): *void
|
|
|
|
|
ext fun pclose(file: *void): int
|
2018-05-22 19:43:54 -04:00
|
|
|
fun from_system_command(command: str, line_size: int): str {
|
2016-07-06 00:16:39 -07:00
|
|
|
var command_string = command.toCharArray()
|
|
|
|
|
defer delete(command_string)
|
|
|
|
|
var p = popen(command_string, "r")
|
|
|
|
|
var to_ret = get_line(line_size, p)
|
|
|
|
|
pclose(p)
|
|
|
|
|
return to_ret
|
|
|
|
|
}
|
2018-05-22 19:43:54 -04:00
|
|
|
fun get_time(): long { return string_to_num<long>(from_system_command(str("date +%s"), 50)); }
|
2018-02-02 00:26:31 -05:00
|
|
|
fun split(time: long, split_label: *char): long {
|
|
|
|
|
var new_time = get_time()
|
2018-05-22 19:43:54 -04:00
|
|
|
print(str(split_label) + ": ")
|
2018-02-02 00:26:31 -05:00
|
|
|
println(new_time - time)
|
|
|
|
|
return new_time
|
|
|
|
|
}
|
|
|
|
|
|