By the way, it is probably a good example of the kind of pickle a
non-expert user of J can get themselves into when trying to do simple
things. I bet that somebody here could write it in about 10
characters!

2009/11/24 Matthew Brand <[email protected]>:
> I have a function called createPathTree_utils_ which creates a whole
> path no matter how deep it is but does not complain if anything
> already exists along the way. It is probably not the best way to do
> it, but it works for me. I find it useful, but maybe there is already
> something like this somewhere in one of the many addons/libraries
> which I have not come across yet?
>
> example:
> createPathTree_utils_ '/tmp/dir1/dir2/'
>
>
>
> coclass 'utils'
> typecheck =: =3!:0
> isboxed =: 32&typecheck_utils_
> boxifopen =: <^:(-...@isboxed_utils_)
> exists  =: 0&<@#@(1!:0)@boxifopen_utils_ NB. does file or directory y exist
> newdir  =: 1!:5...@boxifopen_utils_ NB. create new directory y
> createPath =: newdir_utils_ ^:(-.@:exists_utils_@:(_1&}.)) NB. create
> a path if it does not exist
> createPathTree =:  (  (createPath_utils_ f.)@ ,&'/' @ ; @ ]\ @:
> (_1&}.) @: (<;.1) ) :: 0:
>
>
> 2009/11/24 Dan Bron <[email protected]>:
>> I've just started playing with JDB.  I've found a minor bug:
>>
>>           load'data/jdb'
>>
>>           hf=: Open_jdb_ 'NONEXISTANTDIRECTORY'
>>        |domain error: throw
>>        |       throw msg
>>
>> This isn't a very helpful error message; the problem is  msg  is boxed, and
>> it should be literal.  The cause is line 240 of ~addons\data\jdb\jdb.ijs  :
>>
>>     msg=. (0<#y) { 'Directory not given';'Not a directory: ',dbf
>>
>> the  {  should be  {::  or a  >  should follow the  =.  (or  throw  should
>> accept boxed args).
>>
>> IMO, it would be better to create a non-existant directory.  But that's a
>> design question.
>>
>> -Dan
>>
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to