tilde_path.c

tmi2_fluffos_v2/lib/adm/simul_efun/tilde_path.c · 623 B

From the archive tmi2_fluffos_v2.zip

Download the archive   « Back to the archive contents

/*
 * tilde_path.c
 *
 * Written: 921226 by Zak.
 * Attempts to reduce a given path into '~' format
 * 930320, Zak: added default for `name', idea from Pallando.
 */


string tilde_path(string path, string name)
{
    string wiz, rest;

    if(!path)
	return "";
    if ( !name && this_player() )
        name = geteuid( this_player() );
    if (sscanf(path, "/u/%*s/%s", rest) == 2)
    {
	if (sscanf(rest, "%s/%s", wiz, rest) != 2)
	{
	    wiz = rest;
	    rest = "";
	}
	else
	    rest = "/" + rest;
	if (wiz == name)
	    path = "~" + rest;
	else
	    path = "~" + wiz + rest;
    }
    return path;
} /* tilde_path */

Site Stats

Snippets: 1791
Codebases: 571