Beispiel #1
0
 private static void Lock7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, long position, long length)
 {
     // (JJ)V
     // (JJ)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__real.Lock(position, length);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Beispiel #2
0
        /// <summary>
        /// ファイルからCRC32を計算。返し値がCRC32。
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public UInt32 Update(global::System.IO.FileStream file)
        {
            unchecked
            {
                byte[] buffer   = new byte[BUFFER_SIZE];
                int    readSize = BUFFER_SIZE;

                UInt32 crc = HighBitMask;

                try
                {
                    file.Lock(0, file.Length);

                    int count = file.Read(buffer, 0, readSize);
                    while (count > 0)
                    {
                        for (int i = 0; i < count; i++)
                        {
                            crc = ((crc) >> 8) ^ CRCTable[(buffer[i]) ^ ((crc) & 0x000000FF)];
                        }
                        //	↑は crc = update_crc32(buffer[i], crc); と等価。

                        count = file.Read(buffer, 0, readSize);
                    }

                    file.Unlock(0, file.Length);
                }
                catch (global::System.Exception e)
                {
                    throw e;
                }

                crc          = ~crc;
                LifetimeCRC ^= crc;
                return(crc);
            }
        }