Skip to content

Commit a3b6966

Browse files
committed
Merge pull request #21 from johnhaddon/boostFilesystemFixes2
Restored support for Boost 1.43 (boost::filesystem v2).
2 parents bf86d9d + 6d76cdb commit a3b6966

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/IECore/DeepImageWriter.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ void DeepImageWriter::registerDeepImageWriter( const std::string &extensions, Ca
146146

147147
DeepImageWriterPtr DeepImageWriter::create( const std::string &fileName )
148148
{
149+
/// \todo We can stop using this deprecated form when we no longer need to be compatible
150+
/// with boost 1.43. At that point we can use path.extension().string() and compile with
151+
/// BOOST_FILESYSTEM_NO_DEPRECATED.
149152
std::string ext = boost::filesystem::extension( boost::filesystem::path( fileName ) );
150153

151154
ExtensionsToFnsMap *m = extensionsToFns();

src/IECore/FileSequenceFunctions.cpp

+18-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@
6464

6565
#endif
6666

67+
#if BOOST_VERSION < 104400
68+
69+
// Boost 1.44.0 introduced Filesystem v3, which we use by defining BOOST_FILESYSTEM_VERSION=3 via
70+
// the build process. Prior versions of boost didn't have this version, so we need this define
71+
// to help write code suitable for both.
72+
73+
#define PATH_TO_STRING filename()
74+
75+
#else
76+
77+
#define PATH_TO_STRING filename().string()
78+
79+
#endif
80+
6781
using namespace IECore;
6882

6983
void IECore::findSequences( const std::vector< std::string > &names, std::vector< FileSequencePtr > &sequences, size_t minSequenceSize )
@@ -181,7 +195,7 @@ void IECore::ls( const std::string &path, std::vector< FileSequencePtr > &sequen
181195
std::vector< std::string > files;
182196
for ( boost::filesystem::directory_iterator it( path ); it != end; ++it )
183197
{
184-
files.push_back( it->path().filename().string() );
198+
files.push_back( it->path().PATH_TO_STRING );
185199
}
186200

187201
findSequences( files, sequences, minSequenceSize );
@@ -203,9 +217,9 @@ void IECore::ls( const std::string &sequencePath, FileSequencePtr &sequence, siz
203217

204218
std::vector< std::string > files;
205219

206-
boost::filesystem::path dir = boost::filesystem::path( sequencePath ).branch_path();
220+
boost::filesystem::path dir = boost::filesystem::path( sequencePath ).parent_path();
207221

208-
std::string baseSequencePath = boost::filesystem::path( sequencePath ).filename().string();
222+
std::string baseSequencePath = boost::filesystem::path( sequencePath ).PATH_TO_STRING;
209223

210224
const std::string::size_type first = baseSequencePath.find_first_of( '#' );
211225
assert( first != std::string::npos );
@@ -225,7 +239,7 @@ void IECore::ls( const std::string &sequencePath, FileSequencePtr &sequence, siz
225239

226240
for ( boost::filesystem::directory_iterator it( dirToCheck ); it != end; ++it )
227241
{
228-
const std::string fileName = it->path().filename().string();
242+
const std::string fileName = it->path().PATH_TO_STRING;
229243

230244
if ( fileName.size() >= std::min( prefix.size(), suffix.size() ) && fileName.substr( 0, prefix.size() ) == prefix && fileName.substr( fileName.size() - suffix.size(), suffix.size() ) == suffix )
231245
{

0 commit comments

Comments
 (0)