Fix compilation with C++17

This commit is contained in:
Gioacchino Mazzurco 2021-08-06 12:15:34 +02:00
parent 282f4f18a3
commit 8bed99cc9f
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051

View File

@ -4,8 +4,8 @@
* libretroshare: retroshare core library *
* *
* Copyright (C) 2004-2007 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2020 Gioacchino Mazzurco <gio@eigenlab.org> *
* Copyright (C) 2020 Asociación Civil Altermundi <info@altermundi.net> *
* Copyright (C) 2020-2021 Gioacchino Mazzurco <gio@eigenlab.org> *
* Copyright (C) 2020-2021 Asociación Civil Altermundi <info@altermundi.net> *
* *
* 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 <filesystem>
#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__)