From f42fa9a604f9f4faa1addd1b02c491cd0fe59736 Mon Sep 17 00:00:00 2001
From: "grover92000@gmail.com" <grover92000@gmail.com>
Date: Sat, 20 Apr 2024 13:29:24 -0400
Subject: [PATCH] Changes for boost-1.85

---
 src/core/common/avatarmanager.cpp             | 49 +++++++++++++++++++
 src/core/common/loghelper_server.cpp          |  4 ++
 src/engine/log.cpp                            |  4 ++
 src/engine/log.h                              |  4 ++
 .../qt/qttools/nonqthelper/nonqthelper.cpp    |  8 +++
 src/net/common/clientstate.cpp                | 19 +++++++
 src/net/common/clientthread.cpp               |  4 ++
 src/net/common/downloaderthread.cpp           |  8 +++
 src/net/common/serverlobbythread.cpp          |  8 +++
 src/net/common/uploaderthread.cpp             |  4 ++
 src/pokerth_server.cpp                        |  4 ++
 11 files changed, 116 insertions(+)

diff --git a/src/core/common/avatarmanager.cpp b/src/core/common/avatarmanager.cpp
index d137a5c44..9b2f4abaa 100644
--- a/src/core/common/avatarmanager.cpp
+++ b/src/core/common/avatarmanager.cpp
@@ -87,20 +87,36 @@ AvatarManager::Init(const string &dataDir, const string &cacheDir)
 	path tmpDataPath(dataDir);
 	{
 		boost::mutex::scoped_lock lock(m_cacheDirMutex);
+#if BOOST_VERSION < 108500
 		m_cacheDir = tmpCachePath.directory_string();
+#else
+		m_cacheDir = tmpCachePath.string();
+#endif
 	}
 	{
 		boost::mutex::scoped_lock lock(m_avatarsMutex);
+#if BOOST_VERSION < 108500
 		tmpRet = InternalReadDirectory((tmpDataPath / "gfx/avatars/default/people/").directory_string(), m_avatars);
+#else
+		tmpRet = InternalReadDirectory((tmpDataPath / "gfx/avatars/default/people/").string(), m_avatars);
+#endif
 		retVal = retVal && tmpRet;
+#if BOOST_VERSION < 108500
 		tmpRet = InternalReadDirectory((tmpDataPath / "gfx/avatars/default/misc/").directory_string(), m_avatars);
+#else
+		tmpRet = InternalReadDirectory((tmpDataPath / "gfx/avatars/default/misc/").string(), m_avatars);
+#endif
 		retVal = retVal && tmpRet;
 	}
 	if (cacheDir.empty() || tmpCachePath.empty())
 		LOG_ERROR("Cache directory was not set!");
 	else {
 		boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
+#if BOOST_VERSION < 108500
 		tmpRet = InternalReadDirectory(tmpCachePath.directory_string(), m_cachedAvatars);
+#else
+		tmpRet = InternalReadDirectory(tmpCachePath.string(), m_cachedAvatars);
+#endif
 		retVal = retVal && tmpRet;
 	}
 
