diff --git a/db/database.h b/db/database.h index 68b45cd4942..0b802eb05c7 100644 --- a/db/database.h +++ b/db/database.h @@ -26,7 +26,7 @@ namespace mongo { class Database { public: - Database(const char *nm, bool& newDb, const char *_path = dbpath) : + Database(const char *nm, bool& newDb, const string& _path = dbpath) : name(nm), path(_path), namespaceIndex( path, name ) diff --git a/db/db.cpp b/db/db.cpp index 42bdce184f0..074cb1b3d7a 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -588,7 +588,7 @@ int main(int argc, char* argv[], char *envp[] ) show_help_text(visible_options); return 0; } - dbpath = params["dbpath"].as().c_str(); + dbpath = params["dbpath"].as(); if (params.count("quiet")) { quiet = true; } @@ -748,7 +748,7 @@ int main(int argc, char* argv[], char *envp[] ) return 0; } - #if defined(_WIN32) +#if defined(_WIN32) if ( installService ) { if ( !ServiceController::installService( L"MongoDB", L"Mongo DB", L"Mongo DB Server", argc, argv ) ) dbexit( EXIT_NTSERVICE_ERROR ); @@ -764,8 +764,9 @@ int main(int argc, char* argv[], char *envp[] ) dbexit( EXIT_NTSERVICE_ERROR ); dbexit( EXIT_CLEAN ); } - #endif - } else { +#endif + } + else { cout << dbExecCommand << " --help for help and startup options" << endl; cout << endl; } diff --git a/db/db.h b/db/db.h index c43376476c8..7961b853587 100644 --- a/db/db.h +++ b/db/db.h @@ -120,14 +120,14 @@ namespace mongo { extern const char *curNs; extern bool master; - inline string getKey( const char *ns, const char *path ) { + inline string getKey( const char *ns, const string& path ) { char cl[256]; nsToClient(ns, cl); return string( cl ) + ":" + path; } /* returns true if the database ("database") did not exist, and it was created on this call */ - inline bool setClient(const char *ns, const char *path=dbpath) { + inline bool setClient(const char *ns, const string& path=dbpath) { /* we must be in critical section at this point as these are global variables. */ @@ -167,10 +167,10 @@ namespace mongo { // shared functionality for removing references to a database from this program instance // does not delete the files on disk - void closeClient( const char *cl, const char *path = dbpath ); + void closeClient( const char *cl, const string& path = dbpath ); /* remove database from the databases map */ - inline void eraseDatabase( const char *ns, const char *path=dbpath ) { + inline void eraseDatabase( const char *ns, const string& path=dbpath ) { string key = getKey( ns, path ); databases.erase( key ); } diff --git a/db/instance.cpp b/db/instance.cpp index 744f52411f3..74b0712cb87 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -290,7 +290,7 @@ namespace mongo { /* cl - database name path - db directory */ - void closeClient( const char *cl, const char *path ) { + void closeClient( const char *cl, const string& path ) { assert( database ); assert( database->name == cl ); if ( string("local") != cl ) { diff --git a/db/namespace.h b/db/namespace.h index 2e986d323d0..bcc56cb7ef2 100644 --- a/db/namespace.h +++ b/db/namespace.h @@ -550,7 +550,7 @@ namespace mongo { string database_; }; - extern const char *dbpath; + extern string dbpath; // Rename a namespace within current 'client' db. // (Arguments should include db name) diff --git a/db/pdfile.cpp b/db/pdfile.cpp index a28d658fea1..8d69926d402 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -44,7 +44,7 @@ namespace mongo { extern bool quota; extern int port; - const char *dbpath = "/data/db/"; + string dbpath = "/data/db/"; DataFileMgr theDataFileMgr; map databases; @@ -1404,7 +1404,7 @@ assert( !eloc.isNull() ); return r; } - void DataFileMgr::init(const char *dir) { + void DataFileMgr::init(const string& path ) { /* boost::filesystem::path path( dir ); path /= "temp.dat"; string pathString = path.string(); @@ -1519,7 +1519,7 @@ namespace mongo { boost::intmax_t freeSpace() { #if !defined(_WIN32) struct statvfs info; - assert( !statvfs( dbpath, &info ) ); + assert( !statvfs( dbpath.c_str() , &info ) ); return boost::intmax_t( info.f_bavail ) * info.f_frsize; #else return -1; @@ -1583,7 +1583,7 @@ namespace mongo { return true; } - void _applyOpToDataFiles( const char *database, FileOp &fo, bool afterAllocator, const char *path ) { + void _applyOpToDataFiles( const char *database, FileOp &fo, bool afterAllocator, const string& path ) { if ( afterAllocator ) theFileAllocator().waitUntilFinished(); string c = database; diff --git a/db/pdfile.h b/db/pdfile.h index bcf74490736..2672c008c22 100644 --- a/db/pdfile.h +++ b/db/pdfile.h @@ -94,7 +94,7 @@ namespace mongo { class DataFileMgr { friend class BasicCursor; public: - void init(const char *); + void init(const string& path ); void update( const char *ns, @@ -377,7 +377,7 @@ namespace mongo { virtual const char * op() const = 0; }; - void _applyOpToDataFiles( const char *database, FileOp &fo, bool afterAllocator = false, const char *path = dbpath ); + void _applyOpToDataFiles( const char *database, FileOp &fo, bool afterAllocator = false, const string& path = dbpath ); inline void _deleteDataFiles(const char *database) { class : public FileOp { diff --git a/dbtests/dbtests.cpp b/dbtests/dbtests.cpp index b861686574b..5ef7113a4b2 100644 --- a/dbtests/dbtests.cpp +++ b/dbtests/dbtests.cpp @@ -33,7 +33,7 @@ using namespace std; namespace mongo { - extern const char* dbpath; + extern string dbpath; } // namespace mongo string dbpathSpec = "/tmp/unittest/"; diff --git a/dbtests/perf/perftest.cpp b/dbtests/perf/perftest.cpp index aa3d047a831..373296ac2aa 100644 --- a/dbtests/perf/perftest.cpp +++ b/dbtests/perf/perftest.cpp @@ -30,7 +30,7 @@ #include namespace mongo { - extern const char* dbpath; + extern string dbpath; } // namespace mongo // Very useful function, hacky way of getting at at.