aboutsummaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/util.lua b/util.lua
index 114aad4..8d9df9b 100644
--- a/util.lua
+++ b/util.lua
@@ -123,6 +123,13 @@ function util.get_relative_path(cwd_components, absolute_path_or_components)
return dir:sub(2)
end
+--- Strip the last component from a pathname
+-- @param the pathname
+-- @return the pathname up to the last '/'
+function util.dirname(name)
+ return name:match('(.*[/])')
+end
+
--- Create an iterator yielding the nth line of a file
--
-- @param path The path to the file