private static DataMetaInfo MakeDataMetaInfo(string downloadPath,
                                                     byte[] torrentBytes, bool onDemand)
        {
            DataMetaInfo ret = new DataMetaInfo();

            ret.DataUri      = new Uri(downloadPath);
            ret.TorrentBytes = torrentBytes;
            ret.OnDemand     = onDemand;
            // @TODO: For now we keep the "Files" field but with torrent bytes included,
            // it's redundant.
            Torrent torrent = Torrent.Load(torrentBytes);

            if (torrent.Files.Length > 1)
            {
                // In a single file case, MonoTorrent adds this single file to the list but in
                // BitTorrent protocol, the files key shouldn't present, so the list should be
                // empty.
                foreach (var torrentFile in torrent.Files)
                {
                    ret.Files.Add(new Uri(torrentFile.Path, UriKind.Relative));
                }
            }
            return(ret);
        }
Beispiel #2
0
 private static DataMetaInfo MakeDataMetaInfo(string downloadPath,
     byte[] torrentBytes, bool onDemand)
 {
     DataMetaInfo ret = new DataMetaInfo();
       ret.DataUri = new Uri(downloadPath);
       ret.TorrentBytes = torrentBytes;
       ret.OnDemand = onDemand;
       // @TODO: For now we keep the "Files" field but with torrent bytes included,
       // it's redundant.
       Torrent torrent = Torrent.Load(torrentBytes);
       if (torrent.Files.Length > 1) {
     // In a single file case, MonoTorrent adds this single file to the list but in
     // BitTorrent protocol, the files key shouldn't present, so the list should be
     // empty.
     foreach (var torrentFile in torrent.Files) {
       ret.Files.Add(new Uri(torrentFile.Path, UriKind.Relative));
     }
       }
       return ret;
 }