From 0f05f7c1eecfcc5fd968ce69a686f621dd3a3339 Mon Sep 17 00:00:00 2001 From: Kaiyin Zhong Date: Wed, 26 Jun 2019 11:28:06 +0200 Subject: [PATCH] get extension of path --- os/os.v | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/os/os.v b/os/os.v index 696949a874..c7399d3e65 100644 --- a/os/os.v +++ b/os/os.v @@ -386,6 +386,15 @@ fn print_c_errno() { # printf("errno=%d err='%s'\n", errno, strerror(errno)); } + +pub fn get_extension(path string) string { + pos := path.last_index('.') + if pos == -1 { + return '' + } + return path.right(pos) +} + pub fn basedir(path string) string { pos := path.last_index('/') if pos == -1 {