On Sun, Mar 25, 2012 at 1:51 PM, Clemens Buchacher <dri...@aon.at> wrote:
> On Sun, Mar 25, 2012 at 12:43:07PM +0200, c. wrote:
>>
>> I see 3 possibilities to fix this:
>>
>>  1 - change the PKG_ADD in the packages
>>
>>  2 - patch pkg.m to handle subdirectories in a better way
>
> Maybe adding a "pkg dir" function would make it easier for PKG_ADD's to
> handle.
>
> function dir = pkg_dir(name)
>  [local_packages, global_packages] = pkg("list");
>  installed_pkgs_lst = {local_packages{:}, global_packages{:}};
>
>  dir = [];
>  for i = 1:length (installed_pkgs_lst)
>    pkg = installed_pkgs_lst{i};
>    if strcmp (name, pkg.name)
>      dir = pkg.dir;
>    endif
>  endfor
> endfunction

Sounds good to me. Little retouch

function dir = pkg_dir(name)
 [local_packages, global_packages] = pkg("list");
 installed_pkgs_lst = {local_packages{:}, global_packages{:}};

 installed_names = cellfun (@(x) x.name,
installed_pkgs_lst,'uniformoutput',false);
 [tf idx] = ismember (name,installed_names);

 dir = [];
 if tf
   dir = installed_pkgs_lst{idx}.dir;
 end
endfunction
-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to