Removed file::m_path windows specific field

Removed default_storage::sparse_end
Typos
This commit is contained in:
Alden Torres 2016-01-18 17:59:30 -05:00
parent 8e78669367
commit 5c94b286b0
5 changed files with 17 additions and 57 deletions

View File

@ -345,12 +345,6 @@ namespace libtorrent
boost::uint32_t m_file_id;
#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;
#if defined TORRENT_WINDOWS
static bool has_manage_volume_privs;

View File

@ -452,8 +452,6 @@ namespace libtorrent
private:
int sparse_end(int start) const;
void delete_one_file(std::string const& p, error_code& ec);
void need_partfile();

View File

@ -192,7 +192,7 @@ namespace libtorrent
// the case there is no piece picker, see m_have_all.
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
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
// implementation on Darwin uses significantly less memory to
// 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;
// the scrape data from the tracker response, this

View File

@ -1391,10 +1391,10 @@ namespace libtorrent
#if TORRENT_USE_WSTRING
#define CreateFile_ CreateFileW
m_path = convert_to_wstring(p);
std::wstring file_path = convert_to_wstring(p);
#else
#define CreateFile_ CreateFileA
m_path = convert_to_native(p);
std::string file_path = convert_to_native(p);
#endif
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 & 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
, 0, m.create_mode, flags, 0);
@ -1635,7 +1635,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
}
CloseHandle(native_handle());
m_path.clear();
#else
if (m_file_handle != INVALID_HANDLE_VALUE)
::close(m_file_handle);
@ -2053,26 +2052,21 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
if ((m_open_mode & sparse) == 0)
{
#if TORRENT_USE_WSTRING
typedef DWORD (WINAPI *GetCompressedFileSize_t)(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh);
#else
typedef DWORD (WINAPI *GetCompressedFileSize_t)(LPCSTR lpFileName, LPDWORD lpFileSizeHigh);
#endif
typedef DWORD (WINAPI *GetFileInformationByHandleEx_t)(HANDLE hFile
, FILE_INFO_BY_HANDLE_CLASS FileInformationClass
, LPVOID lpFileInformation
, DWORD dwBufferSize);
static GetCompressedFileSize_t GetCompressedFileSize_ = NULL;
static GetFileInformationByHandleEx_t GetFileInformationByHandleEx_ = NULL;
static bool failed_kernel32 = false;
if ((GetCompressedFileSize_ == NULL) && !failed_kernel32)
if ((GetFileInformationByHandleEx_ == NULL) && !failed_kernel32)
{
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
if (kernel32)
{
#if TORRENT_USE_WSTRING
GetCompressedFileSize_ = (GetCompressedFileSize_t)GetProcAddress(kernel32, "GetCompressedFileSizeW");
#else
GetCompressedFileSize_ = (GetCompressedFileSize_t)GetProcAddress(kernel32, "GetCompressedFileSizeA");
#endif
GetFileInformationByHandleEx_ = (GetFileInformationByHandleEx_t)GetProcAddress(kernel32, "GetFileInformationByHandleEx");
}
else
{
@ -2081,18 +2075,18 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
}
offs.QuadPart = 0;
if (GetCompressedFileSize_)
if (GetFileInformationByHandleEx_)
{
// only allocate the space if the file
// is not fully allocated
DWORD high_dword = 0;
offs.LowPart = GetCompressedFileSize_(m_path.c_str(), &high_dword);
offs.HighPart = high_dword;
if (offs.LowPart == INVALID_FILE_SIZE)
FILE_STANDARD_INFO inf;
if (GetFileInformationByHandleEx_(native_handle()
, FileStandardInfo, &inf, sizeof(inf)) == FALSE)
{
ec.assign(GetLastError(), system_category());
if (ec) return false;
}
offs = inf.AllocationSize;
}
if (offs.QuadPart != s)

View File

@ -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
, std::vector<std::string> const* links
, storage_error& ec)