From a7a53921e44e33a442d9367c906fa19e9e47ab96 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Wed, 30 Dec 2020 18:08:00 +0000 Subject: [PATCH] simgear/misc/sg_path.*: added SGPath::makeLink(), for making softlinks. Note that on Windows there is no implementation yet and it always returns false. --- simgear/misc/sg_path.cxx | 12 ++++++++++++ simgear/misc/sg_path.hxx | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/simgear/misc/sg_path.cxx b/simgear/misc/sg_path.cxx index 9e74bafc..eead1790 100644 --- a/simgear/misc/sg_path.cxx +++ b/simgear/misc/sg_path.cxx @@ -1108,3 +1108,15 @@ bool SGPath::touch() _cached = false; return true; } + +bool SGPath::makeLink(const std::string& destination) +{ + #ifdef SG_WINDOWS + return false; + #else + if (symlink(destination.c_str(), c_str())) { + return false; + } + return true; + #endif +} diff --git a/simgear/misc/sg_path.hxx b/simgear/misc/sg_path.hxx index 205759a1..2ebfa5b5 100644 --- a/simgear/misc/sg_path.hxx +++ b/simgear/misc/sg_path.hxx @@ -289,6 +289,11 @@ public: */ bool touch(); + /** + * Create a link with this path that points to . + */ + bool makeLink(const std::string& destination); + enum StandardLocation { HOME,