static bool Canonize(nglString& rStr) { nglString canon; int32 len = rStr.GetLength(); int32 root_part = GetRootPart(rStr); int32 last_slash = root_part; int32 slash = 0; canon = rStr.GetLeft(root_part); while (slash < len) { slash = rStr.Find(_T('/'), last_slash); if (slash == - 1) slash = len; if (((slash - last_slash) == 1) && (rStr.GetChar(last_slash) == _T('.'))) { // Ignore '.' } else if (((slash - last_slash) == 2) && (!rStr.Compare(_T(".."), last_slash, 2))) { // Interpret '..' int32 prev_slash = canon.FindLast(_T('/')); if (prev_slash < root_part) prev_slash = root_part; if (!canon.IsEmpty() && canon.Compare(_T(".."), canon.GetLength() - 2, 2)) canon.Delete(prev_slash); else { if (canon.GetLength() > root_part) canon += _T('/'); canon += _T(".."); } } else { // Simply append path node nglString node = rStr.Extract(last_slash, (slash - last_slash)); if (canon.GetLength() > root_part) canon += _T('/'); canon += node; } last_slash = slash + 1; } rStr = canon; return true; }
nuiWidgetPtr nuiContainer::Find(const nglString& rName) { CheckValid(); int slash = rName.Find('/'); if (slash >= 0) { nglString path = rName.GetLeft(slash); nglString rest = rName.Extract(slash + 1); nuiWidgetPtr node = SearchForChild(path, false); return node ? node->Find(rest) : NULL; } else return SearchForChild(rName,false); }