function file = get_user_file(user)

% get_user_file - get user file name
% ----------------------------------
%
% file = get_user_file(user)
%
%      = get_user_file(name)
%
% Input:
% ------
%  user - user
%  name - name
%
% Output:
% -------
%  file - user file name

switch (class(user))
	
	case ('char')
		
		name = user;
		
		if (~proper_filename(name))
			error('User name must be a proper filename.');
		end
		
	case ('struct')
		
		if (~isfield(user,'name'))
			error('Input does not seem to be user.');
		end
		
		name = user.name;
		
	otherwise, error('User input must be user or user name.');
		
end

file = [users_root, filesep, name, filesep, name, '.mat'];