mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-13 04:36:16 +00:00
Deprecated rak::path_expand.
This commit is contained in:
@@ -10,8 +10,6 @@ EXTRA_DIST= \
|
||||
rak/address_info.h \
|
||||
rak/algorithm.h \
|
||||
rak/error_number.h \
|
||||
rak/file_stat.h \
|
||||
rak/path.h \
|
||||
rak/partial_queue.h \
|
||||
rak/regex.h \
|
||||
rak/string_manip.h \
|
||||
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
// rak - Rakshasa's toolbox
|
||||
// Copyright (C) 2005-2007, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <sundell.software@gmail.com>
|
||||
|
||||
|
||||
// Various functions for manipulating file paths. Also consider making
|
||||
// a directory iterator.
|
||||
|
||||
#ifndef RAK_PATH_H
|
||||
#define RAK_PATH_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
namespace rak {
|
||||
|
||||
inline std::string
|
||||
path_expand(const std::string& path) {
|
||||
if (path.empty() || path[0] != '~')
|
||||
return path;
|
||||
|
||||
char* home = std::getenv("HOME");
|
||||
|
||||
if (home == NULL)
|
||||
return path;
|
||||
|
||||
return home + path.substr(1);
|
||||
}
|
||||
|
||||
// Don't inline this...
|
||||
//
|
||||
// Same strlcpy as found in *bsd.
|
||||
inline size_t
|
||||
strlcpy(char *dest, const char *src, size_t size) {
|
||||
size_t n = size;
|
||||
const char* first = src;
|
||||
|
||||
if (n != 0) {
|
||||
while (--n != 0)
|
||||
if ((*dest++ = *src++) == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
if (n == 0) {
|
||||
if (size != 0)
|
||||
*dest = '\0';
|
||||
|
||||
while (*src++)
|
||||
;
|
||||
}
|
||||
|
||||
return src - first - 1;
|
||||
}
|
||||
|
||||
inline char*
|
||||
path_expand(const char* src, char* first, char* last) {
|
||||
if (*src == '~') {
|
||||
char* home = std::getenv("HOME");
|
||||
|
||||
if (home == NULL)
|
||||
return first;
|
||||
|
||||
first += strlcpy(first, home, std::distance(first, last));
|
||||
|
||||
if (first > last)
|
||||
return last;
|
||||
|
||||
src++;
|
||||
}
|
||||
|
||||
return std::min(first + strlcpy(first, src, std::distance(first, last)), last);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <functional>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <rak/regex.h>
|
||||
#include <torrent/rate.h>
|
||||
@@ -77,23 +76,23 @@ apply_d_change_link(core::Download* download, const torrent::Object::list_type&
|
||||
|
||||
if (type == "base_path") {
|
||||
target = rpc::call_command_string("d.base_path", rpc::make_target(download));
|
||||
link = rak::path_expand(prefix + rpc::call_command_string("d.base_path", rpc::make_target(download)) + postfix);
|
||||
link = expand_path(prefix + rpc::call_command_string("d.base_path", rpc::make_target(download)) + postfix);
|
||||
|
||||
} else if (type == "base_filename") {
|
||||
target = rpc::call_command_string("d.base_path", rpc::make_target(download));
|
||||
link = rak::path_expand(prefix + rpc::call_command_string("d.base_filename", rpc::make_target(download)) + postfix);
|
||||
link = expand_path(prefix + rpc::call_command_string("d.base_filename", rpc::make_target(download)) + postfix);
|
||||
|
||||
// } else if (type == "directory_path") {
|
||||
// target = rpc::call_command_string("d.directory", rpc::make_target(download));
|
||||
// link = rak::path_expand(prefix + rpc::call_command_string("d.base_path", rpc::make_target(download)) + postfix);
|
||||
|
||||
} else if (type == "tied") {
|
||||
link = rak::path_expand(rpc::call_command_string("d.tied_to_file", rpc::make_target(download)));
|
||||
link = expand_path(rpc::call_command_string("d.tied_to_file", rpc::make_target(download)));
|
||||
|
||||
if (link.empty())
|
||||
return torrent::Object();
|
||||
|
||||
link = rak::path_expand(prefix + link + postfix);
|
||||
link = expand_path(prefix + link + postfix);
|
||||
target = rpc::call_command_string("d.base_path", rpc::make_target(download));
|
||||
|
||||
} else {
|
||||
@@ -131,7 +130,7 @@ apply_d_delete_tied(core::Download* download) {
|
||||
if (tie.empty())
|
||||
return torrent::Object();
|
||||
|
||||
if (::unlink(rak::path_expand(tie).c_str()) == -1)
|
||||
if (::unlink(expand_path(tie).c_str()) == -1)
|
||||
control->core()->push_log_std("Could not unlink tied file: " + std::string(std::strerror(errno)));
|
||||
|
||||
rpc::call_command("d.tied_to_file.set", std::string(), rpc::make_target(download));
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <functional>
|
||||
#include <cstdio>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/hash_string.h>
|
||||
@@ -69,7 +68,7 @@ apply_start_tied() {
|
||||
torrent::utils::FileStat fs;
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
|
||||
|
||||
if (!tied_to_file.empty() && fs.update(rak::path_expand(tied_to_file)))
|
||||
if (!tied_to_file.empty() && fs.update(expand_path(tied_to_file)))
|
||||
rpc::parse_command_single(rpc::make_target(download), "d.try_start=");
|
||||
}
|
||||
|
||||
@@ -85,7 +84,7 @@ apply_stop_untied() {
|
||||
torrent::utils::FileStat fs;
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
|
||||
|
||||
if (!tied_to_file.empty() && !fs.update(rak::path_expand(tied_to_file)))
|
||||
if (!tied_to_file.empty() && !fs.update(expand_path(tied_to_file)))
|
||||
rpc::parse_command_single(rpc::make_target(download), "d.try_stop=");
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ apply_close_untied() {
|
||||
torrent::utils::FileStat fs;
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("d.ignore_commands", rpc::make_target(download)) == 0 && !tied_to_file.empty() && !fs.update(rak::path_expand(tied_to_file)))
|
||||
if (rpc::call_command_value("d.ignore_commands", rpc::make_target(download)) == 0 && !tied_to_file.empty() && !fs.update(expand_path(tied_to_file)))
|
||||
rpc::parse_command_single(rpc::make_target(download), "d.try_close=");
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ apply_remove_untied() {
|
||||
torrent::utils::FileStat fs;
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (!tied_to_file.empty() && !fs.update(rak::path_expand(tied_to_file))) {
|
||||
if (!tied_to_file.empty() && !fs.update(expand_path(tied_to_file))) {
|
||||
// Need to clear tied_to_file so it doesn't try to delete it.
|
||||
rpc::call_command("d.tied_to_file.set", std::string(), rpc::make_target(*itr));
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <rak/path.h>
|
||||
#include <torrent/data/file.h>
|
||||
#include <torrent/data/file_list.h>
|
||||
#include <torrent/data/file_list_iterator.h>
|
||||
|
||||
+10
-46
@@ -1,54 +1,18 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2011, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <sundell.software@gmail.com>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/peer/peer_list.h>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/option_strings.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "command_helpers.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <torrent/peer/peer_list.h>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/option_strings.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "command_helpers.h"
|
||||
|
||||
bool ipv4_range_parse(const char* address, uint32_t* address_start, uint32_t* address_end);
|
||||
|
||||
@@ -89,7 +53,7 @@ apply_ip_tables_get(const torrent::Object::list_type& args) {
|
||||
if (table_itr == ip_tables.end())
|
||||
throw torrent::input_error("Could not find ip table.");
|
||||
|
||||
if (!ipv4_range_parse(address.c_str(), &address_start, &address_end))
|
||||
if (!ipv4_range_parse(address.c_str(), &address_start, &address_end))
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
|
||||
if(!table_itr->table.defined(address_start, address_end))
|
||||
@@ -298,7 +262,7 @@ apply_ipv4_filter_get(const std::string& args) {
|
||||
uint32_t address_start;
|
||||
uint32_t address_end;
|
||||
|
||||
if (!ipv4_range_parse(args.c_str(), &address_start, &address_end))
|
||||
if (!ipv4_range_parse(args.c_str(), &address_start, &address_end))
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
|
||||
if(!torrent::PeerList::ipv4_filter()->defined(address_start, address_end))
|
||||
@@ -326,8 +290,8 @@ apply_ipv4_filter_load(const torrent::Object::list_type& args) {
|
||||
std::string value_name = args.back().as_string();
|
||||
int value = torrent::option_find_string(torrent::OPTION_IP_FILTER, value_name.c_str());
|
||||
|
||||
std::fstream file(rak::path_expand(filename).c_str(), std::ios::in);
|
||||
|
||||
std::fstream file(expand_path(filename).c_str(), std::ios::in);
|
||||
|
||||
if (!file.is_open())
|
||||
throw torrent::input_error("Could not open ip filter file: " + filename);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <functional>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <rak/path.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "core/download.h"
|
||||
#include "core/download_list.h"
|
||||
#include "core/manager.h"
|
||||
#include "rak/path.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
static const int log_flag_use_gz = 0x1;
|
||||
@@ -34,8 +33,8 @@ apply_log_open(int output_flags, const torrent::Object::list_type& args) {
|
||||
|
||||
torrent::Object::list_const_iterator itr = args.begin();
|
||||
|
||||
std::string output_id = (itr++)->as_string();
|
||||
std::string file_name = rak::path_expand((itr++)->as_string());
|
||||
auto output_id = (itr++)->as_string();
|
||||
auto file_name = expand_path((itr++)->as_string());
|
||||
|
||||
if ((output_flags & log_flag_append_pid)) {
|
||||
char buffer[32];
|
||||
@@ -85,7 +84,7 @@ apply_log(const torrent::Object::string_type& arg, int logType) {
|
||||
}
|
||||
|
||||
if (!arg.empty()) {
|
||||
int logFd = open(rak::path_expand(arg).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
int logFd = open(expand_path(arg).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
|
||||
if (logFd < 0)
|
||||
throw torrent::input_error("Could not open execute log file.");
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
#include <rak/address_info.h>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/data/file_manager.h>
|
||||
@@ -125,7 +124,7 @@ apply_scgi(const std::string& arg, int type) {
|
||||
|
||||
case 2:
|
||||
default:
|
||||
path = rak::path_expand(arg);
|
||||
path = expand_path(arg);
|
||||
|
||||
unlink(path.c_str());
|
||||
scgi->open_named(path);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "core/download.h"
|
||||
|
||||
#include <list>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/torrent.h>
|
||||
@@ -19,8 +18,8 @@
|
||||
|
||||
namespace core {
|
||||
|
||||
Download::Download(download_type d) :
|
||||
m_download(d) {
|
||||
Download::Download(download_type d)
|
||||
: m_download(d) {
|
||||
|
||||
m_download.info()->signal_tracker_success().push_back(std::bind(&Download::receive_tracker_msg, this, ""));
|
||||
m_download.info()->signal_tracker_failed().push_back(std::bind(&Download::receive_tracker_msg, this, std::placeholders::_1));
|
||||
@@ -142,7 +141,7 @@ Download::set_root_directory(const std::string& path) {
|
||||
}
|
||||
|
||||
control->core()->download_list()->close_directly(this);
|
||||
file_list->set_root_dir(rak::path_expand(path));
|
||||
file_list->set_root_dir(expand_path(path));
|
||||
|
||||
bencode()->get_key("rtorrent").insert_key("directory", path);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <functional>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/resume.h>
|
||||
#include <torrent/object.h>
|
||||
@@ -123,7 +122,7 @@ DownloadFactory::receive_load() {
|
||||
receive_loaded();
|
||||
|
||||
} else {
|
||||
std::fstream stream(rak::path_expand(m_uri).c_str(), std::ios::in | std::ios::binary);
|
||||
std::fstream stream(expand_path(m_uri).c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
if (!stream.is_open())
|
||||
return receive_failed("Could not open file");
|
||||
@@ -158,8 +157,8 @@ DownloadFactory::receive_commit() {
|
||||
|
||||
void
|
||||
DownloadFactory::receive_success() {
|
||||
auto rtorrent_object = download_factory_load_stream((rak::path_expand(m_uri) + ".rtorrent").c_str());
|
||||
auto libtorrent_resume_object = download_factory_load_stream((rak::path_expand(m_uri) + ".libtorrent_resume").c_str());
|
||||
auto rtorrent_object = download_factory_load_stream((expand_path(m_uri) + ".rtorrent").c_str());
|
||||
auto libtorrent_resume_object = download_factory_load_stream((expand_path(m_uri) + ".libtorrent_resume").c_str());
|
||||
|
||||
uint32_t tracker_key;
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "core/manager.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
@@ -8,7 +10,6 @@
|
||||
#include <sys/select.h>
|
||||
#include <rak/address_info.h>
|
||||
#include <rak/regex.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/utils/resume.h>
|
||||
#include <torrent/object.h>
|
||||
@@ -33,7 +34,6 @@
|
||||
#include "core/download.h"
|
||||
#include "core/download_factory.h"
|
||||
#include "core/http_queue.h"
|
||||
#include "core/manager.h"
|
||||
#include "core/view.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
+1
-36
@@ -1,42 +1,7 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2011, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <sundell.software@gmail.com>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <functional>
|
||||
#include <rak/algorithm.h>
|
||||
#include <rak/path.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -73,7 +38,7 @@ PathInput::receive_do_complete() {
|
||||
size_type dirEnd = find_last_delim();
|
||||
|
||||
utils::Directory dir(dirEnd != 0 ? str().substr(0, dirEnd) : "./");
|
||||
|
||||
|
||||
if (!dir.update(utils::Directory::update_sort | utils::Directory::update_hide_dot) || dir.empty()) {
|
||||
mark_dirty();
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <rak/path.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <torrent/utils/thread.h>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <lua.hpp>
|
||||
#endif
|
||||
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/object.h>
|
||||
|
||||
|
||||
+24
-55
@@ -1,45 +1,11 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2011, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <sundell.software@gmail.com>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <locale>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "parse.h"
|
||||
|
||||
namespace rpc {
|
||||
@@ -90,7 +56,7 @@ parse_string(const char* first, const char* last, std::string* dest, bool (*deli
|
||||
|
||||
dest->push_back(*first++);
|
||||
}
|
||||
|
||||
|
||||
return first;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +66,7 @@ parse_whole_string(const char* first, const char* last, std::string* dest) {
|
||||
first = parse_skip_wspace(first, last);
|
||||
first = parse_string(first, last, dest);
|
||||
first = parse_skip_wspace(first, last);
|
||||
|
||||
|
||||
if (first != last)
|
||||
throw torrent::input_error("Junk at end of input.");
|
||||
}
|
||||
@@ -175,7 +141,7 @@ parse_object(const char* first, const char* last, torrent::Object* dest, bool (*
|
||||
*dest = torrent::Object::create_list();
|
||||
first = parse_list(first + 1, last, dest, &parse_is_delim_block);
|
||||
first = parse_skip_wspace(first, last);
|
||||
|
||||
|
||||
if (first == last || *first != '}')
|
||||
throw torrent::input_error("Could not find closing '}'.");
|
||||
|
||||
@@ -238,7 +204,7 @@ parse_list(const char* first, const char* last, torrent::Object* dest, bool (*de
|
||||
first = parse_skip_wspace(first, last);
|
||||
|
||||
dest->as_list().push_back(tmp);
|
||||
|
||||
|
||||
if (first == last || !parse_is_seperator(*first))
|
||||
break;
|
||||
|
||||
@@ -284,12 +250,12 @@ convert_to_string(const torrent::Object& rawSrc) {
|
||||
|
||||
if (src.as_raw_bencode().is_raw_string())
|
||||
return src.as_raw_bencode().as_raw_string().as_string();
|
||||
|
||||
|
||||
if (src.as_raw_bencode().is_value())
|
||||
return src.as_raw_bencode().as_value_string();
|
||||
|
||||
default: throw torrent::input_error("Not a string.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -341,9 +307,9 @@ convert_list_to_command(torrent::Object::list_const_iterator first,
|
||||
if (first == last)
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
std::string dest = (first++)->as_string();
|
||||
std::string::size_type quoteItr = dest.find('=');
|
||||
|
||||
auto dest = (first++)->as_string();
|
||||
auto quoteItr = dest.find('=');
|
||||
|
||||
if (quoteItr == std::string::npos)
|
||||
throw torrent::input_error("Could not find '=' in command.");
|
||||
|
||||
@@ -419,7 +385,7 @@ convert_to_value_nothrow(const torrent::Object& src, int64_t* value, int base, i
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -430,20 +396,23 @@ print_object(char* first, char* last, const torrent::Object* src, int flags) {
|
||||
{
|
||||
const std::string& str = src->as_string();
|
||||
|
||||
if (first == last)
|
||||
return first;
|
||||
|
||||
if ((flags & print_expand_tilde) && *str.c_str() == '~') {
|
||||
return rak::path_expand(str.c_str(), first, last);
|
||||
auto expanded = expand_path(str);
|
||||
|
||||
} else {
|
||||
if (first == last)
|
||||
return first;
|
||||
|
||||
size_t n = std::min<size_t>(str.size(), std::distance(first, last) - 1);
|
||||
|
||||
std::memcpy(first, str.c_str(), n);
|
||||
size_t n = std::min<size_t>(expanded.size(), std::distance(first, last) - 1);
|
||||
std::memcpy(first, expanded.c_str(), n);
|
||||
*(first += n) = '\0';
|
||||
|
||||
return first;
|
||||
} else {
|
||||
size_t n = std::min<size_t>(str.size(), std::distance(first, last) - 1);
|
||||
std::memcpy(first, str.c_str(), n);
|
||||
*(first += n) = '\0';
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
case torrent::Object::TYPE_VALUE:
|
||||
@@ -480,7 +449,7 @@ print_object_std(std::string* dest, const torrent::Object* src, int flags) {
|
||||
const std::string& str = src->as_string();
|
||||
|
||||
if ((flags & print_expand_tilde) && *str.c_str() == '~')
|
||||
*dest += rak::path_expand(str);
|
||||
*dest += expand_path(str);
|
||||
else
|
||||
*dest += str;
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "rpc/parse.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
#include "rpc/rpc_manager.h"
|
||||
@@ -140,7 +140,7 @@ parse_command_multiple(target_type target, const char* first, const char* last)
|
||||
|
||||
bool
|
||||
parse_command_file(const std::string& path) {
|
||||
std::fstream file(rak::path_expand(path).c_str(), std::ios::in);
|
||||
std::fstream file(expand_path(path).c_str(), std::ios::in);
|
||||
|
||||
if (!file.is_open())
|
||||
return false;
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/utils/log.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "rpc/scgi.h"
|
||||
|
||||
namespace scgi {
|
||||
@@ -90,7 +90,7 @@ ThreadScgi::change_rpc_log() {
|
||||
if (m_rpc_log_filename.empty())
|
||||
return;
|
||||
|
||||
scgi()->set_log_fd(open(rak::path_expand(m_rpc_log_filename).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644));
|
||||
scgi()->set_log_fd(open(expand_path(m_rpc_log_filename).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644));
|
||||
|
||||
if (scgi()->log_fd() == -1) {
|
||||
lt_log_print(torrent::LOG_NOTICE, "Could not open RPC log file '%s'.", m_rpc_log_filename.c_str());
|
||||
|
||||
+6
-40
@@ -1,48 +1,14 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2011, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <sundell.software@gmail.com>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include "utils/directory.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <dirent.h>
|
||||
#include <functional>
|
||||
#include <sys/stat.h>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "directory.h"
|
||||
#include "globals.h"
|
||||
|
||||
namespace utils {
|
||||
|
||||
@@ -52,7 +18,7 @@ Directory::is_valid() const {
|
||||
if (m_path.empty())
|
||||
return false;
|
||||
|
||||
DIR* d = opendir(rak::path_expand(m_path).c_str());
|
||||
DIR* d = opendir(expand_path(m_path).c_str());
|
||||
closedir(d);
|
||||
|
||||
return d;
|
||||
@@ -63,7 +29,7 @@ Directory::update(int flags) {
|
||||
if (m_path.empty())
|
||||
throw torrent::input_error("Directory::update() tried to open an empty path.");
|
||||
|
||||
DIR* d = opendir(rak::path_expand(m_path).c_str());
|
||||
DIR* d = opendir(expand_path(m_path).c_str());
|
||||
|
||||
if (d == NULL)
|
||||
return false;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <rak/path.h>
|
||||
#include "utils/file_status_cache.h"
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/utils/file_stat.h>
|
||||
|
||||
#include "file_status_cache.h"
|
||||
#include "globals.h"
|
||||
|
||||
namespace utils {
|
||||
|
||||
@@ -15,7 +16,7 @@ FileStatusCache::insert(const std::string& path) {
|
||||
// Should we expand somewhere else? Problem is it adds a lot of junk
|
||||
// to the start of the paths added to the cache, causing more work
|
||||
// during search, etc.
|
||||
if (!fs.update(rak::path_expand(path)))
|
||||
if (!fs.update(expand_path(path)))
|
||||
return false;
|
||||
|
||||
std::pair<iterator, bool> result = base_type::insert(value_type(path, file_status()));
|
||||
@@ -40,7 +41,7 @@ FileStatusCache::prune() {
|
||||
torrent::utils::FileStat fs;
|
||||
iterator tmp = itr++;
|
||||
|
||||
if (!fs.update(rak::path_expand(tmp->first)) || tmp->second.m_mtime != (uint32_t)fs.modified_time())
|
||||
if (!fs.update(expand_path(tmp->first)) || tmp->second.m_mtime != (uint32_t)fs.modified_time())
|
||||
base_type::erase(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <cinttypes>
|
||||
|
||||
namespace utils {
|
||||
|
||||
@@ -31,8 +32,6 @@ public:
|
||||
|
||||
using base_type::erase;
|
||||
|
||||
// static int flag_
|
||||
|
||||
// Insert and return true if the entry does not exist or the new
|
||||
// file's mtime is more recent.
|
||||
bool insert(const std::string& path);
|
||||
|
||||
Reference in New Issue
Block a user