From 4070c2d4659ec8449af46f0de91e603e3b4241c2 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 25 Jan 2011 08:21:01 +0000 Subject: [PATCH] fixed stat_file issue on windows --- include/libtorrent/file.hpp | 2 +- src/file.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 8a45a5b03..a98e35a9b 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -109,7 +109,7 @@ namespace libtorrent }; enum stat_flags_t { dont_follow_links = 1 }; - TORRENT_EXPORT void stat_file(std::string const& f, file_status* s + TORRENT_EXPORT void stat_file(std::string f, file_status* s , error_code& ec, int flags = 0); TORRENT_EXPORT void rename(std::string const& f , std::string const& newf, error_code& ec); diff --git a/src/file.cpp b/src/file.cpp index 964036ca1..0038db640 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -135,10 +135,17 @@ BOOST_STATIC_ASSERT((libtorrent::file::no_buffer & libtorrent::file::attribute_m namespace libtorrent { - void stat_file(std::string const& inf, file_status* s + void stat_file(std::string inf, file_status* s , error_code& ec, int flags) { ec.clear(); +#ifdef TORRENT_WINDOWS + // apparently windows doesn't expect paths + // to directories to ever end with a \ or / + if (!inf.empty() && (inf[inf.size() - 1] == '\\' + || inf[inf.size() - 1] == '/')) + inf.resize(inf.size() - 1); +#endif #if TORRENT_USE_WSTRING && defined TORRENT_WINDOWS std::wstring f = convert_to_wstring(inf);