diff options
Diffstat (limited to 'examples/file.tm')
| -rw-r--r-- | examples/file.tm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/file.tm b/examples/file.tm index 6b8807eb..99383a56 100644 --- a/examples/file.tm +++ b/examples/file.tm @@ -56,6 +56,18 @@ func read(path:Text)->FileReadResult: } return Failure(builtin_last_err()) +func resolve_path(path:Text, relative_to=".")->Text: + path_c_str := path:as_c_string() + relative_to_c_str := relative_to:as_c_string() + inline C { + extern char *resolve_path(char*, char*, char*); + } + !! Resolving: ($path_c_str, $relative_to_c_str, $relative_to_c_str) + >> resolved := inline C ( + resolve_path($path_c_str, $relative_to_c_str, $relative_to_c_str) + ): CString + return Text.from_c_string(resolved) + struct WriteHandle(_file:@Memory): func write(h:WriteHandle, text:Text, flush=yes): inline C { |
