{
assert (format());
- stringstream s;
+ filesystem::path p;
+
/* Start with j2c */
- s << "j2c/";
+ p /= "j2c";
pair<string, string> f = Filter::ffmpeg_strings (filters ());
so that we don't get confused about J2K files generated using different
settings.
*/
+ stringstream s;
s << _state.format->nickname()
<< "_" << _state.content_digest
<< "_" << left_crop() << "_" << right_crop() << "_" << top_crop() << "_" << bottom_crop()
<< "_" << f.first << "_" << f.second
<< "_" << _state.scaler->id();
+ p /= s.str ();
+
/* Similarly for the A/B case */
if (dcp_ab()) {
+ stringstream s;
pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
- s << "/ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
+ s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
+ p /= s.str ();
}
- return _state.dir (s.str ());
+ return _state.dir (p.string ());
}
/** Handle a change to the Film's metadata */
FilmState::thumb_file_for_frame (int n) const
{
stringstream s;
- s << dir ("thumbs") << "/";
s.width (8);
s << setfill('0') << n << ".tiff";
- return s.str ();
+
+ filesystem::path p;
+ p /= dir ("thumbs");
+ p /= s.str ();
+
+ return p.string ();
}
string
FilmState::dir (string d) const
{
- stringstream s;
- s << directory << "/" << d;
- filesystem::create_directories (s.str ());
- return s.str ();
+ filesystem::path p;
+ p /= directory;
+ p /= d;
+ filesystem::create_directories (p);
+ return p.string ();
}
/** Given a file or directory name, return its full path within the Film's directory */
string
FilmState::file (string f) const
{
- stringstream s;
- s << directory << "/" << f;
- return s.str ();
+ filesystem::path p;
+ p /= directory;
+ p /= f;
+ return p.string ();
}
string
/* Data which is cached to speed things up */
- /** Vector of frame indices for each of our `thumbnails */
+ /** Vector of frame indices for each of our `thumbnails' */
std::vector<int> thumbs;
/** Size, in pixels, of the source (ignoring cropping) */
Size size;
BOOST_CHECK_THROW (md5_digest ("foobar"), OpenFileError);
}
+
+BOOST_AUTO_TEST_CASE (paths_test)
+{
+ FilmState s;
+ s.directory = "build/test/a/b/c/d/e";
+ s.thumbs.push_back (42);
+ BOOST_CHECK_EQUAL (s.thumb_file (0), "build/test/a/b/c/d/e/thumbs/00000042.tiff");
+
+ s.content = "/foo/bar/baz";
+ BOOST_CHECK_EQUAL (s.content_path(), "/foo/bar/baz");
+ s.content = "foo/bar/baz";
+ BOOST_CHECK_EQUAL (s.content_path(), "build/test/a/b/c/d/e/foo/bar/baz");
+}