samer@0: function [p,h]=dbroot(newroot, newhost) samer@0: % dbroot - Set or retrieve Matbase root directory samer@0: % samer@0: % dbroot :: unit -> string ~'current root', string ~'current name'. samer@0: % dbroot :: string ~'new root' -> action unit. samer@0: % dbroot :: string ~'new root', string ~'new host' -> action unit. samer@0: % samer@0: % The matbase system uses the root and host name to decided where to samer@0: % put the MAT files saved by dbsave, dbsaveas and dbtmp. A directory named samer@0: % after the host is created under the given root. Directories based on samer@0: % the current date are created under the per-host directories. This means samer@0: % the root can be on a shared filesystem as long as each host has a unique samer@0: % name. samer@0: % samer@0: % Note that dbroot MUST be called at least once before the matbase is used samer@0: % otherwise the results are undefined. samer@0: % samer@0: % If no hostname is given, dbroot will attempt to read the HOSTNAME samer@0: % environment variable. If this is empty, a error will be raised. samer@0: samer@0: global DBROOT samer@0: global HOSTNAME samer@0: samer@0: if nargin>=1, samer@0: DBROOT=newroot; samer@0: if nargin<2, newhost=getenv('HOSTNAME'); end samer@0: if isempty(newhost) samer@0: error('dbroot:nohostname','Could not get host name'); samer@0: end samer@0: HOSTNAME=[newhost filesep]; samer@0: else samer@0: % no input arguments so return current values samer@0: p=DBROOT; samer@0: h=HOSTNAME; samer@0: end samer@0: samer@0: