Package: smc
Version: 1.9-3
Severity: normal
Tags: patch

SMC fails to build with the new Boost 1.46 packages [1]. The attached
patch fixes the build on both old and new boost versions.
The changes are actually listed here:

http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/deprecated.html

Regards

Konstantinos

[1]: 
http://buildd.debian-ports.org/status/fetch.php?pkg=smc&arch=armhf&ver=1.9-3%2Bb1&stamp=1304120136
(armhf is a new port so I had to build most packages with the new
boost libs, hence the error appeared there first).
diff -ruN smc-1.9/src/core/filesystem/filesystem.cpp smc-1.9.new//src/core/filesystem/filesystem.cpp
--- smc-1.9/src/core/filesystem/filesystem.cpp	2009-07-04 10:11:18.000000000 +0000
+++ smc-1.9.new//src/core/filesystem/filesystem.cpp	2011-06-08 04:07:04.889984136 +0000
@@ -64,7 +64,11 @@
 
 bool Dir_Exists( const std::string &dir )
 {
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 	return fs::exists( fs::path( dir, fs::native ) );
+#else
+	return fs::exists( fs::path( dir.c_str() ) );
+#endif
 
 	/*struct stat file_info;
 
@@ -89,7 +93,11 @@
 
 bool Create_Directory( const std::string &dir )
 {
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 	return fs::create_directory( fs::path( dir, fs::native ) );
+#else
+	return fs::create_directory( fs::path( dir.c_str() ) );
+#endif
 }
 
 size_t Get_File_Size( const std::string &filename )
@@ -130,7 +138,11 @@
 {
 	vector<std::string> valid_files;
 
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 	fs::path full_path( dir, fs::native );
+#else
+	fs::path full_path( dir.c_str() );
+#endif
 	fs::directory_iterator end_iter;
 
 	// load all available objects
@@ -142,32 +154,56 @@
 			if( fs::is_directory( *dir_itr ) )
 			{
 				// ignore hidden directories
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 				if( dir_itr->path().leaf().find( "." ) == 0 )
+#else
+				if( dir_itr->path().filename().string().find( "." ) == 0 )
+#endif
 				{
 					continue;
 				}
 
 				if( with_directories )
 				{
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 					valid_files.push_back( dir + "/" + dir_itr->path().leaf() );
+#else
+					valid_files.push_back( dir + "/" + dir_itr->path().filename().string() );
+#endif
 				}
 
 				// load all items from the sub-directory
 				if( search_in_sub_directories )
 				{
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 					vector<std::string> new_valid_files = Get_Directory_Files( dir + "/" + dir_itr->path().leaf(), file_type, with_directories );
+#else
+					vector<std::string> new_valid_files = Get_Directory_Files( dir + "/" + dir_itr->path().filename().string(), file_type, with_directories );
+#endif
 					valid_files.insert( valid_files.end(), new_valid_files.begin(), new_valid_files.end() );
 				}
 			}
 			// valid file
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 			else if( file_type.empty() || dir_itr->path().leaf().rfind( file_type ) != std::string::npos )
+#else
+			else if( file_type.empty() || dir_itr->path().filename().string().rfind( file_type ) != std::string::npos )
+#endif
 			{
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 				valid_files.push_back( dir + "/" + dir_itr->path().leaf() );
+#else
+				valid_files.push_back( dir + "/" + dir_itr->path().filename().string() );
+#endif
 			}
 		}
 		catch( const std::exception &ex )
 		{
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 			printf( "%s %s\n", dir_itr->path().leaf().c_str(), ex.what() );
+#else
+			printf( "%s %s\n", dir_itr->path().filename().string().c_str(), ex.what() );
+#endif
 		}
 	}
 
diff -ruN smc-1.9/src/overworld/world_manager.cpp smc-1.9.new//src/overworld/world_manager.cpp
--- smc-1.9/src/overworld/world_manager.cpp	2009-08-16 16:44:52.000000000 +0000
+++ smc-1.9.new//src/overworld/world_manager.cpp	2011-06-08 13:51:15.159979826 +0000
@@ -111,14 +111,22 @@
 void cOverworld_Manager :: Load_Dir( const std::string &dir, bool user_dir /* = 0 */ ) 
 {
 	// set world directory
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 	fs::path full_path( dir, fs::native );
+#else
+	fs::path full_path( dir.c_str() );
+#endif
 	fs::directory_iterator end_iter;
 
 	for( fs::directory_iterator dir_itr( full_path ); dir_itr != end_iter; ++dir_itr )
 	{
 		try
 		{
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 			std::string current_dir = dir_itr->path().leaf();
+#else
+			std::string current_dir = dir_itr->path().filename().string();
+#endif
 
 			// only directories with an existing description
 			if( fs::is_directory( *dir_itr ) && File_Exists( dir + "/" + current_dir + "/description.xml" ) )
diff -ruN smc-1.9/src/video/video.cpp smc-1.9.new//src/video/video.cpp
--- smc-1.9/src/video/video.cpp	2009-07-04 09:46:56.000000000 +0000
+++ smc-1.9.new//src/video/video.cpp	2011-06-08 14:02:49.359979740 +0000
@@ -749,7 +749,11 @@
 		{
 			try
 			{
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 				fs::remove_all( fs::path( m_imgcache_dir, fs::native ) );
+#else
+				fs::remove_all( fs::path( m_imgcache_dir.c_str() ) );
+#endif
 			}
 			// could happen if a file is locked or we have no write rights
 			catch( const std::exception &ex )
@@ -771,7 +775,11 @@
 	// no cache available
 	if( !Dir_Exists( imgcache_dir_active ) )
 	{
+#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2
 		fs::create_directories( fs::path( imgcache_dir_active + "/" GAME_PIXMAPS_DIR, fs::native ) );
+#else
+		fs::create_directories( fs::path( imgcache_dir_active + "/" GAME_PIXMAPS_DIR ) );
+#endif
 	}
 	// cache available
 	else

Reply via email to