From 92fba05040db38ef36d53a46c2e86590501d3b65 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 3 Mar 2012 21:51:15 +0000 Subject: [PATCH] attempt to fix unc paths on windows --- src/file.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 3432b13ab..08bda8c15 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -801,20 +801,19 @@ namespace libtorrent FILE_SHARE_READ, }; -#if TORRENT_USE_WSTRING -#define CreateFile_ CreateFileW - m_path = convert_to_wstring(path); +#if TORRENT_USE_UNC_PATHS + // UNC paths must be absolute + std::string p = "\\\\?\\" + (is_complete(path) ? path : combine_path(current_working_directory(), path)); #else -#define CreateFile_ CreateFileA - m_path = convert_to_native(path); + std::string const& p = path; #endif -#if TORRENT_USE_UNC_PATHS #if TORRENT_USE_WSTRING - m_path = L"\\\\?\\" + m_path; +#define CreateFile_ CreateFileW + m_path = convert_to_wstring(p); #else - m_path = "\\\\?\\" + m_path; -#endif // TORRENT_USE_WSTRING +#define CreateFile_ CreateFileA + m_path = convert_to_native(p); #endif TORRENT_ASSERT((mode & rw_mask) < sizeof(mode_array)/sizeof(mode_array[0]));