* added support for storing symbolic links in .torrent files
This commit is contained in:
@@ -164,6 +164,9 @@ namespace libtorrent
|
||||
std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem::path const& p);
|
||||
std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem::wpath const& p);
|
||||
|
||||
fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::path const& p);
|
||||
fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::wpath const& p);
|
||||
|
||||
template <class Pred, class Str, class PathTraits>
|
||||
void add_files_impl(file_storage& fs, boost::filesystem::basic_path<Str, PathTraits> const& p
|
||||
, boost::filesystem::basic_path<Str, PathTraits> const& l, Pred pred)
|
||||
@@ -191,7 +194,16 @@ namespace libtorrent
|
||||
{
|
||||
int file_flags = get_file_attributes(f);
|
||||
std::time_t mtime = get_file_mtime(f);
|
||||
fs.add_file(l, file_size(f), file_flags, mtime);
|
||||
//Masking all bits to check if the file is a symlink
|
||||
if(file_flags & file_storage::attribute_symlink)
|
||||
{
|
||||
fs::path sym_path = get_symlink_path(f);
|
||||
fs.add_file(l, 0 ,file_flags, mtime, sym_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
fs.add_file(l, file_size(f), file_flags, mtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -57,8 +57,10 @@ namespace libtorrent
|
||||
struct TORRENT_EXPORT file_entry
|
||||
{
|
||||
file_entry(): offset(0), size(0), file_base(0)
|
||||
, pad_file(false), hidden_attribute(false)
|
||||
, executable_attribute(false) {}
|
||||
, mtime(0), pad_file(false), hidden_attribute(false)
|
||||
, executable_attribute(false)
|
||||
, symlink_attribute(false)
|
||||
{}
|
||||
|
||||
fs::path path;
|
||||
size_type offset; // the offset of this file inside the torrent
|
||||
@@ -71,6 +73,8 @@ namespace libtorrent
|
||||
bool pad_file:1;
|
||||
bool hidden_attribute:1;
|
||||
bool executable_attribute:1;
|
||||
bool symlink_attribute:1;
|
||||
fs::path symlink_path;
|
||||
};
|
||||
|
||||
struct TORRENT_EXPORT file_slice
|
||||
@@ -93,15 +97,16 @@ namespace libtorrent
|
||||
{
|
||||
pad_file = 1,
|
||||
attribute_hidden = 2,
|
||||
attribute_executable = 4
|
||||
attribute_executable = 4,
|
||||
attribute_symlink = 8
|
||||
};
|
||||
|
||||
void add_file(file_entry const& e);
|
||||
void add_file(fs::path const& p, size_type size, int flags = 0, std::time_t mtime = 0);
|
||||
void add_file(fs::path const& p, size_type size, int flags = 0, std::time_t mtime = 0, fs::path const& s_p = "");
|
||||
void rename_file(int index, std::string const& new_filename);
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
void add_file(fs::wpath const& p, size_type size, int flags = 0, std::time_t mtime = 0);
|
||||
void add_file(fs::wpath const& p, size_type size, int flags = 0, std::time_t mtime = 0, fs::path const& s_p = "");
|
||||
void rename_file(int index, std::wstring const& new_filename);
|
||||
void set_name(std::wstring const& n);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user