fixed boost.filesystem usage to not rely on deprecated functions

This commit is contained in:
Arvid Norberg 2008-11-21 23:38:07 +00:00
parent 446d3b51f0
commit 357d548bb5
7 changed files with 21 additions and 18 deletions

View File

@ -551,7 +551,7 @@ void scan_dir(path const& dir_path
for (directory_iterator i(dir_path), end; i != end; ++i)
{
if (extension(*i) != ".torrent") continue;
std::string file = i->string();
std::string file = i->path().string();
handles_t::iterator k = handles.find(file);
if (k != handles.end())

View File

@ -73,8 +73,6 @@ int main(int argc, char* argv[])
int piece_size = 256 * 1024;
char const* creator_str = "libtorrent";
path::default_name_check(no_check);
if (argc != 4 && argc != 5)
{
std::cerr << "usage: make_torrent <output torrent-file> "

View File

@ -161,9 +161,9 @@ namespace libtorrent
{
for (directory_iterator i(f), end; i != end; ++i)
#if BOOST_VERSION < 103600
add_files_impl(fs, p, l / i->leaf(), pred);
add_files_impl(fs, p, l / i->path().leaf(), pred);
#else
add_files_impl(fs, p, l / i->filename(), pred);
add_files_impl(fs, p, l / i->path().filename(), pred);
#endif
}
else
@ -185,7 +185,11 @@ namespace libtorrent
inline void add_files(file_storage& fs, boost::filesystem::path const& file)
{
#if BOOST_VERSION < 103600
detail::add_files_impl(fs, complete(file).branch_path(), file.leaf(), detail::default_pred);
#else
detail::add_files_impl(fs, complete(file).parent_path(), file.filename(), detail::default_pred);
#endif
}
template <class Fun>

View File

@ -139,9 +139,9 @@ namespace libtorrent
#ifdef TORRENT_WINDOWS
#ifdef UNICODE
std::wstring file_path(safe_convert(path.native_file_string()));
std::wstring file_path(safe_convert(path.external_file_string()));
#else
std::string file_path = utf8_native(path.native_file_string());
std::string file_path = utf8_native(path.external_file_string());
#endif
m_file_handle = CreateFile(
@ -173,7 +173,7 @@ namespace libtorrent
| S_IRGRP | S_IWGRP
| S_IROTH | S_IWOTH;
m_fd = ::open(path.native_file_string().c_str()
m_fd = ::open(path.external_file_string().c_str()
, mode, permissions);
if (m_fd == -1)

View File

@ -160,7 +160,7 @@ namespace
// First create branch, by calling ourself recursively
create_directories_win(ph.branch_path());
// Now that parent's path exists, create the directory
std::wstring wph(safe_convert(ph.native_directory_string()));
std::wstring wph(safe_convert(ph.external_directory_string()));
CreateDirectory(wph.c_str(), 0);
return true;
}
@ -208,7 +208,7 @@ namespace
std::time_t last_write_time_win( const fs::path & ph )
{
struct _stat path_stat;
std::wstring wph(safe_convert(ph.native_file_string()));
std::wstring wph(safe_convert(ph.external_file_string()));
if ( ::_wstat( wph.c_str(), &path_stat ) != 0 )
boost::throw_exception( filesystem_error(
"boost::filesystem::last_write_time",
@ -273,9 +273,9 @@ namespace libtorrent
for (basic_directory_iterator<Path> i(old_path), end; i != end; ++i)
{
#if BOOST_VERSION < 103600
recursive_copy(i->path(), new_path / i->leaf(), ec);
recursive_copy(i->path(), new_path / i->path().leaf(), ec);
#else
recursive_copy(i->path(), new_path / i->filename(), ec);
recursive_copy(i->path(), new_path / i->path().filename(), ec);
#endif
if (ec) return;
}
@ -392,7 +392,7 @@ namespace libtorrent
|| (!compact_mode && size < s->first))
{
if (error) *error = "filesize mismatch for file '"
+ i->path.native_file_string()
+ i->path.external_file_string()
+ "', size: " + boost::lexical_cast<std::string>(size)
+ ", expected to be " + boost::lexical_cast<std::string>(s->first)
+ " bytes";
@ -405,7 +405,7 @@ namespace libtorrent
(!compact_mode && (time > s->second + 5 * 60) || time < s->second - 1))
{
if (error) *error = "timestamp mismatch for file '"
+ i->path.native_file_string()
+ i->path.external_file_string()
+ "', modification date: " + boost::lexical_cast<std::string>(time)
+ ", expected to have modification date "
+ boost::lexical_cast<std::string>(s->second);
@ -832,7 +832,7 @@ namespace libtorrent
{
if (i->size != fs->first)
{
error = "file size for '" + i->path.native_file_string()
error = "file size for '" + i->path.external_file_string()
+ "' was expected to be "
+ boost::lexical_cast<std::string>(i->size) + " bytes";
return false;
@ -858,7 +858,7 @@ namespace libtorrent
save_path = complete(save_path);
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 103400
std::wstring wsave_path(safe_convert(save_path.native_file_string()));
std::wstring wsave_path(safe_convert(save_path.external_file_string()));
if (!exists_win(save_path))
CreateDirectory(wsave_path.c_str(), 0);
else if ((GetFileAttributes(wsave_path.c_str()) & FILE_ATTRIBUTE_DIRECTORY) == 0)

View File

@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
using boost::filesystem::remove_all;
using boost::filesystem::create_directory;
using namespace libtorrent;
namespace sf = boost::filesystem;
void print_alerts(libtorrent::session& ses, char const* name
, bool allow_disconnects, bool allow_no_torrents, bool allow_failed_fastresume)
@ -128,7 +129,7 @@ void start_web_server(int port, bool ssl)
std::ofstream f("lighty_config");
f << "server.modules = (\"mod_access\", \"mod_redirect\", \"mod_setenv\")\n"
"server.document-root = \"" << boost::filesystem::initial_path().string() << "\"\n"
"server.document-root = \"" << fs::initial_path<fs::path>().string() << "\"\n"
"server.range-requests = \"enable\"\n"
"server.port = " << port << "\n"
"server.pid-file = \"./lighty" << port << ".pid\"\n"

View File

@ -544,7 +544,7 @@ int test_main()
char* env = std::getenv("TORRENT_TEST_PATHS");
if (env == 0)
{
test_paths.push_back(initial_path());
test_paths.push_back(initial_path<path>());
}
else
{