예제 #1
0
            protected void SetPointer()
            {
                long skip = currPos;

                if (skip < pos)
                {
                    curr = first;
                    offs = 0;
                    pos  = 0;
                }
                else
                {
                    skip -= pos;
                }

                while (skip > 0)
                {
                    if (offs == curr.body.Length)
                    {
                        if (curr.next == null)
                        {
                            BlobImpl prev = curr;
                            curr = curr.next = new BlobImpl(first.Storage, curr.body.Length);
                            curr.MakePersistent(first.Storage);
                            prev.Store();
                        }
                        else
                        {
                            curr = curr.next;
                            curr.Load();
                        }
                        offs = 0;
                    }
                    int n = skip > curr.body.Length - offs ? curr.body.Length - offs : (int)skip;
                    pos  += n;
                    skip -= n;
                    offs += n;
                }
            }
예제 #2
0
            public override void SetLength(long length)
            {
                BlobImpl blob = first;

                size = 0;
                if (length > 0)
                {
                    while (length > blob.body.Length)
                    {
                        size += blob.body.Length;
                        if (blob.next == null)
                        {
                            BlobImpl prev = blob;
                            blob = blob.next = new BlobImpl(first.Storage, blob.body.Length);
                            blob.MakePersistent(first.Storage);
                            prev.Store();
                        }
                        else
                        {
                            blob = blob.next;
                            blob.Load();
                        }
                    }
                    size += length;
                }
                if (pos > size)
                {
                    pos  = size;
                    curr = blob;
                }
                if (blob.next != null)
                {
                    BlobImpl.DeallocateAll(blob.next);
                    blob.Modify();
                    blob.next = null;
                }
                first.Modify();
                first.size = size;
            }
예제 #3
0
            public override void Write(byte[] buffer, int src, int count)
            {
                SetPointer();

                while (count > 0)
                {
                    if (offs == curr.body.Length)
                    {
                        if (curr.next == null)
                        {
                            BlobImpl prev = curr;
                            curr = curr.next = new BlobImpl(first.Storage, curr.body.Length);
                            curr.MakePersistent(first.Storage);
                            prev.Store();
                        }
                        else
                        {
                            curr = curr.next;
                            curr.Load();
                        }
                        offs = 0;
                    }
                    int n = count > curr.body.Length - offs ? curr.body.Length - offs : count;
                    curr.Modify();
                    Array.Copy(buffer, src, curr.body, offs, n);
                    pos   += n;
                    src   += n;
                    offs  += n;
                    count -= n;
                }
                currPos = pos;
                if (pos > size)
                {
                    size = pos;
                    first.Modify();
                    first.size = size;
                }
            }
예제 #4
0
 protected void SetPointer() 
 {
     long skip = currPos;
     if (skip < pos) 
     {
         curr = first;
         offs = 0;
         pos = 0;
     } 
     else 
     {
         skip -= pos;
     }
          
     while (skip > 0) 
     { 
         if (offs == curr.body.Length) 
         { 
             if (curr.next == null) 
             { 
                 BlobImpl prev = curr;
                 curr = curr.next = new BlobImpl(first.Storage, curr.body.Length);
                 curr.MakePersistent(first.Storage);
                 prev.Store();
             } 
             else 
             {
                 curr = curr.next;
                 curr.Load();
             }
             offs = 0;
         }
         int n = skip > curr.body.Length - offs ? curr.body.Length - offs : (int)skip; 
         pos += n;
         skip -= n;
         offs += n;
     }
 }
예제 #5
0
            public override void Write(byte[] buffer, int src, int count) 
            {
                SetPointer();

                while (count > 0) 
                { 
                    if (offs == curr.body.Length) 
                    { 
                        if (curr.next == null) 
                        { 
                            BlobImpl prev = curr;
                            curr = curr.next = new BlobImpl(first.Storage, curr.body.Length);
                            curr.MakePersistent(first.Storage);
                            prev.Store();
                        } 
                        else 
                        {
                            curr = curr.next;
                            curr.Load();
                        }
                        offs = 0;
                    }
                    int n = count > curr.body.Length - offs ? curr.body.Length - offs : count; 
                    curr.Modify();
                    Array.Copy(buffer, src, curr.body, offs, n);
                    pos += n;
                    src += n;
                    offs += n;
                    count -= n;
                }
                currPos = pos;
                if (pos > size) 
                {
                    size = pos;
                    first.Modify();
                    first.size = size;
                }
            }