Removed file::m_path windows specific field
Removed default_storage::sparse_end Typos
This commit is contained in:
parent
8e78669367
commit
5c94b286b0
|
@ -345,12 +345,6 @@ namespace libtorrent
|
||||||
boost::uint32_t m_file_id;
|
boost::uint32_t m_file_id;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_WINDOWS && TORRENT_USE_WSTRING
|
|
||||||
std::wstring m_path;
|
|
||||||
#elif defined TORRENT_WINDOWS
|
|
||||||
std::string m_path;
|
|
||||||
#endif // TORRENT_WINDOWS
|
|
||||||
|
|
||||||
int m_open_mode;
|
int m_open_mode;
|
||||||
#if defined TORRENT_WINDOWS
|
#if defined TORRENT_WINDOWS
|
||||||
static bool has_manage_volume_privs;
|
static bool has_manage_volume_privs;
|
||||||
|
|
|
@ -452,8 +452,6 @@ namespace libtorrent
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int sparse_end(int start) const;
|
|
||||||
|
|
||||||
void delete_one_file(std::string const& p, error_code& ec);
|
void delete_one_file(std::string const& p, error_code& ec);
|
||||||
|
|
||||||
void need_partfile();
|
void need_partfile();
|
||||||
|
|
|
@ -192,7 +192,7 @@ namespace libtorrent
|
||||||
// the case there is no piece picker, see m_have_all.
|
// the case there is no piece picker, see m_have_all.
|
||||||
boost::scoped_ptr<piece_picker> m_picker;
|
boost::scoped_ptr<piece_picker> m_picker;
|
||||||
|
|
||||||
// TOOD: make this a raw pointer. perhaps keep the shared_ptr
|
// TODO: make this a raw pointer. perhaps keep the shared_ptr
|
||||||
// around further down the object to maintain an owner
|
// around further down the object to maintain an owner
|
||||||
boost::shared_ptr<torrent_info> m_torrent_file;
|
boost::shared_ptr<torrent_info> m_torrent_file;
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ namespace libtorrent
|
||||||
// use sorted_insert() and sorted_find() on it. The GNU STL
|
// use sorted_insert() and sorted_find() on it. The GNU STL
|
||||||
// implementation on Darwin uses significantly less memory to
|
// implementation on Darwin uses significantly less memory to
|
||||||
// represent a vector than a set, and this set is typically
|
// represent a vector than a set, and this set is typically
|
||||||
// relaitvely small, and it's cheap to copy pointers.
|
// relatively small, and it's cheap to copy pointers.
|
||||||
std::vector<peer_connection*> m_connections;
|
std::vector<peer_connection*> m_connections;
|
||||||
|
|
||||||
// the scrape data from the tracker response, this
|
// the scrape data from the tracker response, this
|
||||||
|
|
36
src/file.cpp
36
src/file.cpp
|
@ -1391,10 +1391,10 @@ namespace libtorrent
|
||||||
|
|
||||||
#if TORRENT_USE_WSTRING
|
#if TORRENT_USE_WSTRING
|
||||||
#define CreateFile_ CreateFileW
|
#define CreateFile_ CreateFileW
|
||||||
m_path = convert_to_wstring(p);
|
std::wstring file_path = convert_to_wstring(p);
|
||||||
#else
|
#else
|
||||||
#define CreateFile_ CreateFileA
|
#define CreateFile_ CreateFileA
|
||||||
m_path = convert_to_native(p);
|
std::string file_path = convert_to_native(p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TORRENT_ASSERT((mode & rw_mask) < sizeof(mode_array)/sizeof(mode_array[0]));
|
TORRENT_ASSERT((mode & rw_mask) < sizeof(mode_array)/sizeof(mode_array[0]));
|
||||||
|
@ -1411,7 +1411,7 @@ namespace libtorrent
|
||||||
| ((mode & direct_io) ? FILE_FLAG_NO_BUFFERING : 0)
|
| ((mode & direct_io) ? FILE_FLAG_NO_BUFFERING : 0)
|
||||||
| ((mode & no_cache) ? FILE_FLAG_WRITE_THROUGH : 0);
|
| ((mode & no_cache) ? FILE_FLAG_WRITE_THROUGH : 0);
|
||||||
|
|
||||||
handle_type handle = CreateFile_(m_path.c_str(), m.rw_mode
|
handle_type handle = CreateFile_(file_path.c_str(), m.rw_mode
|
||||||
, (mode & lock_file) ? FILE_SHARE_READ : FILE_SHARE_READ | FILE_SHARE_WRITE
|
, (mode & lock_file) ? FILE_SHARE_READ : FILE_SHARE_READ | FILE_SHARE_WRITE
|
||||||
, 0, m.create_mode, flags, 0);
|
, 0, m.create_mode, flags, 0);
|
||||||
|
|
||||||
|
@ -1635,7 +1635,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(native_handle());
|
CloseHandle(native_handle());
|
||||||
m_path.clear();
|
|
||||||
#else
|
#else
|
||||||
if (m_file_handle != INVALID_HANDLE_VALUE)
|
if (m_file_handle != INVALID_HANDLE_VALUE)
|
||||||
::close(m_file_handle);
|
::close(m_file_handle);
|
||||||
|
@ -2053,26 +2052,21 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
|
|
||||||
if ((m_open_mode & sparse) == 0)
|
if ((m_open_mode & sparse) == 0)
|
||||||
{
|
{
|
||||||
#if TORRENT_USE_WSTRING
|
typedef DWORD (WINAPI *GetFileInformationByHandleEx_t)(HANDLE hFile
|
||||||
typedef DWORD (WINAPI *GetCompressedFileSize_t)(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh);
|
, FILE_INFO_BY_HANDLE_CLASS FileInformationClass
|
||||||
#else
|
, LPVOID lpFileInformation
|
||||||
typedef DWORD (WINAPI *GetCompressedFileSize_t)(LPCSTR lpFileName, LPDWORD lpFileSizeHigh);
|
, DWORD dwBufferSize);
|
||||||
#endif
|
|
||||||
|
|
||||||
static GetCompressedFileSize_t GetCompressedFileSize_ = NULL;
|
static GetFileInformationByHandleEx_t GetFileInformationByHandleEx_ = NULL;
|
||||||
|
|
||||||
static bool failed_kernel32 = false;
|
static bool failed_kernel32 = false;
|
||||||
|
|
||||||
if ((GetCompressedFileSize_ == NULL) && !failed_kernel32)
|
if ((GetFileInformationByHandleEx_ == NULL) && !failed_kernel32)
|
||||||
{
|
{
|
||||||
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
||||||
if (kernel32)
|
if (kernel32)
|
||||||
{
|
{
|
||||||
#if TORRENT_USE_WSTRING
|
GetFileInformationByHandleEx_ = (GetFileInformationByHandleEx_t)GetProcAddress(kernel32, "GetFileInformationByHandleEx");
|
||||||
GetCompressedFileSize_ = (GetCompressedFileSize_t)GetProcAddress(kernel32, "GetCompressedFileSizeW");
|
|
||||||
#else
|
|
||||||
GetCompressedFileSize_ = (GetCompressedFileSize_t)GetProcAddress(kernel32, "GetCompressedFileSizeA");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2081,18 +2075,18 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
}
|
}
|
||||||
|
|
||||||
offs.QuadPart = 0;
|
offs.QuadPart = 0;
|
||||||
if (GetCompressedFileSize_)
|
if (GetFileInformationByHandleEx_)
|
||||||
{
|
{
|
||||||
// only allocate the space if the file
|
// only allocate the space if the file
|
||||||
// is not fully allocated
|
// is not fully allocated
|
||||||
DWORD high_dword = 0;
|
FILE_STANDARD_INFO inf;
|
||||||
offs.LowPart = GetCompressedFileSize_(m_path.c_str(), &high_dword);
|
if (GetFileInformationByHandleEx_(native_handle()
|
||||||
offs.HighPart = high_dword;
|
, FileStandardInfo, &inf, sizeof(inf)) == FALSE)
|
||||||
if (offs.LowPart == INVALID_FILE_SIZE)
|
|
||||||
{
|
{
|
||||||
ec.assign(GetLastError(), system_category());
|
ec.assign(GetLastError(), system_category());
|
||||||
if (ec) return false;
|
if (ec) return false;
|
||||||
}
|
}
|
||||||
|
offs = inf.AllocationSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offs.QuadPart != s)
|
if (offs.QuadPart != s)
|
||||||
|
|
|
@ -888,32 +888,6 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int default_storage::sparse_end(int piece) const
|
|
||||||
{
|
|
||||||
TORRENT_ASSERT(piece >= 0);
|
|
||||||
TORRENT_ASSERT(piece < files().num_pieces());
|
|
||||||
|
|
||||||
boost::int64_t file_offset = boost::int64_t(piece) * files().piece_length();
|
|
||||||
int file_index = 0;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (file_offset < files().file_size(file_index))
|
|
||||||
break;
|
|
||||||
|
|
||||||
file_offset -= files().file_size(file_index);
|
|
||||||
++file_index;
|
|
||||||
TORRENT_ASSERT(file_index != files().num_files());
|
|
||||||
}
|
|
||||||
|
|
||||||
error_code ec;
|
|
||||||
file_handle handle = open_file_impl(file_index, file::read_only, ec);
|
|
||||||
if (ec) return piece;
|
|
||||||
|
|
||||||
boost::int64_t data_start = handle->sparse_end(file_offset);
|
|
||||||
return int((data_start + files().piece_length() - 1) / files().piece_length());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool default_storage::verify_resume_data(bdecode_node const& rd
|
bool default_storage::verify_resume_data(bdecode_node const& rd
|
||||||
, std::vector<std::string> const* links
|
, std::vector<std::string> const* links
|
||||||
, storage_error& ec)
|
, storage_error& ec)
|
||||||
|
|
Loading…
Reference in New Issue