If file is /etc/haproxy/haproxy.cfg
, output should be directory name /etc/haproxy
.
Currently i am using
file = "/etc/haproxy/haproxy.cfg"
sep = "/"
file:match("(.*"..sep..")")
But it is not platform independent and would fail on Windows, since the path separator is different. So is there a platform agnostic way of achieving this, with using lfs module?
package.config:sub(1,1)
gives you the path separator for the platform in which Lua is running. See the manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With