sparse files fixes. now sets the size of the files in case sparse files are supported

This commit is contained in:
Arvid Norberg
2007-04-19 03:06:15 +00:00
parent a35c1ef1a5
commit 92cf13c2c2
5 changed files with 79 additions and 26 deletions

View File

@@ -238,6 +238,16 @@ namespace libtorrent
return bytes_read;
}
void set_size(size_type s)
{
size_type pos = tell();
seek(s, seek_begin);
if (FALSE == ::SetEndOfFile(m_file_handle))
throw_exception("file::set_size");
seek(pos, seek_begin);
}
size_type seek(size_type pos, seek_mode from_where)
{
assert(pos >= 0 || from_where != seek_begin);
@@ -339,6 +349,11 @@ namespace libtorrent
return m_impl->read(buffer, num_bytes);
}
void file::set_size(size_type s)
{
m_impl->set_size(s);
}
size_type file::seek(size_type pos, seek_mode m)
{
return m_impl->seek(pos,impl::seek_mode(m.m_val));