2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <boost/filesystem.hpp>
22 #include <boost/algorithm/string.hpp>
26 using namespace boost;
31 ifstream f ("/etc/mtab");
36 split (b, s, is_any_of (" "));
37 if (b.size() >= 3 && b[2] == "udf") {
38 replace_all (b[1], "\\040", " ");
47 dvd_titles (string dvd)
49 filesystem::path video (dvd);
52 list<DVDTitle> titles;
54 for (filesystem::directory_iterator i = filesystem::directory_iterator (video); i != filesystem::directory_iterator(); ++i) {
55 #if BOOST_FILESYSTEM_VERSION == 3
56 string const n = filesystem::path(*i).filename().generic_string();
58 string const n = filesystem::path(*i).filename();
60 if (starts_with (n, "VTS_") && ends_with (n, ".VOB")) {
61 uint64_t const size = filesystem::file_size (filesystem::path (*i));
63 split (p, n, is_any_of ("_."));
65 int const a = atoi (p[1].c_str ());
66 int const b = atoi (p[2].c_str ());
71 list<DVDTitle>::iterator j = titles.begin ();
72 while (j != titles.end() && j->number != a) {
76 if (j == titles.end ()) {
77 titles.push_back (DVDTitle (a, size));
92 operator< (DVDTitle const & a, DVDTitle const & b)
94 return a.number < b.number;