/*
 * twpath - returns the absolute path to the root directory of the
 * current treewalk, if the clips are set right.
 *
 *	Copyright (C) 1989  Mike Meyer
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 1, or any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* Use the value we already calculated, if we can */
dir = getclip('tw.fullpath')
if dir ~= "" then return dir

/* Not there, got to work it out */
dir = getclip('tw.dirname')
if dir = "" then return ""		/* If no directory, punt */

dir = pragma('Directory', dir)		/* There and */
root = pragma('Directory', dir)		/* back again. */

/* Add the trailing slash if needed */
if right(root, 1) ~= ':' then root = root'/'

call setclip 'tw.fullpath', root
return root
