From 88f67680fc7fa7c846dd0c0db678f4b76065977a Mon Sep 17 00:00:00 2001 From: Kaiyin Zhong Date: Wed, 26 Jun 2019 12:56:05 +0200 Subject: [PATCH] rename get_extension to ext, add path_sans_ext --- os/os.v | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/os/os.v b/os/os.v index c7399d3e65..7ee3553185 100644 --- a/os/os.v +++ b/os/os.v @@ -387,7 +387,7 @@ fn print_c_errno() { } -pub fn get_extension(path string) string { +pub fn ext(path string) string { pos := path.last_index('.') if pos == -1 { return '' @@ -395,6 +395,15 @@ pub fn get_extension(path string) string { return path.right(pos) } +fn path_sans_ext(path string) string { + pos := path.last_index('.') + if pos == -1 { + return path + } + return path.left(pos) +} + + pub fn basedir(path string) string { pos := path.last_index('/') if pos == -1 {