Q:

How do i get directory path, given a file name in Lua, which is platform independent

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?

A:

package.config:sub(1,1) gives you the path separator for the platform in which Lua is running. See the manual.

