/[RomCheater]/trunk/RomCheater/Serialization/SerializationWriter.cs
ViewVC logotype

Diff of /trunk/RomCheater/Serialization/SerializationWriter.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Serialization/SerializationWriter.cs	2012/06/21 05:14:38	401
+++ trunk/RomCheater/Serialization/SerializationWriter.cs	2012/06/21 06:30:33	402
@@ -6,23 +6,22 @@
 
 namespace RomCheater.Serialization
 {
-    public interface ISerializationWriter
+    public interface ISerializationResultCount
     {
         int ResultCount { get; }
     }
-    public abstract class SerializationWriter : ISerializationWriter, IDisposable
+    public abstract class SerializationWriter : ISerializationResultCount, IDisposable
     {
         private const string DEFAULT_FOLDER = "tmp";
         private const string DEFAULT_FILENAME = "SerializedMemoryResults.tmp";
         private static string DEFAULT_PATH = string.Format(@"{0}\{1}", DEFAULT_FOLDER,DEFAULT_FILENAME);
         public SerializationWriter() : this(DEFAULT_PATH) { }
-        protected SerializationWriter(string filename) : this(filename, 0) { }
-        public SerializationWriter(int resultCount) : this(DEFAULT_PATH, resultCount) { }
-        public SerializationWriter(string filename, int resultCount) { FileName = filename; ResultCount = resultCount; CreateFile(); }
+        protected SerializationWriter(string filename) : this(filename, 0, true) { }
+        public SerializationWriter(int resultCount) : this(DEFAULT_PATH, resultCount, true) { }
+        public SerializationWriter(string filename, int resultCount, bool delete) { FileName = filename; ResultCount = resultCount; CreateFile(delete); }
 
-        #region ISerializationWriter members
-        public int ResultCount { get; protected set; }
-        
+        #region ISerializationResultCount members
+        public int ResultCount { get; protected set; }        
         #endregion
         private FileStream fileStream;
         protected BinaryWriter binWriter;
@@ -44,9 +43,10 @@
                 return false;
             }
         }
-        private void CreateFile()
+        private void CreateFile(bool delete)
         {
-            DeleteResultFile();
+            if (delete)
+                DeleteResultFile();
             FileInfo fi = new FileInfo(FileName);
             if (!fi.Exists)
             {

 

  ViewVC Help
Powered by ViewVC 1.1.22