mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 09:06:21 +01:00
don't use path for RelativePath, just use string so boost isn't loaded at static init time
This commit is contained in:
parent
c4ea46b1e7
commit
166e3df928
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
10
util/paths.h
10
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; }
|
||||
|
Loading…
Reference in New Issue
Block a user