@@ -113,7 +129,11 @@ AvatarManager::AddSingleAvatar(const std::string &fileName)
 {
 	bool retVal = false;
 	path filePath(fileName);
+#if BOOST_VERSION < 108500
 	string tmpFileName(filePath.file_string());
+#else
+	string tmpFileName(filePath.string());
+#endif
 
 	if (!fileName.empty() && !tmpFileName.empty()) {
 		unsigned outFileSize = 0;
@@ -240,7 +260,11 @@ AvatarManager::GetAvatarFileType(const string &fileName)
 	AvatarFileType fileType;
 
 	path filePath(fileName);
+#if BOOST_VERSION < 108500
 	string ext(extension(filePath));
+#else
+	string ext(filePath.extension().string());
+#endif
 	if (boost::algorithm::iequals(ext, ".png"))
 		fileType = AVATAR_FILE_TYPE_PNG;
 	else if (boost::algorithm::iequals(ext, ".jpg") || boost::algorithm::iequals(ext, ".jpeg"))
@@ -362,7 +386,11 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
 			if (IsValidAvatarFileType(avatarFileType, data, size)) {
 				path tmpPath(cacheDir);
 				tmpPath /= (md5buf.ToString() + ext);
+#if BOOST_VERSION < 108500
 				string fileName(tmpPath.file_string());
+#else
+				string fileName(tmpPath.string());
+#endif
 				std::ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
 				if (!o.fail()) {
 					o.write((const char *)data, size);
@@ -426,7 +454,11 @@ AvatarManager::RemoveOldAvatarCacheEntries()
 	}
 	try {
 		path cachePath(cacheDir);
+#if BOOST_VERSION < 108500
 		cacheDir = cachePath.directory_string();
+#else
+		cacheDir = cachePath.string();
+#endif
 		// Never delete anything if we do not have a special cache dir set.
 		if (!cacheDir.empty()) {
 			boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
@@ -441,12 +473,20 @@ AvatarManager::RemoveOldAvatarCacheEntries()
 				while (i != end) {
 					bool keepFile = false;
 					path filePath(i->second);
+#if BOOST_VERSION < 108500
 					string fileString(filePath.file_string());
+#else
+					string fileString(filePath.string());
+#endif
 					// Only consider files which are definitely in the cache dir.
 					if (fileString.size() > cacheDir.size() && fileString.substr(0, cacheDir.size()) == cacheDir) {
 						// Only consider files with MD5 as file name.
 						MD5Buf tmpBuf;
+#if BOOST_VERSION < 108500
 						if (exists(filePath) && tmpBuf.FromString(basename(filePath))) {
+#else
+						if (exists(filePath) && tmpBuf.FromString(filePath.stem().string())) {
+#endif
 							timeMap.insert(TimeAvatarMap::value_type(last_write_time(filePath), i->first));
 							keepFile = true;
 						}
@@ -520,10 +560,19 @@ AvatarManager::InternalReadDirectory(const std::string &dir, AvatarMap &avatars)
 			directory_iterator end;
 
 			while (i != end) {
+#if BOOST_VERSION < 108500
 				if (is_regular(i->status())) {
 					string md5sum(basename(i->path()));
+#else
+				if (is_regular_file(i->status())) {
+					string md5sum(i->path().stem().string());
+#endif
 					MD5Buf md5buf;
+#if BOOST_VERSION < 108500
 					string fileName(i->path().file_string());
+#else
+					string fileName(i->path().string());
+#endif
 					if (md5buf.FromString(md5sum)) {
 						// Only consider files with md5sum as name.
 						avatars.insert(AvatarMap::value_type(md5buf, fileName));
diff --git a/src/core/common/loghelper_server.cpp b/src/core/common/loghelper_server.cpp
index a0d0350ed..f3e8366b2 100644
--- a/src/core/common/loghelper_server.cpp
+++ b/src/core/common/loghelper_server.cpp
@@ -59,7 +59,11 @@ loghelper_init(const string &logDir, int logLevel)
 	path tmpLogFile(logDir);
 	tmpLogFile /= SERVER_MSG_LOG_FILE_NAME;
 
+#if BOOST_VERSION < 108500
 	g_logFile = tmpLogFile.directory_string();
+#else
+	g_logFile = tmpLogFile.string();
+#endif
 	g_logLevel = logLevel;
 }
 
diff --git a/src/engine/log.cpp b/src/engine/log.cpp
index 1f50fde2e..c6fe7f8e1 100644
--- a/src/engine/log.cpp
+++ b/src/engine/log.cpp
@@ -84,7 +84,11 @@ Log::init()
 				mySqliteLogFileName /= string("pokerth-log-") + curDateTime + ".pdb";
 
 				// open sqlite-db
+#if BOOST_VERSION < 108500
 				sqlite3_open(mySqliteLogFileName.directory_string().c_str(), &mySqliteLogDb);
+#else
+				sqlite3_open(mySqliteLogFileName.string().c_str(), &mySqliteLogDb);
+#endif
 				if( mySqliteLogDb != 0 ) {
 
 					int i;
diff --git a/src/engine/log.h b/src/engine/log.h
index 7dbf2514d..0a79c5377 100644
--- a/src/engine/log.h
+++ b/src/engine/log.h
@@ -73,7 +73,11 @@ class Log
 
 	std::string getMySqliteLogFileName()
 	{
+#if BOOST_VERSION < 108500
 		return mySqliteLogFileName.directory_string();
+#else
+		return mySqliteLogFileName.string();
+#endif
 	}
 
 private:
diff --git a/src/gui/qt/qttools/nonqthelper/nonqthelper.cpp b/src/gui/qt/qttools/nonqthelper/nonqthelper.cpp
index 2acfeeb45..bdc625b4a 100644
--- a/src/gui/qt/qttools/nonqthelper/nonqthelper.cpp
+++ b/src/gui/qt/qttools/nonqthelper/nonqthelper.cpp
@@ -65,7 +65,15 @@ std::string
 NonQtHelper::getDataPathStdString(const char *argv0)
 {
 	boost::filesystem::path startPath(argv0);
+#if BOOST_VERSION < 108500
 	startPath = startPath.remove_leaf();
+#else
+	startPath = startPath.remove_filename();
+#endif
 	startPath /= "data";
+#if BOOST_VERSION < 108500
 	return stringToUtf8(startPath.directory_string());
+#else
+	return stringToUtf8(startPath.string());
+#endif
 }
diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp
index d7fc7285a..9d35e99ff 100644
--- a/src/net/common/clientstate.cpp
+++ b/src/net/common/clientstate.cpp
@@ -211,7 +211,11 @@ ClientStateStartServerListDownload::Enter(boost::shared_ptr<ClientThread> client
 	} else {
 		// Download the server list.
 		boost::shared_ptr<DownloadHelper> downloader(new DownloadHelper);
+#if BOOST_VERSION < 108500
 		downloader->Init(client->GetContext().GetServerListUrl(), tmpServerListPath.directory_string());
+#else
+		downloader->Init(client->GetContext().GetServerListUrl(), tmpServerListPath.string());
+#endif
 		ClientStateDownloadingServerList::Instance().SetDownloadHelper(downloader);
 		client->SetState(ClientStateDownloadingServerList::Instance());
 	}
@@ -303,13 +307,24 @@ ClientStateReadingServerList::Enter(boost::shared_ptr<ClientThread> client)
 	path zippedServerListPath(context.GetCacheDir());
 	zippedServerListPath /= context.GetServerListUrl().substr(context.GetServerListUrl().find_last_of('/') + 1);
 	path xmlServerListPath;
+#if BOOST_VERSION < 108500
 	if (extension(zippedServerListPath) == ".z") {
 		xmlServerListPath = change_extension(zippedServerListPath, "");
+#else
+	if (zippedServerListPath.extension().string() == ".z") {
+		xmlServerListPath = zippedServerListPath;
+		xmlServerListPath.replace_extension("");
+#endif
 
 		// Unzip the file using zlib.
 		try {
+#if BOOST_VERSION < 108500
 			std::ifstream inFile(zippedServerListPath.directory_string().c_str(), ios_base::in | ios_base::binary);
 			std::ofstream outFile(xmlServerListPath.directory_string().c_str(), ios_base::out | ios_base::trunc);
+#else
+			std::ifstream inFile(zippedServerListPath.string().c_str(), ios_base::in | ios_base::binary);
+			std::ofstream outFile(xmlServerListPath.string().c_str(), ios_base::out | ios_base::trunc);
+#endif
 			boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
 			in.push(boost::iostreams::zlib_decompressor());
 			in.push(inFile);
@@ -321,7 +336,11 @@ ClientStateReadingServerList::Enter(boost::shared_ptr<ClientThread> client)
 		xmlServerListPath = zippedServerListPath;
 
 	// Parse the server address.
+#if BOOST_VERSION < 108500
 	TiXmlDocument doc(xmlServerListPath.directory_string());
+#else
+	TiXmlDocument doc(xmlServerListPath.string());
+#endif
 
 	if (doc.LoadFile()) {
 		client->ClearServerInfoMap();
diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp
index dee5daf68..e24413d14 100644
--- a/src/net/common/clientthread.cpp
+++ b/src/net/common/clientthread.cpp
@@ -977,7 +977,11 @@ ClientThread::GetCacheServerListFileName()
 	size_t pos = serverListUrl.find_last_of('/');
 	if (!GetContext().GetCacheDir().empty() && !serverListUrl.empty() && pos != string::npos && ++pos < serverListUrl.length()) {
 		tmpServerListPath /= serverListUrl.substr(pos);
+#if BOOST_VERSION < 108500
 		fileName = tmpServerListPath.directory_string();
+#else
+		fileName = tmpServerListPath.string();
+#endif
 	}
 	return fileName;
 }
diff --git a/src/net/common/downloaderthread.cpp b/src/net/common/downloaderthread.cpp
index 56a9526ec..7984cb410 100644
--- a/src/net/common/downloaderthread.cpp
+++ b/src/net/common/downloaderthread.cpp
@@ -96,7 +96,11 @@ DownloaderThread::Main()
 				// Previous download was finished.
 				if (m_curDownloadData) {
 					path filepath(m_curDownloadData->filename);
+#if BOOST_VERSION < 108500
 					std::ifstream instream(filepath.file_string().c_str(), ios_base::in | ios_base::binary);
+#else
+					std::ifstream instream(filepath.string().c_str(), ios_base::in | ios_base::binary);
+#endif
 					// Find out file size.
 					// Not fully portable, but works on win/linux/mac.
 					instream.seekg(0, ios_base::beg);
@@ -132,7 +136,11 @@ DownloaderThread::Main()
 				}
 				if (m_curDownloadData && !m_curDownloadData->filename.empty()) {
 					path filepath(m_curDownloadData->filename);
+#if BOOST_VERSION < 108500
 					m_downloadHelper->Init(m_curDownloadData->address, filepath.file_string());
+#else
+					m_downloadHelper->Init(m_curDownloadData->address, filepath.string());
+#endif
 					m_downloadInProgress = true;
 				}
 			}
diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp
index 1cb341eaa..d3964895d 100644
--- a/src/net/common/serverlobbythread.cpp
+++ b/src/net/common/serverlobbythread.cpp
@@ -277,7 +277,11 @@ ServerLobbyThread::Init(const string &logDir)
 		boost::filesystem::path logPath(logDir);
 		if (!logDir.empty()) {
 			logPath /= SERVER_STATISTICS_FILE_NAME;
+#if BOOST_VERSION < 108500
 			m_statisticsFileName = logPath.directory_string();
+#else
+			m_statisticsFileName = logPath.string();
+#endif
 			ReadStatisticsFile();
 		}
 	}
@@ -1264,7 +1268,11 @@ ServerLobbyThread::HandleNetPacketAvatarEnd(boost::shared_ptr<SessionData> sessi
 				// Init finished - start session.
 				EstablishSession(session);
 				LOG_MSG("Client \"" << session->GetClientAddr() << "\" uploaded avatar \""
+#if BOOST_VERSION < 108500
 						<< boost::filesystem::path(avatarFileName).file_string() << "\".");
+#else
+						<< boost::filesystem::path(avatarFileName).string() << "\".");
+#endif
 			} else
 				SessionError(session, ERR_NET_WRONG_AVATAR_SIZE);
 		}
diff --git a/src/net/common/uploaderthread.cpp b/src/net/common/uploaderthread.cpp
index f1eefea6c..ecf1436d9 100644
--- a/src/net/common/uploaderthread.cpp
+++ b/src/net/common/uploaderthread.cpp
@@ -94,7 +94,11 @@ UploaderThread::Main()
 						url += filepath.filename().string();
 #endif
 					}
+#if BOOST_VERSION < 108500
 					m_uploadHelper->Init(url, filepath.file_string(), data.user, data.pwd, data.filesize, data.httpPost);
+#else
+					m_uploadHelper->Init(url, filepath.string(), data.user, data.pwd, data.filesize, data.httpPost);
+#endif
 					m_uploadInProgress = true;
 				}
 			}
diff --git a/src/pokerth_server.cpp b/src/pokerth_server.cpp
index 450a47e9d..1ee0db80e 100644
--- a/src/pokerth_server.cpp
+++ b/src/pokerth_server.cpp
@@ -158,7 +158,11 @@ main(int argc, char *argv[])
 	if (pidFile.empty()) {
 		path tmpPidPath(myConfig->readConfigString("LogDir"));
 		tmpPidPath /= "pokerth.pid";
+#if BOOST_VERSION < 108500
 		pidFile = tmpPidPath.directory_string();
+#else
+		pidFile = tmpPidPath.string();
+#endif
 	}
 	{
 		std::ofstream pidStream(pidFile.c_str(), ios_base::out | ios_base::trunc);
