/* REXX */ /* * Equivalent of 'mkdir -p' on Linux (creates all missing path components) * * (c) too simple to be copyrighted */ '@echo off' parse arg aArgs /* @todo process quotes in arguments to make it possible to create several * directories at once */ aArgs = strip(aArgs) if (aArgs == '') then do say "Usage: mkdir-p " exit 255 end exit MakeDir(strip(aArgs)) MakeDir: procedure expose (Globals) parse arg aDir aDir = translate(aDir, '\', '/') curdir = directory() base = aDir todo.0 = 0 do while 1 d = directory(base) if (d \== '') then leave i = todo.0 + 1 todo.i = filespec('N', base) todo.0 = i drv = filespec('D', base) path = filespec('P', base) if (path == '\' | path == '') then do base = drv||path leave end base = drv||strip(path, 'T', '\') end call directory curdir do i = todo.0 to 1 by -1 if (i < todo.0 | (base \== '' & right(base,1) \== '\' &, right(base,1) \== ':')) then base = base'\' base = base||todo.i rc = SysMkDir(base) if (rc \= 0) then do say 'Could not create directory '''base'''!' say 'SysMkDir returned 'rc return rc end end return 0