From 261219d30f951b2ef688ba5c5f9b4bc4c4d53182 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 18 Sep 2014 22:36:35 +0400 Subject: [PATCH 2/3] Windows: fix wrong convertion of path from utf8 to ansi in libtorrent's create_directory (GetDataDir() returns string in correct code page) --- src/twister.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/twister.cpp b/src/twister.cpp index 24a19f21..0c347f11 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -140,8 +140,8 @@ torrent_handle startTorrentUser(std::string const &username, bool following) tparams.name = username; boost::filesystem::path torrentPath = GetDataDir() / "swarm"; tparams.save_path= torrentPath.string(); - libtorrent::error_code ec; - create_directory(tparams.save_path, ec); + boost::system::error_code ec; + boost::filesystem::create_directory(torrentPath, ec); std::string filename = combine_path(tparams.save_path, to_hex(ih.to_string()) + ".resume"); load_file(filename.c_str(), tparams.resume_data); @@ -265,10 +265,10 @@ void ThreadWaitExtIP() MilliSleep(500); } - libtorrent::error_code ec; + libtorrent::error_code ec; // libtorrent::error_code == boost::system::error_code boost::filesystem::path swarmDbPath = GetDataDir() / "swarm" / "db"; - create_directories(swarmDbPath.string(), ec); + boost::filesystem::create_directories(swarmDbPath, ec); m_swarmDb.reset(new CLevelDB(swarmDbPath.string(), 256*1024, false, false)); int listen_port = GetListenPort() + LIBTORRENT_PORT_OFFSET; From edbc39f32fa851ee3315a4ddf18435622af3dd05 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Fri, 19 Sep 2014 10:54:22 +0400 Subject: [PATCH 3/3] print error messages --- src/twister.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/twister.cpp b/src/twister.cpp index 0c347f11..c5ffa44e 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -142,6 +142,9 @@ torrent_handle startTorrentUser(std::string const &username, bool following) tparams.save_path= torrentPath.string(); boost::system::error_code ec; boost::filesystem::create_directory(torrentPath, ec); + if (ec) { + fprintf(stderr, "failed to create directory '%s': %s\n", torrentPath.string().c_str(), ec.message().c_str()); + } std::string filename = combine_path(tparams.save_path, to_hex(ih.to_string()) + ".resume"); load_file(filename.c_str(), tparams.resume_data); @@ -269,6 +272,9 @@ void ThreadWaitExtIP() boost::filesystem::path swarmDbPath = GetDataDir() / "swarm" / "db"; boost::filesystem::create_directories(swarmDbPath, ec); + if (ec) { + fprintf(stderr, "failed to create directory '%s': %s\n", swarmDbPath.string().c_str(), ec.message().c_str()); + } m_swarmDb.reset(new CLevelDB(swarmDbPath.string(), 256*1024, false, false)); int listen_port = GetListenPort() + LIBTORRENT_PORT_OFFSET;