Here's my version, from
http://www.jsoftware.com/svn/DanBron/trunk/config/startup.yes.ijs :
NB. Create an arbitrary-depth directory
NB. (1!:5 will die if you try to create a subdir in a dir that doesn't
exist)
NB. e.g. mkdir 'c:\d\e\f\g\'
NB.! Does not handle '.' or '..' correctly.
NB.! Unpredictable about relative-directory creation.
NB.! Won't work on Win95 or NT4 with IE3 or earlier (or, obviously, any
non-windows OS).
NB. Put a slash on if it's not there already
appendSlash =. '\'&appendIfNotPresent @:
('/' scalarReplace '\') @: >
NB. Make a list of directories to be created (the }. is to make this
work
with the '\\' syntax of Windows network shares)
dirs =. (}.~ # (~: * >:@:])
i:&(<'\\')) @: (<@;\) @: (<;.2) @:
appendSlash
NB. DLL call to check if a path exists. NB.!! Won't work on Win95 or
NT4
with IE3 or earlier.
NB. I don't use 1!:0 because 1!:0 '\\host\share\' fails, even though
1!:0
'\\host\share\sub\' works
existing =. >@:{.@:('shlwapi.dll
PathFileExistsA i *c'&(15!:0))"0
NB. Find the first directory that doesn't exist, then grab it and
everthing after it for creation.
nonExistant =. (a:"_`(}.~ >:)@.((~: #)~)
i:&1@:existing)
NB. Make a nested directory
mkdir =: *./ @: , @: (1!:5 @:
nonExistant @: dirs) f. :: 0:
I wrote this a long time ago.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm