Exemplo n.º 1
0
 private void CheckFileProperties(string[] filePathList, BencodedInteger fileLength)
 {
     if (filePathList == null || fileLength == null)
         throw new TorrentException(string.Format("Invalid metadata, 'path'/'length' not of expected type."));
 }
Exemplo n.º 2
0
 private List<byte[]> GetRawChecksums(BencodedDictionary info, BencodedInteger pieceLength)
 {
     byte[] rawChecksums = (info["pieces"] as BencodedString).Select(c=>(byte)c).ToArray();
     if (pieceLength == null || rawChecksums == null || rawChecksums.Length%ChecksumSize != 0)
         throw new TorrentException(
             string.Format(
                 "Invalid metadata, 'piece length'/'pieces' not of expected type, or invalid length of 'pieces'."));
     IEnumerable<byte[]> slicedChecksums = rawChecksums.Batch(ChecksumSize).Select(e => e.ToArray());
     return slicedChecksums.ToList();
 }
Exemplo n.º 3
0
 private void CheckFileLength(BencodedInteger fileLength)
 {
     if (fileLength == null)
         throw new TorrentException(string.Format("Invalid metadata, 'length' not of expected type."));
 }