summaryrefslogtreecommitdiff
path: root/src/mongo/db/server_options_helpers.cpp
diff options
context:
space:
mode:
authorKevin Pulo <kevin.pulo@mongodb.com>2016-08-16 22:08:49 +1000
committerKevin Pulo <kevin.pulo@mongodb.com>2016-08-16 22:10:46 +1000
commit512a1d57f6b3560cc3531355676cf06d362c93a1 (patch)
tree4a4c8585f07e48a6c3c6b009e28d65ea402c9e56 /src/mongo/db/server_options_helpers.cpp
parent51fe71a4169d8ac01dca915b482c94e228d8a746 (diff)
downloadmongo-512a1d57f6b3560cc3531355676cf06d362c93a1.tar.gz
SERVER-24914 SERVER-24915 improve getting cwd at server startup
Diffstat (limited to 'src/mongo/db/server_options_helpers.cpp')
-rw-r--r--src/mongo/db/server_options_helpers.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp
index 6956c8454f0..c82311f65a2 100644
--- a/src/mongo/db/server_options_helpers.cpp
+++ b/src/mongo/db/server_options_helpers.cpp
@@ -449,7 +449,7 @@ namespace {
// Helpers for option storage
Status setupBinaryName(const std::vector<std::string>& argv) {
if (argv.empty()) {
- return Status(ErrorCodes::InternalError, "Cannot get binary name: argv array is empty");
+ return Status(ErrorCodes::UnknownError, "Cannot get binary name: argv array is empty");
}
// setup binary name
@@ -463,13 +463,13 @@ Status setupBinaryName(const std::vector<std::string>& argv) {
Status setupCwd() {
// setup cwd
- char buffer[1024];
-#ifdef _WIN32
- verify(_getcwd(buffer, 1000));
-#else
- verify(getcwd(buffer, 1000));
-#endif
- serverGlobalParams.cwd = buffer;
+ boost::system::error_code ec;
+ boost::filesystem::path cwd = boost::filesystem::current_path(ec);
+ if (ec) {
+ return Status(ErrorCodes::UnknownError,
+ "Cannot get current working directory: " + ec.message());
+ }
+ serverGlobalParams.cwd = cwd.string();
return Status::OK();
}
@@ -730,7 +730,7 @@ Status canonicalizeServerOptions(moe::Environment* params) {
return Status::OK();
}
-Status storeServerOptions(const moe::Environment& params, const std::vector<std::string>& args) {
+Status setupServerOptions(const std::vector<std::string>& args) {
Status ret = setupBinaryName(args);
if (!ret.isOK()) {
return ret;
@@ -746,7 +746,11 @@ Status storeServerOptions(const moe::Environment& params, const std::vector<std:
return ret;
}
- ret = setParsedOpts(params);
+ return Status::OK();
+}
+
+Status storeServerOptions(const moe::Environment& params) {
+ Status ret = setParsedOpts(params);
if (!ret.isOK()) {
return ret;
}