Ejemplo n.º 1
0
 public uint Reserve(long offset, uint size)
 {
     if (offset < m_offset || offset + size > m_offset + m_size)
     {
         if (offset > m_arc.MaxOffset)
         {
             throw new ArgumentOutOfRangeException("offset", "Too large offset specified for memory mapped file view.");
         }
         if (size < ArcView.PageSize)
         {
             size = (uint)ArcView.PageSize;
         }
         if (size > m_arc.MaxOffset - offset)
         {
             size = (uint)(m_arc.MaxOffset - offset);
         }
         var old_view = m_view;
         m_view = m_arc.CreateViewAccessor(offset, size);
         old_view.SafeMemoryMappedViewHandle.ReleasePointer();
         old_view.Dispose();
         m_offset = offset;
         m_size   = size;
         unsafe { m_mem = m_view.GetPointer(m_offset); }
     }
     return((uint)(m_offset + m_size - offset));
 }
Ejemplo n.º 2
0
 public Frame(ArcView arc, long offset, uint size)
 {
     m_arc    = arc;
     m_offset = Math.Min(offset, m_arc.MaxOffset);
     m_size   = (uint)Math.Min(size, m_arc.MaxOffset - m_offset);
     m_view   = m_arc.CreateViewAccessor(m_offset, m_size);
     unsafe { m_mem = m_view.GetPointer(m_offset); }
 }
Ejemplo n.º 3
0
 public Frame(Frame other)
 {
     m_arc    = other.m_arc;
     m_offset = 0;
     m_size   = (uint)Math.Min(ArcView.PageSize, m_arc.MaxOffset);
     m_view   = m_arc.CreateViewAccessor(m_offset, m_size);
     unsafe { m_mem = m_view.GetPointer(m_offset); }
 }
Ejemplo n.º 4
0
 public Frame(ArcView arc)
 {
     m_arc    = arc;
     m_offset = 0;
     m_size   = (uint)Math.Min(ArcView.PageSize, m_arc.MaxOffset);
     m_view   = m_arc.CreateViewAccessor(m_offset, m_size);
     unsafe { m_mem = m_view.GetPointer(m_offset); }  //unsafe permet d'utiliser des pointeurs
 }
Ejemplo n.º 5
0
 public bool AsciiEqual(long offset, string data)
 {
     if (Reserve(offset, (uint)data.Length) < (uint)data.Length)
     {
         return(false);
     }
     unsafe
     {
         byte *ptr = m_view.GetPointer(m_offset);
         try {
             for (int i = 0; i < data.Length; ++i)
             {
                 if (ptr[offset - m_offset + i] != data[i])
                 {
                     return(false);
                 }
             }
         } finally {
             m_view.SafeMemoryMappedViewHandle.ReleasePointer();
         }
         return(true);
     }
 }
Ejemplo n.º 6
0
 public ViewPointer(MemoryMappedViewAccessor view, long offset)
 {
     m_view = view;
     m_ptr  = m_view.GetPointer(offset);
 }