annotate matlab/db/dbroot.m @ 37:89688ebc447f tip

Deprecating this repository.
author samer
date Mon, 05 Jan 2015 17:42:03 +0000
parents 0dd31a8c66bd
children
rev   line source
samer@0 1 function [p,h]=dbroot(newroot, newhost)
samer@0 2 % dbroot - Set or retrieve Matbase root directory
samer@0 3 %
samer@0 4 % dbroot :: unit -> string ~'current root', string ~'current name'.
samer@0 5 % dbroot :: string ~'new root' -> action unit.
samer@0 6 % dbroot :: string ~'new root', string ~'new host' -> action unit.
samer@0 7 %
samer@0 8 % The matbase system uses the root and host name to decided where to
samer@0 9 % put the MAT files saved by dbsave, dbsaveas and dbtmp. A directory named
samer@0 10 % after the host is created under the given root. Directories based on
samer@0 11 % the current date are created under the per-host directories. This means
samer@0 12 % the root can be on a shared filesystem as long as each host has a unique
samer@0 13 % name.
samer@0 14 %
samer@0 15 % Note that dbroot MUST be called at least once before the matbase is used
samer@0 16 % otherwise the results are undefined.
samer@0 17 %
samer@0 18 % If no hostname is given, dbroot will attempt to read the HOSTNAME
samer@0 19 % environment variable. If this is empty, a error will be raised.
samer@0 20
samer@0 21 global DBROOT
samer@0 22 global HOSTNAME
samer@0 23
samer@0 24 if nargin>=1,
samer@0 25 DBROOT=newroot;
samer@0 26 if nargin<2, newhost=getenv('HOSTNAME'); end
samer@0 27 if isempty(newhost)
samer@0 28 error('dbroot:nohostname','Could not get host name');
samer@0 29 end
samer@0 30 HOSTNAME=[newhost filesep];
samer@0 31 else
samer@0 32 % no input arguments so return current values
samer@0 33 p=DBROOT;
samer@0 34 h=HOSTNAME;
samer@0 35 end
samer@0 36
samer@0 37