diff --git a/libretroshare/src/util/rsdir.cc b/libretroshare/src/util/rsdir.cc index 8556b8198..1a6375297 100644 --- a/libretroshare/src/util/rsdir.cc +++ b/libretroshare/src/util/rsdir.cc @@ -4,8 +4,8 @@ * libretroshare: retroshare core library * * * * Copyright (C) 2004-2007 Robert Fernie * - * Copyright (C) 2020 Gioacchino Mazzurco * - * Copyright (C) 2020 AsociaciĆ³n Civil Altermundi * + * Copyright (C) 2020-2021 Gioacchino Mazzurco * + * Copyright (C) 2020-2021 AsociaciĆ³n Civil Altermundi * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -64,6 +64,26 @@ * #define RSDIR_DEBUG 1 ****/ +#if __cplusplus < 201703L +bool std::filesystem::create_directories(const std::string& path) +{ + for( std::string::size_type lastIndex = 0; lastIndex < std::string::npos; + lastIndex = path.find('/', lastIndex) ) + { + std::string&& curDir = path.substr(0, ++lastIndex); + if(!RsDirUtil::checkCreateDirectory(curDir)) + { + RsErr() << __PRETTY_FUNCTION__ << " failure creating: " << curDir + << " of: " << path << std::endl; + return false; + } + } + return true; +} +#else +# include +#endif // __cplusplus < 201703L + std::string RsDirUtil::getTopDir(const std::string& dir) { std::string top; @@ -528,24 +548,6 @@ bool RsDirUtil::checkCreateDirectory(const std::string& dir) return true; } -#if __cplusplus < 201703L -bool std::filesystem::create_directories(const std::string& path) -{ - for( std::string::size_type lastIndex = 0; lastIndex < std::string::npos; - lastIndex = path.find('/', lastIndex) ) - { - std::string&& curDir = path.substr(0, ++lastIndex); - if(!RsDirUtil::checkCreateDirectory(curDir)) - { - RsErr() << __PRETTY_FUNCTION__ << " failure creating: " << curDir - << " of: " << path << std::endl; - return false; - } - } - return true; -} -#endif // __cplusplus < 201703L - std::string RsDirUtil::removeSymLinks(const std::string& path) { #if defined(WINDOWS_SYS) || defined(__APPLE__) || defined(__ANDROID__)