コード例 #1
0
ファイル: G2File.cs プロジェクト: nikkolasg/gnutella2
 private static bool isPartialFile(G2PacketH hit)
 {
     G2Packet part = hit.getFirstChildPacket(G2PacketType.PART);
     if (part != null)
         return true;
     return false;
 }
コード例 #2
0
ファイル: G2File.cs プロジェクト: nikkolasg/gnutella2
        /**
         * Get a URL link if present
         * IF not present , it has to beretrieved by HTTP request
         * */
        private static string getDownloadLink(G2PacketH hit)
        {
            G2Packet pack = hit.getFirstChildPacket (G2PacketType.URL);
            if (pack == null)
                return "";
            G2PacketURL url = pack as G2PacketURL;
            if (url == null)
                return "";

            return url.Str;
        }
コード例 #3
0
ファイル: G2File.cs プロジェクト: nikkolasg/gnutella2
        /**
         * Return the size of the file and the name with the out parameters name
         * */
        private static long getNameAndSizeFromHit(G2PacketH hit, out string name)
        {
            G2Packet SZ,DN;
            DN = hit.getFirstChildPacket (G2PacketType.DN);
            SZ = hit.getFirstChildPacket (G2PacketType.SZ);
            name = "";
            if (DN == null) // no name
                return 0;
            // object size packet is not present
            // so we parse DN with a 32 bit integer before
            if ( SZ == null) {
                byte[] bytes = ((G2PacketDN)DN).bytes;
                byte[] bName = bytes.SubArray (4, bytes.Length - 4);
                long size = BinaryUtils.getVariableIntLE (bytes, 4);
                name = BinaryUtils.getStringFromBytes (bName, (int)(bytes.Length - 4));
                return size;

            } else {
                name = ((G2PacketDN)DN).Str;
                return ((G2PacketSZ)SZ).Size;

            }
        }
コード例 #4
0
ファイル: G2File.cs プロジェクト: nikkolasg/gnutella2
 /**
  * Return creation time in DateTime format if present
  * otherwise return current time
  * */
 private static DateTime getCreationTimeFromHit(G2PacketH hit)
 {
     G2Packet pack = hit.getFirstChildPacket (G2PacketType.CT);
     if (pack == null)
         return DateTime.Now;
     G2PacketCT ct = pack as G2PacketCT;
     return BinaryUtils.UnixTimeStampToDateTime (ct.Timestamp);
 }