// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . //------------------------------------------------------------------------------------------------- // includes //------------------------------------------------------------------------------------------------- #include "stdpch.h" #include "nel/misc/sstring.h" //------------------------------------------------------------------------------------------------- // namespaces //------------------------------------------------------------------------------------------------- using namespace NLMISC; //----------------------------------------------------------------------------- // cleanPath - convert a path to standardised format //----------------------------------------------------------------------------- CSString cleanPath(const CSString& path,bool addTrailingSlash) { CSString result; // split the path up into its component elements CVectorSString pathComponents; path.unquoteIfQuoted().splitByOneOfSeparators("/\\",pathComponents,false,false,true,false,true); // iterate over path components collapsing '.' and '..' entries for (uint32 i=0;i::max()) { pathComponents[j].clear(); pathComponents[i].clear(); } continue; } } // treat the special case where original path started with a '/' or '//' if (path.left(1)=="/" || path.left(1)=="\\") { result= (path.left(2).right(1)=="/" || path.left(2).right(1)=="\\")? "//": "/"; } // concatenate the path bits for (uint32 i=0;i