diff --git a/db/durop.cpp b/db/durop.cpp index 8509ea20315..241146290f8 100644 --- a/db/durop.cpp +++ b/db/durop.cpp @@ -94,7 +94,7 @@ namespace mongo { log.read(_len); // size of file, not length of name string s; log.readStr(s); - _p._p = path(s); + _p._p = s; } void FileCreatedOp::_serialize(AlignedBuilder& ab) { diff --git a/dbtests/basictests.cpp b/dbtests/basictests.cpp index abefe1a0225..82db47adcad 100644 --- a/dbtests/basictests.cpp +++ b/dbtests/basictests.cpp @@ -24,6 +24,7 @@ #include "../util/array.h" #include "../util/text.h" #include "../util/queue.h" +#include "../util/paths.h" namespace BasicTests { @@ -552,6 +553,22 @@ namespace BasicTests { } }; + class RelativePathTest { + public: + void run(){ + RelativePath a = RelativePath::fromRelativePath( "a" ); + RelativePath b = RelativePath::fromRelativePath( "a" ); + RelativePath c = RelativePath::fromRelativePath( "b" ); + RelativePath d = RelativePath::fromRelativePath( "a/b" ); + + + ASSERT( a == b ); + ASSERT( a != c ); + ASSERT( a != d ); + ASSERT( c != d ); + } + }; + class All : public Suite { public: All() : Suite( "basic" ){ @@ -585,6 +602,7 @@ namespace BasicTests { add< StrTests >(); add< HostAndPortTests >(); + add< RelativePathTest >(); } } myall; diff --git a/util/paths.h b/util/paths.h index 01c37490719..98fb33c1bb5 100644 --- a/util/paths.h +++ b/util/paths.h @@ -30,10 +30,10 @@ namespace mongo { checking. if you want to say 'my param MUST be a relative path", use this. */ struct RelativePath { - path _p; + string _p; - static RelativePath fromRelativePath(path f) { - RelativePath rp; + static RelativePath fromRelativePath(string f) { + RelativePath rp; rp._p = f; return rp; } @@ -48,12 +48,12 @@ namespace mongo { if( str::startsWith(relative, "/") || str::startsWith(relative, "\\") ) { relative.erase(0, 1); } - RelativePath rp; + RelativePath rp; rp._p = relative; return rp; } - string toString() const { return _p.string(); } + string toString() const { return _p; } inline bool operator!=(const RelativePath& r) const { return _p != r._p; } inline bool operator==(const RelativePath& r) const { return _p == r._p; }