Ejemplo n.º 1
0
 public void SectionStop(PerfSection section)
 {
     if (mbLogPerf)
     {
         PerfLogWrite(format(mStackLevel) + section.ToString(), true);
     }
     mStackLevel--;
 }
Ejemplo n.º 2
0
 public void SectionStart(PerfSection section)
 {
     mStackLevel++;
     if (mbLogPerf)
     {
         PerfLogWrite(format(mStackLevel) + section.ToString(), true);
     }
 }
Ejemplo n.º 3
0
        public bool SaveData(string fileName, bool overwrite, bool checkReadOnly)
        {
            try
            {
                using (PerfSection p = new PerfSection("SaveData() " + Path.GetFileName(fileName)))
                {
                    if (File.Exists(fileName))
                    {
                        if (!overwrite)
                        {
                            return(false);
                        }
                        if (checkReadOnly && File.GetAttributes(fileName) == FileAttributes.ReadOnly)
                        {
                            return(false);
                        }
                        File.SetAttributes(fileName, FileAttributes.Normal);
                        File.Delete(fileName);
                    }

                    DiskFile zipFile = new DiskFile(fileName);
                    zipFile.Create();

                    if (!zipFile.Exists)
                    {
                        return(false);
                    }
                    ZipArchive zip = new ZipArchive(zipFile);

                    Dictionary <string, IDataStream> .Enumerator it = mStreams.GetEnumerator();
                    while (it.MoveNext() != false)
                    {
                        AbstractFile   md = zip.CreateFile(it.Current.Key, true);
                        Stream         s  = md.OpenWrite(true);
                        BufferedStream bs = null;
                        if (CoreGlobals.OutOfMemory == false)
                        {
                            bs = new BufferedStream(s, 10000000); //~10mb buffer
                            it.Current.Value.Save(bs);
                        }
                        else
                        {
                            it.Current.Value.Save(s);
                        }


                        if (bs != null)
                        {
                            bs.Flush();
                            bs.Close();
                        }
                        else
                        {
                            s.Close();
                        }
                    }
                }
                return(true);
            }
            catch (System.Exception ex)
            {
                CoreGlobals.FatalEdDataSaveError = true;
                throw ex;
            }
            return(false);
        }