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

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

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

--- trunk/RomCheater/Serialization/SearchResultWriter.cs	2013/06/02 20:22:04	448
+++ trunk/RomCheater/Serialization/SearchResultWriter.cs	2013/06/03 01:45:40	456
@@ -65,6 +65,7 @@
         }
         #endregion
 
+        long ResultCountOffset = 0;
         private void WriteHeader(Guid guid)
         {
             try
@@ -86,6 +87,7 @@
                 }
                 // write count (int)
                 binWriter.Write(ResultCount);
+                ResultCountOffset = binWriter.BaseStream.Position - sizeof(int);
             }
             catch (Exception ex)
             {
@@ -98,14 +100,21 @@
             if (Cancelled) { binWriter.Close(); fileStream.Close(); return; }
             try
             {
-                base.Dispose(disposing);
-                // ensure ResultCount and ResultsWritten are equal            
+               
+                //// ensure ResultCount and ResultsWritten are equal            
+                //if (ResultCount != ResultsWritten)
+                //{
+                //    string message = string.Format("ResultCount does not match ResultsWritten: 0x{0:x8} != 0x{1:x8} -- offset: 0x{2:x8}", ResultCount, ResultsWritten, ResultCount - ResultsWritten);
+                //    Logging.logger.Error.WriteLine(message);
+                //    throw new InvalidOperationException(message);
+                //}
                 if (ResultCount != ResultsWritten)
                 {
-                    string message = string.Format("ResultCount does not match ResultsWritten: 0x{0:x8} != 0x{1:x8} -- offset: 0x{2:x8}", ResultCount, ResultsWritten, ResultCount - ResultsWritten);
-                    Logging.logger.Error.WriteLine(message);
-                    throw new InvalidOperationException(message);
+                    // update the number of results written
+                    binWriter.BaseStream.Seek(ResultCountOffset, SeekOrigin.Begin);
+                    binWriter.Write(ResultsWritten);
                 }
+                base.Dispose(disposing);
             }
             catch (Exception ex)
             {

 

  ViewVC Help
Powered by ViewVC 1.1.22