/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
string  home_dir;
static string current_path;

string  invalid_path()
{
    write( "Invalid path.\n" );
    return 0;
}				/* invalid_path() */

string  get_path( string str )
{
    string *array, *array1, temp, temp1;
    int     i, j;

    if( !str )
    {
	if( !home_dir )
	{
	    home_dir = "/w/" + this_player()->query_name();
	}
	str = home_dir;
    }
    if( str == "~" )
    {
	str = "w/" + this_player()->query_name();
    }
    else
    {
	if( str[ 0 ] == '~' )
	{
	    if( str[ 1 ] == '/' )
	    {
		sscanf( str, "~%s", temp );
		str = "/w/" + this_player()->query_name() + temp;
	    }
	    else
	    {
		string  name;

		if( sscanf( str, "~%s/%s", name, str ) != 2 )
		{
		    name = extract( str, 1 );
		    str = "w/" + name;
		}
		else
/* cheat at this point and just assume they are a wizard. sigh i kno i know */
		    str = "w/" + name + "/" + str;
	    }
	}
	else
	    if( str[ 0 ] != '/' )
		str = current_path + "/" + str + "/";
	if( str == "/" )
	    return "/";
	else
	    array = explode( str, "/" ) - ({ "" });
	for( i = 0; i < sizeof( array ); i++ )
	    if( array[ i ] == ".." )
	    {
		if( i < 1 )
		    return invalid_path();
		if( i == 1 )
		    array1 = ({ "." });
		else
		    array1 = array[ 0..i - 2 ];
		if( i + 1 <= sizeof( array ) - 1 )
		    array1 += array[ i + 1..sizeof( array ) - 1 ];
		array = array1;
		i -= 2;
	    }
	    else
		if( array[ i ] == "." )
		    array[ i ] = 0;
	if( array )
	    str = implode( array, "/" );
	else
	    str = "";
    }
    return "/" + str;
}				/* get_path() */

static string *get_files( string str )
{
    int     loop, count;
    string *filenames, rmpath, temp1, temp2, *names, *files;

    names = explode( str, " " ) - ({ "" });
    if( sizeof( names ) == 0 )
    {
	return({ });
    }
    filenames = ({ });
    for( count = 0; count < sizeof( names ); count++ )
    {
	str = names[ count ];
	str = rmpath = get_path( str );
	if( rmpath == "/" )
	{
	    filenames += ({ "/" });
	    continue;
	}
	if( sscanf( rmpath, "%s/%s", temp1, temp2 ) == 2 )
	{
	    string *path_elements;

	    path_elements = explode( rmpath, "/" ) - ({ "" });
	    rmpath = implode( path_elements[ 0..sizeof( path_elements ) - 2 ], "/" );
	}
	files = get_dir( str );

	if( files )
	{
	    int     loop2;

	    for( loop2 = 0; loop2 < sizeof( files ); loop2++ )
	    {
		filenames += ({ rmpath + "/" + files[ loop2 ] });
	    }
	}
    }
    for( loop = 0; loop < sizeof( filenames ); loop++ )
    {
	if( filenames[ loop ][ 0 ] != '/' )
	{
	    filenames[ loop ] = "/" + filenames[ loop ];
	}
    }
    return filenames;
}

/* Changed to be *.* so as to handle virtual wombles as well */
string *get_cfiles( string str )
{
    int     loop;
    string  temp, *names, temp2;

    names = explode( str, " " ) - ({ "" });
    for( loop = 0; loop < sizeof( names ); loop++ )
    {
	if( sscanf( names[ loop ], "%s.%s", temp, temp2 ) != 2 )
	{
	    names[ loop ] += ".c";
	}
    }
    str = implode( names, " " );
    return get_files( str );
}				/* get_cfiles() */

string  query_current_path()
{
    return current_path;
}