Esempio n. 1
0
        /// <summary>
        /// Computes Adler32 for byte array
        /// </summary>
        public static uint ForBytes(byte[] buff)
        {
            var adler = new Adler32();

            adler.Add(buff);
            return(adler.m_Value);
        }
Esempio n. 2
0
        /// <summary>
        /// Computes Adler32 for binary string representation (in-memory)
        /// </summary>
        public static uint ForString(string text)
        {
            if (text.IsNullOrWhiteSpace()) return 0;

            var adler = new Adler32();
            adler.Add( text );
            return adler.m_Value;
        }
Esempio n. 3
0
          /// <summary>
          /// Computes Adler32 for binary string representation (in-memory)
          /// </summary>
          public static uint ForString(string text)
          {
            if (text.IsNullOrWhiteSpace()) return 0;

            var adler = new Adler32();
            for(var i=0; i<text.Length; i++)
             adler.Add( text[i] );

            return adler.m_Value;
          }
Esempio n. 4
0
        /// <summary>
        /// Computes Adler32 for binary string representation (in-memory)
        /// </summary>
        public static uint ForString(string text)
        {
            if (text.IsNullOrWhiteSpace())
            {
                return(0);
            }

            var adler = new Adler32();

            adler.Add(text);
            return(adler.m_Value);
        }
Esempio n. 5
0
File: Adler32.cs Progetto: ame89/nfx
        /// <summary>
        /// Computes Adler32 for binary string representation (in-memory)
        /// </summary>
        public static uint ForString(string text)
        {
            if (text.IsNullOrWhiteSpace())
            {
                return(0);
            }

            var adler = new Adler32();

            for (var i = 0; i < text.Length; i++)
            {
                adler.Add(text[i]);
            }

            return(adler.m_Value);
        }
Esempio n. 6
0
 /// <summary>
 /// Computes Adler32 for byte array
 /// </summary>
 public static uint ForBytes(byte[] buff)
 {
     var adler = new Adler32();
     adler.Add( buff );
     return adler.m_Value;
 }
Esempio n. 7
0
      private static void buildDirLevel(ConfigSectionNode pNode, FileSystemDirectory directory)
      {
        const int BUFF_SIZE = 64 * 1024;

        foreach(var sdn in directory.SubDirectoryNames)
          using(var sdir = directory.GetSubDirectory(sdn))
          {
            var dnode = pNode.AddChildNode(CONFIG_DIR_SECTION);
            dnode.AddAttributeNode(CONFIG_NAME_ATTR, sdir.Name);
            buildDirLevel(dnode, sdir);
          }

        foreach(var fn in directory.FileNames.Where(fn => !string.Equals(fn, MANIFEST_FILE_NAME, StringComparison.InvariantCultureIgnoreCase)))
          using(var file = directory.GetFile(fn))
          {
            var fnode = pNode.AddChildNode(CONFIG_FILE_SECTION);
            fnode.AddAttributeNode(CONFIG_NAME_ATTR, file.Name);
          
            long size = 0;
            var csum = new Adler32();
            var buff = new byte[BUFF_SIZE];
            using(var fs = file.FileStream)
              while(true)
              {
                var read = fs.Read(buff, 0, BUFF_SIZE);
                if (read<=0) break;
                size += read;
                csum.Add(buff, 0, read); 
              }

            fnode.AddAttributeNode(CONFIG_SIZE_ATTR, size);
            fnode.AddAttributeNode(CONFIG_CSUM_ATTR, csum.Value);
          }
      
      }