removed unused file::sparse_end
This commit is contained in:
parent
94d737ff77
commit
6b04c4f642
|
@ -186,10 +186,6 @@ namespace libtorrent {
|
|||
|
||||
std::int64_t get_size(error_code& ec) const;
|
||||
|
||||
// return the offset of the first byte that
|
||||
// belongs to a data-region
|
||||
std::int64_t sparse_end(std::int64_t start) const;
|
||||
|
||||
handle_type native_handle() const { return m_file_handle; }
|
||||
|
||||
private:
|
||||
|
|
51
src/file.cpp
51
src/file.cpp
|
@ -1248,57 +1248,6 @@ namespace {
|
|||
return -1;
|
||||
}
|
||||
return fs.st_size;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::int64_t file::sparse_end(std::int64_t start) const
|
||||
{
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
||||
#ifndef FSCTL_QUERY_ALLOCATED_RANGES
|
||||
typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||
LARGE_INTEGER FileOffset;
|
||||
LARGE_INTEGER Length;
|
||||
} FILE_ALLOCATED_RANGE_BUFFER;
|
||||
#define FSCTL_QUERY_ALLOCATED_RANGES ((0x9 << 16) | (1 << 14) | (51 << 2) | 3)
|
||||
#endif // TORRENT_MINGW
|
||||
|
||||
FILE_ALLOCATED_RANGE_BUFFER buffer;
|
||||
DWORD bytes_returned = 0;
|
||||
FILE_ALLOCATED_RANGE_BUFFER in;
|
||||
error_code ec;
|
||||
std::int64_t file_size = get_size(ec);
|
||||
if (ec) return start;
|
||||
|
||||
in.FileOffset.QuadPart = start;
|
||||
in.Length.QuadPart = file_size - start;
|
||||
|
||||
if (!DeviceIoControl(native_handle(), FSCTL_QUERY_ALLOCATED_RANGES
|
||||
, &in, sizeof(FILE_ALLOCATED_RANGE_BUFFER)
|
||||
, &buffer, sizeof(FILE_ALLOCATED_RANGE_BUFFER), &bytes_returned, 0))
|
||||
{
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return start;
|
||||
}
|
||||
|
||||
// if there are no allocated regions within the rest
|
||||
// of the file, return the end of the file
|
||||
if (bytes_returned == 0) return file_size;
|
||||
|
||||
// assume that this range overlaps the start of the
|
||||
// region we were interested in, and that start actually
|
||||
// resides in an allocated region.
|
||||
if (buffer.FileOffset.QuadPart < start) return start;
|
||||
|
||||
// return the offset to the next allocated region
|
||||
return buffer.FileOffset.QuadPart;
|
||||
|
||||
#elif defined SEEK_DATA
|
||||
// this is supported on solaris
|
||||
std::int64_t ret = ::lseek(native_handle(), start, SEEK_DATA);
|
||||
if (ret < 0) return start;
|
||||
return start;
|
||||
#else
|
||||
return start;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue