private void normalizePath()
{
if (path == null) return;
bool isAbs = pathStr.StartsWith("/");
bool isDir = pathStr.EndsWith("/");
bool dotLast = false;
bool modified = false;
for (int i=0; i<path.sz(); ++i)
{
string seg = (string)path.get(i);
if (seg == "." && (path.sz() > 1 || host != null))
{
path.removeAt(i);
modified = true;
dotLast = true;
i -= 1;
}
else if (seg == ".." && i > 0 && path.get(i-1).ToString() != "..")
{
path.removeAt(i);
path.removeAt(i-1);
modified = true;
i -= 2;
dotLast = true;
}
else
{
dotLast = false;
}
}
if (modified)
{
if (dotLast) isDir = true;
if (path.sz() == 0 || path.last().ToString() == "..") isDir = false;
pathStr = toPathStr(isAbs, path, isDir);
}
}