From 166e3df9286542d5718239ea437b3a11e97c7a98 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Sun, 19 Dec 2010 00:56:44 -0500 Subject: [PATCH] don't use path for RelativePath, just use string so boost isn't loaded at static init time --- db/durop.cpp | 2 +- dbtests/basictests.cpp | 18 ++++++++++++++++++ util/paths.h | 10 +++++----- 3 files changed, 24 insertions(+), 6 deletions(-) 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; }