X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffile_group.cc;h=9d042554c5b8c0649385456895d0358d813a7b0c;hb=d50bc4c21be3e0766916b47a6e688cf896bed059;hp=cdd78c6a30e0427c28887465a93274480934b73f;hpb=10f55bf3a2ac9340263a410fa2a69f1360f5c227;p=dcpomatic.git diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index cdd78c6a3..9d042554c 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -21,10 +21,18 @@ #include #include "file_group.h" #include "exceptions.h" +#include "cross.h" using std::vector; using std::cout; +FileGroup::FileGroup () + : _current_path (0) + , _current_file (0) +{ + +} + FileGroup::FileGroup (boost::filesystem::path p) : _current_path (0) , _current_file (0) @@ -49,6 +57,13 @@ FileGroup::~FileGroup () } } +void +FileGroup::set_paths (vector const & p) +{ + _paths = p; + ensure_open_path (0); + seek (0, SEEK_SET); +} /** Ensure that the given path index in the content is the _current_file */ void @@ -64,7 +79,7 @@ FileGroup::ensure_open_path (size_t p) const } _current_path = p; - _current_file = fopen (_paths[_current_path].string().c_str(), "rb"); + _current_file = fopen_boost (_paths[_current_path], "rb"); if (_current_file == 0) { throw OpenFileError (_paths[_current_path]); } @@ -85,7 +100,11 @@ FileGroup::seek (int64_t pos, int whence) const for (size_t i = 0; i < _current_path; ++i) { full_pos += boost::filesystem::file_size (_paths[i]); } +#ifdef DCPOMATIC_WINDOWS + full_pos += _ftelli64 (_current_file); +#else full_pos += ftell (_current_file); +#endif full_pos += pos; break; case SEEK_END: @@ -110,7 +129,7 @@ FileGroup::seek (int64_t pos, int whence) const } ensure_open_path (i); - fseek (_current_file, sub_pos, SEEK_SET); + dcpomatic_fseek (_current_file, sub_pos, SEEK_SET); return full_pos; }