X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fpacksource.cpp;h=d22c7dc4235990591fffbf7c9d2dafba0eca3aaa;hp=d054e1d4ee9e50ef99c8d9c136aee978237113bf;hb=e44432ecb5d2c0a288652ac6ed9d06f51a68d395;hpb=73ef0d0378ba1c987f99522ba904cba9fd4b0ad4 diff --git a/source/packsource.cpp b/source/packsource.cpp index d054e1d..d22c7dc 100644 --- a/source/packsource.cpp +++ b/source/packsource.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "collection.h" @@ -5,6 +6,15 @@ using namespace std; +namespace { + +void delete_io(Msp::IO::Base *io) +{ + delete io; +} + +} + namespace Msp { namespace DataFile { @@ -120,9 +130,10 @@ PackSource::File::File(const Pack &p, const string &fn): RefPtr PackSource::File::open() const { - RefPtr io_file = new IO::BufferedFile(pack.get_filename()); - io_file->seek(pack.get_base_offset()+offset, IO::S_BEG); - return io_file; + IO::BufferedFile *io_file = new IO::BufferedFile(pack.get_filename()); + IO::Slice *io_slice = new IO::Slice(*io_file, pack.get_base_offset()+offset, length); + io_slice->signal_deleted.connect(sigc::bind(sigc::ptr_fun(delete_io), io_file)); + return io_slice; } string PackSource::File::get_full_name() const