*/
#include <iostream>
-#include "zypp/base/String.h"
-#include "zypp/Pathname.h"
-#include "zypp/Url.h"
+#include <zypp/base/String.h>
+#include <zypp/Pathname.h>
+#include <zypp/Url.h>
using std::string;
return Pathname();
Pathname ret_t( name_r );
- string::size_type idx = ret_t._name.find_last_of( '/' );
+ std::string::size_type idx = ret_t._name.find_last_of( '/' );
- if ( idx == string::npos ) {
+ if ( idx == std::string::npos ) {
ret_t._name = ".";
} else if ( idx == 0 ) {
ret_t._name = "/";
return string();
string ret_t( name_r.asString() );
- string::size_type idx = ret_t.find_last_of( '/' );
- if ( idx != string::npos && ( idx != 0 || ret_t.size() != 1 ) ) {
+ std::string::size_type idx = ret_t.find_last_of( '/' );
+ if ( idx != std::string::npos && ( idx != 0 || ret_t.size() != 1 ) ) {
ret_t.erase( 0, idx+1 );
}
return string();
string base( basename( name_r ) );
- string::size_type pos = base.rfind( '.' );
+ std::string::size_type pos = base.rfind( '.' );
switch ( pos )
{
case 0:
if ( base.size() == 2 && base[0] == '.' ) // ..
return string();
break;
- case string::npos:
+ case std::string::npos:
return string();
break;
}
return root_r / path_r;
}
+ Pathname Pathname::stripprefix( const Pathname & root_r, const Pathname & path_r )
+ {
+ if ( root_r.emptyOrRoot() )
+ return path_r;
+ if ( root_r == path_r )
+ return "/";
+ std::string rest( str::stripPrefix( path_r.asString(), root_r.asString() ) );
+ if ( rest[0] == '/' ) // needs to be a dir prefix!
+ return rest;
+ return path_r;
+ }
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Pathname::cat