Posted By

denisko-redisko on 01/30/12


Tagged


Versions (?)

lua mkpath function


 / Published in: Lua
 

Creates a complex folder structure

  1. local lfs = require("lfs")
  2.  
  3. function lfs.mkpath (path)
  4. local dirpath = ""
  5. for dirname in path:gmatch("[^\\/]+") do
  6. dirpath = dirpath .. dirname .. "/"
  7. lfs.mkdir(dirpath)
  8. end
  9. end
  10.  
  11. lfs.mkpath(
  12. 'dir level_1 num_1/dir level_2 num_1/dir level_3 num_1/'..
  13. '../dir level_3 num_2/'..
  14. '../../dir level_2 num_2/dir level_3 num_1/'..
  15. '../dir level_3 num_2'
  16. )

Report this snippet  

You need to login to post a comment.