fixed unicode issue in storage
This commit is contained in:
parent
cffb933aaa
commit
4709d202e1
|
@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_CONFIG_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
|
||||
|
@ -81,7 +82,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_BSD
|
||||
#endif
|
||||
|
||||
|
||||
// should wpath or path be used?
|
||||
#if defined UNICODE && !defined BOOST_FILESYSTEM_NARROW_ONLY && BOOST_VERSION >= 103400
|
||||
#define TORRENT_USE_WPATH 1
|
||||
#else
|
||||
#define TORRENT_USE_WPATH 0
|
||||
#endif
|
||||
|
||||
#endif // TORRENT_CONFIG_HPP_INCLUDED
|
||||
|
||||
|
|
|
@ -95,9 +95,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
#if TORRENT_USE_WPATH
|
||||
|
||||
#ifdef BOOST_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
#include "libtorrent/utf8.hpp"
|
||||
#include "libtorrent/buffer.hpp"
|
||||
|
@ -260,7 +263,7 @@ namespace libtorrent
|
|||
{
|
||||
size_type size = 0;
|
||||
std::time_t time = 0;
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
#if TORRENT_USE_WPATH
|
||||
fs::wpath f = safe_convert((p / i->path).string());
|
||||
#else
|
||||
fs::path f = p / i->path;
|
||||
|
@ -310,7 +313,7 @@ namespace libtorrent
|
|||
size_type size = 0;
|
||||
std::time_t time = 0;
|
||||
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
#if TORRENT_USE_WPATH
|
||||
fs::wpath f = safe_convert((p / i->path).string());
|
||||
#else
|
||||
fs::path f = p / i->path;
|
||||
|
@ -443,7 +446,7 @@ namespace libtorrent
|
|||
last_path = dir;
|
||||
if (!exists_win(last_path))
|
||||
create_directories_win(last_path);
|
||||
#elif defined(_WIN32) && defined(UNICODE)
|
||||
#elif TORRENT_USE_WPATH
|
||||
last_path = dir;
|
||||
fs::wpath wp = safe_convert(last_path.string());
|
||||
if (!exists(wp))
|
||||
|
@ -506,9 +509,9 @@ namespace libtorrent
|
|||
fs::path old_name = m_save_path / files().at(index).path;
|
||||
m_pool.release(old_name);
|
||||
|
||||
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION >= 103400
|
||||
fs::wpath old_path = safe_convert(old_name);
|
||||
fs::wpath new_path = safe_convert(m_save_path / new_filename);
|
||||
#if TORRENT_USE_WPATH
|
||||
fs::wpath old_path = safe_convert(old_name.string());
|
||||
fs::wpath new_path = safe_convert((m_save_path / new_filename).string());
|
||||
#else
|
||||
fs::path const& old_path = old_name;
|
||||
fs::path new_path = m_save_path / new_filename;
|
||||
|
@ -565,7 +568,7 @@ namespace libtorrent
|
|||
std::pair<iter_t, bool> ret = directories.insert((m_save_path / bp).string());
|
||||
bp = bp.branch_path();
|
||||
}
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
#if TORRENT_USE_WPATH
|
||||
try
|
||||
{ fs::remove(safe_convert(p)); }
|
||||
catch (std::exception& e)
|
||||
|
@ -590,7 +593,7 @@ namespace libtorrent
|
|||
for (std::set<std::string>::reverse_iterator i = directories.rbegin()
|
||||
, end(directories.rend()); i != end; ++i)
|
||||
{
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
#if TORRENT_USE_WPATH
|
||||
try
|
||||
{ fs::remove(safe_convert(*i)); }
|
||||
catch (std::exception& e)
|
||||
|
@ -725,7 +728,7 @@ namespace libtorrent
|
|||
// returns true on success
|
||||
bool storage::move_storage(fs::path save_path)
|
||||
{
|
||||
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION >= 103400
|
||||
#if TORRENT_USE_WPATH
|
||||
fs::wpath old_path;
|
||||
fs::wpath new_path;
|
||||
#else
|
||||
|
@ -741,7 +744,7 @@ namespace libtorrent
|
|||
CreateDirectory(wsave_path.c_str(), 0);
|
||||
else if ((GetFileAttributes(wsave_path.c_str()) & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
return false;
|
||||
#elif defined(_WIN32) && defined(UNICODE)
|
||||
#elif TORRENT_USE_WPATH
|
||||
fs::wpath wp = safe_convert(save_path.string());
|
||||
if (!exists(wp))
|
||||
create_directory(wp);
|
||||
|
@ -756,7 +759,7 @@ namespace libtorrent
|
|||
|
||||
m_pool.release(this);
|
||||
|
||||
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION >= 103400
|
||||
#if TORRENT_USE_WPATH
|
||||
old_path = safe_convert((m_save_path / files().name()).string());
|
||||
new_path = safe_convert((save_path / files().name()).string());
|
||||
#else
|
||||
|
@ -770,7 +773,6 @@ namespace libtorrent
|
|||
#endif
|
||||
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 103400
|
||||
rename_win(old_path, new_path);
|
||||
rename(old_path, new_path);
|
||||
#else
|
||||
rename(old_path, new_path);
|
||||
#endif
|
||||
|
@ -1648,7 +1650,7 @@ namespace libtorrent
|
|||
#endif
|
||||
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 103400
|
||||
file_exists = exists_win(f);
|
||||
#elif defined(_WIN32) && defined(UNICODE)
|
||||
#elif TORRENT_USE_WPATH
|
||||
fs::wpath wf = safe_convert(f.string());
|
||||
file_exists = exists(wf);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue