Ejemplo n.º 1
0
        public static FileStream OpenLogFile(string filePath)
        {
            FileStream fileStream = null;

            try
            {
                fileStream = CsvFieldCache.OpenFileAndSkipPreamble(filePath);
                if (fileStream == null)
                {
                    return(null);
                }
                string text;
                return(CsvFieldCache.SeekToDataStartOffset(fileStream, out text));
            }
            catch (IOException ex)
            {
                ExTraceGlobals.CommonTracer.TraceError <string>(0L, "CsvFieldCache OpenLogFile failed with error {0}", ex.Message);
            }
            catch (UnauthorizedAccessException ex2)
            {
                ExTraceGlobals.CommonTracer.TraceError <string>(0L, "CsvFieldCache OpenLogFile failed with error {0}", ex2.Message);
            }
            if (fileStream != null)
            {
                fileStream.Close();
            }
            return(null);
        }
Ejemplo n.º 2
0
        private static FileStream SeekToDataStartOffset(FileStream file, out string version)
        {
            int num = -1;

            version = string.Empty;
            byte[] array = new byte[1024];
            bool   flag  = true;
            int    num2;
            int    i;

            for (;;)
            {
                num2 = file.Read(array, 0, array.Length);
                if (num2 == 0)
                {
                    break;
                }
                for (i = 0; i < num2; i++)
                {
                    byte b = array[i];
                    if (flag)
                    {
                        if (b != 35)
                        {
                            goto Block_3;
                        }
                        if (i + "Version:".Length < num2)
                        {
                            string text = CsvFieldCache.DecodeString(array, i + 1, "Version:".Length);
                            if (text.Equals("Version:"))
                            {
                                num = i + "Version:".Length + 1;
                            }
                        }
                        flag = false;
                    }
                    else if (b == 10)
                    {
                        flag = true;
                        if (num != -1)
                        {
                            version = CsvFieldCache.DecodeString(array, num, i - num).Trim();
                            num     = -1;
                        }
                    }
                }
            }
            file.Close();
            return(null);

Block_3:
            file.Seek((long)(i - num2), SeekOrigin.Current);
            return(file);
        }
Ejemplo n.º 3
0
        public bool Find(IComparable key, CsvFieldCache cursor)
        {
            ExTraceGlobals.CommonTracer.TraceDebug((long)this.GetHashCode(), "CsvClusteredIndex Find");
            long position = cursor.Position;
            long num      = cursor.Length;
            bool flag     = false;

            while (position <= num - (long)cursor.ReadSize)
            {
                long num2 = cursor.Seek((num - position) / 2L + position);
                if (!cursor.MoveNext(false))
                {
                    num = num2;
                }
                else
                {
                    object obj = null;
                    while (obj == null && cursor.MoveNext(false))
                    {
                        if (cursor.FieldCount != cursor.SchemaFieldCount)
                        {
                            flag = true;
                        }
                        obj = cursor.GetField(this.idx);
                    }
                    if (obj == null)
                    {
                        num = num2;
                    }
                    else if (key.CompareTo(obj) > 0)
                    {
                        position = cursor.Position;
                    }
                    else
                    {
                        num = num2;
                    }
                }
            }
            cursor.Seek(position);
            bool flag2 = this.Scan(key, cursor);

            return(flag || flag2);
        }
Ejemplo n.º 4
0
        private bool Scan(IComparable key, CsvFieldCache cursor)
        {
            ExTraceGlobals.CommonTracer.TraceDebug((long)this.GetHashCode(), "CsvClusteredIndex Scan");
            bool result = false;

            while (cursor.MoveNext(false))
            {
                if (cursor.FieldCount != cursor.SchemaFieldCount)
                {
                    result = true;
                }
                object field = cursor.GetField(this.idx);
                if (field != null && key.CompareTo(field) <= 0)
                {
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
 public ReadOnlyRow(CsvFieldCache cursor, long position)
 {
     this.cursor   = cursor;
     this.position = position;
 }