1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rename get_extension to ext, add path_sans_ext

This commit is contained in:
Kaiyin Zhong 2019-06-26 12:56:05 +02:00 committed by Alex Medvednikov
parent 67eb8d74c1
commit 88f67680fc

11
os/os.v
View File

@ -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('.') pos := path.last_index('.')
if pos == -1 { if pos == -1 {
return '' return ''
@ -395,6 +395,15 @@ pub fn get_extension(path string) string {
return path.right(pos) 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 { pub fn basedir(path string) string {
pos := path.last_index('/') pos := path.last_index('/')
if pos == -1 { if pos == -1 {