Get path of filename
Posted: Tue Apr 22, 2014 9:03 pm
I want to write a function to get the path of a filename in a LÖVE program, and am finding it difficult. getDir('/usr/local/bin/sl') should return '/usr/local/bin'. I essentially want to remove the last item in a filename. In python I would just do:
but as far as I know lua does not have the split or the join functions.
Code: Select all
def getDir(sPath):
dir = '/'.join(sPath.split('/')[:-1])
return dir