From 6ae210f37b2b3c4c45e530109f7697a285c68fc5 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 6 Sep 2024 15:39:20 -0400 Subject: Add resolve_path() --- examples/file.tm | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 { -- cgit v1.2.3