forked from premiere/premiere-libtorrent
only allocate a file if it's not already allocated (windows)
This commit is contained in:
parent
c9f7ba495f
commit
b2484ead10
10
src/file.cpp
10
src/file.cpp
|
@ -1479,15 +1479,21 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if _WIN32_WINNT >= 0x501
|
#if _WIN32_WINNT >= 0x501
|
||||||
// TODO: again, only allocate the space if the file
|
|
||||||
// is not fully allocated
|
|
||||||
if ((m_open_mode & sparse) == 0)
|
if ((m_open_mode & sparse) == 0)
|
||||||
|
{
|
||||||
|
// only allocate the space if the file
|
||||||
|
// is not fully allocated
|
||||||
|
offs.LowPart = GetCompressedFileSize(m_path.c_str(), &offs.HighPart);
|
||||||
|
ec.assign(GetLastError(), get_system_category());
|
||||||
|
if (ec) return false;
|
||||||
|
if (offs.QuadPart != s)
|
||||||
{
|
{
|
||||||
// if the user has permissions, avoid filling
|
// if the user has permissions, avoid filling
|
||||||
// the file with zeroes, but just fill it with
|
// the file with zeroes, but just fill it with
|
||||||
// garbage instead
|
// garbage instead
|
||||||
SetFileValidData(m_file_handle, offs.QuadPart);
|
SetFileValidData(m_file_handle, offs.QuadPart);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
Loading…
Reference in New Issue