/[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

revision 455 by william, Sun Jun 2 20:22:04 2013 UTC revision 456 by william, Mon Jun 3 01:45:40 2013 UTC
# Line 65  namespace RomCheater.Serialization Line 65  namespace RomCheater.Serialization
65          }          }
66          #endregion          #endregion
67    
68            long ResultCountOffset = 0;
69          private void WriteHeader(Guid guid)          private void WriteHeader(Guid guid)
70          {          {
71              try              try
# Line 86  namespace RomCheater.Serialization Line 87  namespace RomCheater.Serialization
87                  }                  }
88                  // write count (int)                  // write count (int)
89                  binWriter.Write(ResultCount);                  binWriter.Write(ResultCount);
90                    ResultCountOffset = binWriter.BaseStream.Position - sizeof(int);
91              }              }
92              catch (Exception ex)              catch (Exception ex)
93              {              {
# Line 98  namespace RomCheater.Serialization Line 100  namespace RomCheater.Serialization
100              if (Cancelled) { binWriter.Close(); fileStream.Close(); return; }              if (Cancelled) { binWriter.Close(); fileStream.Close(); return; }
101              try              try
102              {              {
103                  base.Dispose(disposing);                
104                  // ensure ResultCount and ResultsWritten are equal                              //// ensure ResultCount and ResultsWritten are equal            
105                    //if (ResultCount != ResultsWritten)
106                    //{
107                    //    string message = string.Format("ResultCount does not match ResultsWritten: 0x{0:x8} != 0x{1:x8} -- offset: 0x{2:x8}", ResultCount, ResultsWritten, ResultCount - ResultsWritten);
108                    //    Logging.logger.Error.WriteLine(message);
109                    //    throw new InvalidOperationException(message);
110                    //}
111                  if (ResultCount != ResultsWritten)                  if (ResultCount != ResultsWritten)
112                  {                  {
113                      string message = string.Format("ResultCount does not match ResultsWritten: 0x{0:x8} != 0x{1:x8} -- offset: 0x{2:x8}", ResultCount, ResultsWritten, ResultCount - ResultsWritten);                      // update the number of results written
114                      Logging.logger.Error.WriteLine(message);                      binWriter.BaseStream.Seek(ResultCountOffset, SeekOrigin.Begin);
115                      throw new InvalidOperationException(message);                      binWriter.Write(ResultsWritten);
116                  }                  }
117                    base.Dispose(disposing);
118              }              }
119              catch (Exception ex)              catch (Exception ex)
120              {              {

Legend:
Removed from v.455  
changed lines
  Added in v.456

  ViewVC Help
Powered by ViewVC 1.1.22