From da9753409b790325889afc8cb9be28c1ea309391 Mon Sep 17 00:00:00 2001 From: LingBin Date: Thu, 12 Oct 2023 19:35:52 +0800 Subject: [PATCH] fix(cleanup): ensure FLAGS_log_dir ends with '/' (#972) --- AUTHORS | 1 + CONTRIBUTORS | 1 + src/logging.cc | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 9d711ec..4b5ff02 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,6 +16,7 @@ Brian Silverman Dmitriy Arbitman Google Inc. Guillaume Dumont +LingBin Marco Wang Michael Tanner MiniLight diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 5780377..82aead9 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -36,6 +36,7 @@ HÃ¥kan L. S. Younes Ivan Penkov Jacob Trimble Jim Ray +LingBin Marco Wang Michael Darr Michael Tanner diff --git a/src/logging.cc b/src/logging.cc index 23295f5..a364e4f 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #ifdef HAVE_UNISTD_H @@ -2397,8 +2398,13 @@ const vector& GetLoggingDirectories() { logging_directories_list = new vector; if ( !FLAGS_log_dir.empty() ) { - // A dir was specified, we should use it - logging_directories_list->push_back(FLAGS_log_dir); + // Ensure the specified path ends with a directory delimiter. + if (std::find(std::begin(possible_dir_delim), std::end(possible_dir_delim), + FLAGS_log_dir.back()) == std::end(possible_dir_delim)) { + logging_directories_list->push_back(FLAGS_log_dir + "/"); + } else { + logging_directories_list->push_back(FLAGS_log_dir); + } } else { GetTempDirectories(logging_directories_list); #ifdef GLOG_OS_WINDOWS