|
From: Yoda-JM <yo...@us...> - 2011-05-23 16:07:09
|
Author: Vincent Le Ligeour <yo...@us...>
Date: Mon May 23 17:59:45 2011 +0200
Converted to boost::filesystem3
---
cmake/Modules/FindBoost.cmake | 2 +-
game/backgrounds.cc | 5 +++++
game/cache.cc | 4 ++++
game/filemagic.hh | 4 ++++
game/fs.cc | 4 ++++
game/songparser-ini.cc | 4 ++++
game/songparser.cc | 4 ++++
game/songs.cc | 5 +++++
tools/ss_helpers.hh | 4 ++++
9 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/cmake/Modules/FindBoost.cmake b/cmake/Modules/FindBoost.cmake
index 3fd02f7..4acd243 100644
--- a/cmake/Modules/FindBoost.cmake
+++ b/cmake/Modules/FindBoost.cmake
@@ -90,7 +90,7 @@ if (Boost_FOUND)
else()
# MESSAGE(STATUS "Finding Boost libraries.... ")
- SET( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.45" "1.44" "1.43" "1.42" "1.41" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.0" "1.36" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33")
+ SET( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.46" "1.45" "1.44" "1.43" "1.42" "1.41" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.0" "1.36" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33")
############################################
#
diff --git a/game/backgrounds.cc b/game/backgrounds.cc
index 7fd3cd0..cdedefb 100644
--- a/game/backgrounds.cc
+++ b/game/backgrounds.cc
@@ -55,8 +55,13 @@ void Backgrounds::reload_internal(fs::path const& parent) {
for (fs::directory_iterator dirIt(parent), dirEnd; m_loading && dirIt != dirEnd; ++dirIt) {
fs::path p = dirIt->path();
if (fs::is_directory(p)) { reload_internal(p); continue; }
+#if BOOST_FILESYSTEM_VERSION < 3
std::string name = p.leaf(); // File basename
std::string path = p.directory_string(); // Path without filename
+#else
+ std::string name = p.filename().string(); // File basename
+ std::string path = p.string(); // Path without filename
+#endif
path.erase(path.size() - name.size());
if (!regex_match(name.c_str(), match, expression)) continue;
{
diff --git a/game/cache.cc b/game/cache.cc
index 69974e2..0f1edd0 100644
--- a/game/cache.cc
+++ b/game/cache.cc
@@ -9,7 +9,11 @@ namespace cache {
fs::path constructSVGCacheFileName(fs::path const& svgfilename, double factor){
fs::path cache_filename;
std::string const lod = (boost::format("%.2f") % factor).str();
+#if BOOST_FILESYSTEM_VERSION < 3
std::string const cache_basename = svgfilename.filename() + ".cache_" + lod + ".png";
+#else
+ std::string const cache_basename = svgfilename.filename().string() + ".cache_" + lod + ".png";
+#endif
if (isThemeResource(svgfilename)) {
std::string const theme_name = (config["game/theme"].s().empty() ? "default" : config["game/theme"].s());
diff --git a/game/filemagic.hh b/game/filemagic.hh
index bf87ded..29e81fe 100644
--- a/game/filemagic.hh
+++ b/game/filemagic.hh
@@ -71,7 +71,11 @@ namespace filemagic {
// For now, just check the extension an assume it's not lying.
// Get file extension in lower case
+#if BOOST_FILESYSTEM_VERSION < 3
std::string ext = filename.extension();
+#else
+ std::string ext = filename.extension().string();
+#endif
// somehow this does not convert the extension to lower case:
//std::for_each(ext.begin(), ext.end(), static_cast<int(*)(int)>(std::tolower));
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower );
diff --git a/game/fs.cc b/game/fs.cc
index e34a784..767a7ab 100644
--- a/game/fs.cc
+++ b/game/fs.cc
@@ -128,7 +128,11 @@ std::string getThemePath(std::string const& filename) {
bool isThemeResource(fs::path filename){
try {
+#if BOOST_FILESYSTEM_VERSION < 3
std::string themefile = getThemePath(filename.filename());
+#else
+ std::string themefile = getThemePath(filename.filename().string());
+#endif
return themefile == filename;
} catch (...) { return false; }
}
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 38e163b..db15d79 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -104,7 +104,11 @@ void SongParser::iniParseHeader() {
// Search the dir for the music files
for (boost::filesystem::directory_iterator dirIt(s.path), dirEnd; dirIt != dirEnd; ++dirIt) {
boost::filesystem::path p = dirIt->path();
+#if BOOST_FILESYSTEM_VERSION < 3
std::string name = p.leaf(); // File basename (notes.txt)
+#else
+ std::string name = p.filename().string(); // File basename (notes.txt)
+#endif
if (regex_match(name.c_str(), match, midifile)) {
s.midifilename = name;
} else if (regex_match(name.c_str(), match, audiofile_background)) {
diff --git a/game/songparser.cc b/game/songparser.cc
index 2b7b9b4..ac9f3f6 100644
--- a/game/songparser.cc
+++ b/game/songparser.cc
@@ -100,7 +100,11 @@ SongParser::SongParser(Song& s):
for (boost::filesystem::directory_iterator dirIt(s.path), dirEnd; dirIt != dirEnd; ++dirIt) {
boost::filesystem::path p = dirIt->path();
+#if BOOST_FILESYSTEM_VERSION < 3
std::string name = p.leaf(); // File basename
+#else
+ std::string name = p.filename().string(); // File basename
+#endif
if (m_song.cover.empty() && regex_match(name.c_str(), match, coverfile)) {
m_song.cover = name;
} else if (m_song.background.empty() && regex_match(name.c_str(), match, backgroundfile)) {
diff --git a/game/songs.cc b/game/songs.cc
index 62ab26d..afab383 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -67,8 +67,13 @@ void Songs::reload_internal(fs::path const& parent) {
for (fs::directory_iterator dirIt(parent), dirEnd; m_loading && dirIt != dirEnd; ++dirIt) {
fs::path p = dirIt->path();
if (fs::is_directory(p)) { reload_internal(p); continue; }
+#if BOOST_FILESYSTEM_VERSION < 3
std::string name = p.leaf(); // File basename (notes.txt)
std::string path = p.directory_string(); // Path without filename
+#else
+ std::string name = p.filename().string(); // File basename (notes.txt)
+ std::string path = p.string(); // Path without filename
+#endif
path.erase(path.size() - name.size());
if (!regex_match(name.c_str(), match, expression)) continue;
try {
diff --git a/tools/ss_helpers.hh b/tools/ss_helpers.hh
index 58e19dc..8895d94 100644
--- a/tools/ss_helpers.hh
+++ b/tools/ss_helpers.hh
@@ -10,7 +10,11 @@ extern "C" void xmlLogger(void* logger, char const* msg, ...) { if (logger) *(st
void enableXMLLogger(std::ostream& os = std::cerr) { xmlSetGenericErrorFunc(&os, xmlLogger); }
void disableXMLLogger() { xmlSetGenericErrorFunc(NULL, xmlLogger); }
+#if BOOST_FILESYSTEM_VERSION < 3
std::string filename(boost::filesystem::path const& p) { return *--p.end(); }
+#else
+std::string filename(boost::filesystem::path const& p) { return p.filename().string(); }
+#endif
/** Fix Singstar's b0rked XML **/
std::string xmlFix(std::vector<char> const& data) {
|