Synopsis - Cross-Reference
File: /src/Support/Path.cc1// 2// Copyright (C) 2004 Stefan Seefeld 3// All rights reserved. 4// Licensed to the public under the terms of the GNU LGPL (>= 2), 5// see the file COPYING for details. 6// 7 8#include "Path.hh" 9 10#ifdef _WIN32 11# include "Path-win32.cc" 12#else 13# include "Path-posix.cc" 14#endif 15 16using namespace Synopsis; 17 18std::string Path::basename() const 19{ 20 if (my_impl.empty()) return ""; 21 std::string::size_type i = my_impl.rfind(Path::SEPARATOR); 22 return i == std::string::npos ? my_impl : my_impl.substr(i + 1); 23} 24 25Path Path::dirname() const 26{ 27 if (my_impl.empty()) return Path(""); 28 std::string::size_type i = my_impl.rfind(Path::SEPARATOR); 29 return i == std::string::npos ? Path("") : Path(my_impl.substr(0, i)); 30} 31 32void Path::strip(const std::string &prefix) 33{ 34 if (prefix.empty()) return; 35 if (prefix == my_impl.substr(0, prefix.size())) 36 my_impl = my_impl.substr(prefix.size()); 37} 38