Exemplo n.º 1
0
        public Index(string nm, ushort kl, DateTime udTime)
        {
            int sz = DataFile.GetSize(Root);

            if (DataFile.Exists(nm, "Index"))
            {
                File = DataFile.Open(nm, "Index", FileMode.Open);
                File.Read(Root, DataFile.coSignatureSz, sz);
                if (DateTime.Compare(Root.LastUpdate, udTime) >= 0 && Root.Closed)
                {
                    Root.Closed = false;
                    File.Lock(Root);
                    File.Write(Root);
                    return;
                }
                File.Close();
                DataFile.Delete(nm, "Index");
            }
            File = DataFile.Open(nm, "Index", FileMode.CreateNew);
            DataFile.Blank(Root, sz);
            Root.KeyLength = kl;
            Root.Closed    = false;
            Root.PageSize  = (ushort)DataFile.GetSize(new IdxPage(0, 0, 0, kl));
            File.Append(Root, sz);
            File.Lock(Root);
        }
Exemplo n.º 2
0
        internal void Close(Table obj)
        {
            SyncOpen.WaitOne();
            View vw = obj.Order;

            obj.LoTable = null;
            obj.Order   = null;
            if (vw != null && vw.Close())
            {
                SyncView.WaitOne();
                ViewList.Remove(vw.getkey);
                SyncView.ReleaseMutex();
            }
            if (OpenCount == 1)
            {
                string tmpfile = "";
                if (MustPack)
                {
                    Struct.LastUpdate = DateTime.Now;
                    tmpfile           = String.Format("{0}{1:yyyy}{1:MM}{1:dd}{1:HH}{1:mm}{1:ss}", Alias, Struct.LastUpdate);
                    File.CopyTo(tmpfile, "BackupTable");
                    long r, w, x;
                    w = 1;
                    x = Struct.RowCount;
                    for (r = 1; r <= x; r++)
                    {
                        Read(obj, r);
                        if (!Deleted(obj))
                        {
                            if (w != r)
                            {
                                obj.Buffer.Position = Data + (w - 1) * Struct.RowLength;
                                File.Write(obj);
                            }
                            w++;
                        }
                    }
                    Struct.LastUpdate = DateTime.Now;
                    Struct.RowCount   = w - 1;
                    File.LoFile.SetLength(Data + Struct.RowLength * Struct.RowCount);
                }
                File.Write(Struct);
                File.Close();
                if (MustPack)
                {
                    DataFile.Delete(tmpfile, "BackupTable");
                }
                OpenList.Remove(Alias);
            }
            else
            {
                OpenCount--;
            }
            SyncOpen.ReleaseMutex();
        }
Exemplo n.º 3
0
 public void Close()
 {
     Root.Closed = true;
     File.Write(Root);
     File.Close();
 }