From 627399f7604818438f9840daca4dd587fd91650a Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Tue, 7 Dec 2010 18:45:21 -0800 Subject: [PATCH] logging: create_symlink:sometimes use rel symlinks Signed-off-by: Colin McCabe --- src/common/DoutStreambuf.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/DoutStreambuf.cc b/src/common/DoutStreambuf.cc index a8a7818feafb2..77fb9a31f1b5b 100644 --- a/src/common/DoutStreambuf.cc +++ b/src/common/DoutStreambuf.cc @@ -135,8 +135,14 @@ static std::string get_dirname(const std::string &filename) return filename.substr(0, last_slash); } -static int create_symlink(const string &oldpath, const string &newpath) +static int create_symlink(string oldpath, const string &newpath) { + // Create relative symlink if the files are in the same directory + if (get_dirname(oldpath) == get_dirname(newpath)) { + oldpath = string("./") + get_basename(oldpath); + cerr << "setting oldpath = '" << oldpath << "'" << std::endl; + } + while (1) { if (::symlink(oldpath.c_str(), newpath.c_str()) == 0) return 0; -- 2.39.5