A function that breaks down a file or folder path and returns the components as a table.
functionParseFilePath(s) assert(type(s) == 'string', 'ParseFilePath: string expected, got ' .. type(s) .. '.') local t = {}
for Piece in s:gmatch('[^\\]+') do table.insert(t, Piece) end
-- VOLUME if #t > 0then local UNCprefix = s:match('^(\\\\)') or'' t.Vol = UNCprefix .. t[1] .. '\\' end
-- NAME if #t > 1then -- DETECT FOLDER OR SEPARATE EXTENSION if s:match('\\$') then t.Name = t[#t] .. '\\' elseif t[#t]:match('.+%..+') then t.Name, t.Ext = t[#t]:match('(.-)%.([^%.]-)$') else t.Name = t[#t] end end
-- FOLDER if #t > 2then t.Dir = table.concat(t, '\\', 2, #t-1) .. '\\' end