Exemple #1
0
 private void SetStream(Stream source, Stream target)
 {
     try
     {
         MemoryStream memStream = source as MemoryStream;
         if (memStream != null)
         {
             memStream.WriteTo(target);
         }
         else
         {
             JetMemoryStream jmStream = source as JetMemoryStream;
             if (jmStream != null)
             {
                 jmStream.WriteTo(target);
             }
             else
             {
                 try
                 {
                     if (source.CanSeek)
                     {
                         source.Position = 0;
                     }
                     CopyStream(target, source, _bfs.GetRawBytes());
                 }
                 finally
                 {
                     source.Close();
                 }
             }
         }
     }
     finally
     {
         target.Close();
     }
 }
Exemple #2
0
 public BlobFSMemoryStream(int handle, BlobFileSystem bfs)
     : base(1024)
 {
     _handle = handle;
     _bfs    = bfs;
     bfs.Lock();
     try
     {
         CopyStream(this, bfs.GetRawStream(handle), bfs.GetRawBytes());
     }
     catch
     {
         SetLength(0);
         bfs.RewriteFile(handle);
         bfs.Flush();
     }
     finally
     {
         bfs.UnLock();
     }
     base.Position = 0;
     _dirty        = false;
 }