Implement method to verify and write torrent files and file manifests to disk.
Also add some helper methods to file manifest and torrent file get add useful info encapsulated
in the name. Lastly fixed an apart bug in load_directory helper related to files from
boost::directory_iterator being in an arbitrary rather than lexicographical order.
Change-Id: I8a2c2f3224caec65cf97a418785778234a0d4d73
diff --git a/src/file-manifest.hpp b/src/file-manifest.hpp
index 8c4680a..8366db2 100644
--- a/src/file-manifest.hpp
+++ b/src/file-manifest.hpp
@@ -141,6 +141,14 @@
data_packet_size() const;
/// Returns the 'data_packet_size' of this FileManifest
+ size_t
+ submanifest_number() const;
+ /// Return the submanifest number for this FileManifest
+
+ std::string
+ file_name() const;
+ /// Return the file name for this FileManifest
+
std::shared_ptr<Name>
submanifest_ptr() const;
/// Returns the 'submanifest_ptr' of this FileManifest, or 'nullptr' is none exists
@@ -301,6 +309,19 @@
return m_submanifestPtr;
}
+inline std::string
+FileManifest::file_name() const
+{
+ return name().getSubName(1, name().size() - 2).toUri();
+}
+
+
+inline size_t
+FileManifest::submanifest_number() const
+{
+ return name().get(name().size() - 1).toSequenceNumber();
+}
+
inline void
FileManifest::set_submanifest_ptr(std::shared_ptr<Name> subManifestPtr)
{