X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcopy_from_dvd_job.cc;h=dcf53ac54e2baed566fde74bf1b2edc51ccf1e96;hb=63ea6b6c5ee64f8ee067c2b488d004b6dfe363e0;hp=f7281fc10e303479c2a0bcfdaef6e26121df059f;hpb=9dd38ef2f05b24ba669acb9805e0914ac227fff2;p=dcpomatic.git diff --git a/src/lib/copy_from_dvd_job.cc b/src/lib/copy_from_dvd_job.cc index f7281fc10..dcf53ac54 100644 --- a/src/lib/copy_from_dvd_job.cc +++ b/src/lib/copy_from_dvd_job.cc @@ -25,18 +25,19 @@ #include #include #include "copy_from_dvd_job.h" -#include "film_state.h" #include "dvd.h" #include "cross.h" +#include "film.h" -using namespace std; -using namespace boost; +using std::string; +using std::list; +using std::stringstream; +using boost::shared_ptr; -/** @param fs FilmState for the film to write DVD data into. - * @param l Log that we can write to. +/** @param f Film to write DVD data into. */ -CopyFromDVDJob::CopyFromDVDJob (shared_ptr fs, Log* l, shared_ptr req) - : Job (fs, shared_ptr (), l, req) +CopyFromDVDJob::CopyFromDVDJob (shared_ptr f, shared_ptr req) + : Job (f, req) { } @@ -51,7 +52,7 @@ void CopyFromDVDJob::run () { /* Remove any old DVD rips */ - filesystem::remove_all (_fs->dir ("dvd")); + boost::filesystem::remove_all (_film->dir ("dvd")); string const dvd = find_dvd (); if (dvd.empty ()) { @@ -75,7 +76,7 @@ CopyFromDVDJob::run () } stringstream c; - c << "vobcopy -n " << longest_title << " -l -o \"" << _fs->dir ("dvd") << "\" 2>&1"; + c << "vobcopy -n " << longest_title << " -l -o \"" << _film->dir ("dvd") << "\" 2>&1"; FILE* f = popen (c.str().c_str(), "r"); if (f == 0) { @@ -94,6 +95,25 @@ CopyFromDVDJob::run () } } + const string dvd_dir = _film->dir ("dvd"); + + string largest_file; + uintmax_t largest_size = 0; + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dvd_dir); i != boost::filesystem::directory_iterator(); ++i) { + uintmax_t const s = boost::filesystem::file_size (*i); + if (s > largest_size) { + +#if BOOST_FILESYSTEM_VERSION == 3 + largest_file = boost::filesystem::path(*i).generic_string(); +#else + largest_file = i->string (); +#endif + largest_size = s; + } + } + + _film->set_content (largest_file); + int const r = pclose (f); if (WEXITSTATUS (r) != 0) { set_error ("call to vobcopy failed");