mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-17 23:52:30 +00:00
* Expand ~ in paths, all uses should be covered.
* Moved option file parsing to VariableMap and added "import" and "try_import" options for loading option files. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@636 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+11
-6
@@ -40,6 +40,7 @@
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <sigc++/signal.h>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
@@ -217,15 +218,19 @@ Download::receive_chunk_failed(__UNUSED uint32_t idx) {
|
||||
|
||||
// Clean up.
|
||||
void
|
||||
Download::set_root_directory(const std::string& d) {
|
||||
if (d.empty())
|
||||
Download::set_root_directory(const std::string& path) {
|
||||
if (path.empty()) {
|
||||
m_download.set_root_dir("./" + (m_download.size_file_entries() > 1 ? m_download.name() : std::string()));
|
||||
else
|
||||
m_download.set_root_dir(d +
|
||||
(*d.rbegin() != '/' ? "/" : "") +
|
||||
|
||||
} else {
|
||||
std::string fullPath = rak::path_expand(path);
|
||||
|
||||
m_download.set_root_dir(fullPath +
|
||||
(*fullPath.rbegin() != '/' ? "/" : "") +
|
||||
(m_download.size_file_entries() > 1 ? m_download.name() : ""));
|
||||
}
|
||||
|
||||
m_download.bencode().get_key("rtorrent").insert_key("directory", d);
|
||||
m_download.bencode().get_key("rtorrent").insert_key("directory", path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ private:
|
||||
const char* connection_current() const { return connection_type_to_string(m_download.connection_type()); }
|
||||
void set_connection_current(const std::string& t) { return m_download.set_connection_type(string_to_connection_type(t.c_str())); }
|
||||
|
||||
void set_root_directory(const std::string& d);
|
||||
void set_root_directory(const std::string& path);
|
||||
|
||||
torrent::Download m_download;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/bencode.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
@@ -108,7 +109,7 @@ DownloadFactory::receive_load() {
|
||||
m_variables.set("tied_to_file", (int64_t)false);
|
||||
|
||||
} else {
|
||||
m_stream = new std::fstream(m_uri.c_str(), std::ios::in);
|
||||
m_stream = new std::fstream(rak::path_expand(m_uri).c_str(), std::ios::in);
|
||||
|
||||
if (m_stream->good())
|
||||
receive_loaded();
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/bencode.h>
|
||||
#include <torrent/exceptions.h>
|
||||
@@ -82,9 +83,9 @@ DownloadStore::set_path(const std::string& path) {
|
||||
throw torrent::input_error("Tried to change session directory while it is enabled.");
|
||||
|
||||
if (!path.empty() && *path.rbegin() != '/')
|
||||
m_path = path + '/';
|
||||
m_path = rak::path_expand(path + '/');
|
||||
else
|
||||
m_path = path;
|
||||
m_path = rak::path_expand(path);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user