Beispiel #1
0
 public V8File(V8Catalog _parent, String _name, V8File _previous, int _start_data, int _start_header, DateTime _time_create, DateTime _time_modify)
 {
     IsDestructed     = false;
     Flushed          = false;
     Parent           = _parent;
     Name             = _name;
     Previous         = _previous;
     Next             = null;
     Data             = null;
     StartData        = _start_data;
     StartHeader      = _start_header;
     IsDataModified   = (StartData != 0 ? true : false);
     IsHeaderModified = (StartHeader != 0 ? true : false);
     if (Previous != null)
     {
         Previous.Next = this;
     }
     else
     {
         Parent.First = this;
     }
     ISCatalog  = FileIsCatalog.iscatalog_unknown;
     Self       = null;
     IsOpened   = false;
     TimeCreate = _time_create;
     TimeModify = _time_modify;
     SelfZipped = false;
     if (Parent != null)
     {
         Parent.Files[Name.ToUpper()] = this;
     }
 }
Beispiel #2
0
 public void close()
 {
     cat = null;
     if (stream != rstream)
     {
         stream.Dispose();
         rstream.Dispose();
     }
     else
     {
         stream.Dispose();
     }
     stream  = null;
     rstream = null;
     if (!string.IsNullOrEmpty(fname))
     {
         System.IO.File.Delete(fname);
     }
     if (!string.IsNullOrEmpty(rfname))
     {
         System.IO.File.Delete(rfname);
     }
     fname  = "";
     rfname = "";
 }
Beispiel #3
0
        public void Close()
        {
            int _t = 0;

            if (Parent == null)
            {
                return;
            }

            if (!IsOpened)
            {
                return;
            }

            if (Self != null)
            {
                if (Self.is_destructed)
                {
                    Self = null;
                }
            }
            Self = null;

            if (Parent.Data != null)
            {
                if (IsDataModified || IsHeaderModified)
                {
                    if (IsDataModified)
                    {
                        StartData = Parent.WriteDataBlock(Data, StartData, SelfZipped);
                    }
                    if (IsHeaderModified)
                    {
                        MemoryStream hs = new MemoryStream();
                        hs.Write(BitConverter.GetBytes(TimeCreate.Ticks), 0, 8);
                        hs.Write(BitConverter.GetBytes(TimeModify.Ticks), 0, 8);
                        hs.Write(BitConverter.GetBytes(_t), 0, 4);
                        hs.Write(Encoding.UTF8.GetBytes(Name), 0, Name.Length);
                        hs.Write(BitConverter.GetBytes(_t), 0, 4);

                        StartHeader = Parent.WriteBlock(hs, StartHeader, false);
                        hs.Dispose();
                    }
                }
            }
            Data.Dispose();
            Data             = null;
            ISCatalog        = FileIsCatalog.iscatalog_false;
            IsOpened         = false;
            IsDataModified   = false;
            IsHeaderModified = false;
        }
Beispiel #4
0
        public int WriteAndClose(Stream _Stream, int Length = -1) // перезапись целиком и закрытие файла (для экономии памяти не используется data файла)
        {
            int _t = 0;

            if (!IsOpened)
            {
                if (!Open())
                {
                    return(0);
                }
            }

            if (Parent == null)
            {
                return(0);
            }

            if (Self != null)
            {
                Self = null;
            }

            Data.Dispose();
            Data = null;

            if (Parent.Data != null)
            {
                StartData = Parent.WriteDataBlock(_Stream, StartData, SelfZipped, Length);
                MemoryStream hs = new MemoryStream();
                hs.Write(BitConverter.GetBytes(TimeCreate.Ticks), 0, 8);
                hs.Write(BitConverter.GetBytes(TimeModify.Ticks), 0, 8);
                hs.Write(BitConverter.GetBytes(_t), 0, 4);
                hs.Write(Encoding.UTF8.GetBytes(Name), 0, Name.Length);
                hs.Write(BitConverter.GetBytes(_t), 0, 4);

                StartHeader = Parent.WriteBlock(hs, StartHeader, false);
                hs.Dispose();
            }
            ISCatalog        = FileIsCatalog.iscatalog_unknown;
            IsOpened         = false;
            IsDataModified   = false;
            IsHeaderModified = false;

            if (Length == -1)
            {
                return((int)_Stream.Length);
            }

            return(Length);
        }
Beispiel #5
0
        /// <summary>
        /// сохранение конфигурации в файл
        /// </summary>
        /// <param name="_filename"></param>
        /// <returns></returns>
        public bool save_config(String _filename)
        {
            V8Catalog c;
            V8File    f;

            Container_file tf;
            int            i, j, prevj, size;

            if (!ready)
            {
                return(false);
            }

            size  = files.Count;
            prevj = 101;

            if (File.Exists(_filename))
            {
                File.Delete(_filename);
            }
            c = new V8Catalog(_filename, false);

            i = 1;
            foreach (var item_files in files)
            {
                j = i * 100 / size;
                if (j != prevj)
                {
                    prevj = j;
                }
                tf = item_files.Value;
                if (!tf.ropen())
                {
                    f = c.CreateFile(tf.Name);
                    //f.SetTimeCreate(tf.File.Ft_create);
                    //f.SetTimeModify(tf.File.Ft_modify);
                    f.WriteAndClose(tf.Rstream);
                    tf.close();
                }
                ++i;
            }
            return(true);
        }
Beispiel #6
0
        public void DeleteFile()
        {
            if (Parent != null)
            {
                if (Next != null)
                {
                    Next.Previous = Previous;
                }
                else
                {
                    Parent.Last = Previous;
                }

                if (Previous != null)
                {
                    Previous.Next = Next;
                }
                else
                {
                    Parent.First = Next;
                }

                Parent.is_fatmodified = true;
                Parent.FreeBlock(StartData);
                Parent.FreeBlock(StartHeader);
                Parent.Files.Remove(Name.ToUpper());
                Parent = null;
            }
            Data = null;
            if (Self != null)
            {
                Self.Data = null;
                Self      = null;
            }
            ISCatalog        = FileIsCatalog.iscatalog_false;
            Next             = null;
            Previous         = null;
            IsOpened         = false;
            StartData        = 0;
            StartHeader      = 0;
            IsDataModified   = false;
            IsHeaderModified = false;
        }
Beispiel #7
0
        public V8Catalog GetCatalog()
        {
            V8Catalog ret = null;

            if (IsCatalog())
            {
                if (Self != null)
                {
                    Self = new V8Catalog(this);
                }
                ret = Self;
            }
            else
            {
                ret = null;
            }

            return(ret);
        }
Beispiel #8
0
 public ConfigStorageCFFile(string fname)
 {
     filename = fname;
     cat      = new V8Catalog(filename);
 }
Beispiel #9
0
 private bool Recursive_test_stream_format(V8Catalog cat, String path)
 {
     return(true);
 }