Exemple #1
0
            public override void Close()
            {
                if (!multisession && pos < curr.body.Length)
                {
                    byte[] tmp = new byte[pos];
                    Array.Copy(curr.body, 0, tmp, 0, pos);
                    curr.body = tmp;
                }

                curr.Store();
                if (curr != first)
                {
                    first.Store();
                }

                first = curr = null;
            }
Exemple #2
0
            public override void Write(byte[] b, int off, int len)
            {
                while (len > 0)
                {
                    if (pos == curr.body.Length)
                    {
                        BlobImpl next = new BlobImpl(curr.Storage, curr.body.Length);
                        BlobImpl prev = curr;
                        curr = prev.next = next;
                        if (prev != first)
                        {
                            prev.Store();
                            prev.Invalidate();
                            prev.next = null;
                        }

                        pos = 0;
                    }

                    int n = (len > curr.body.Length - pos) ? curr.body.Length - pos : len;
                    Array.Copy(b, off, curr.body, pos, n);
                    off += n;
                    pos += n;
                    len -= n;
                    first.size += n;
                }
            }
Exemple #3
0
            internal BlobOutputStream(BlobImpl first, bool multisession)
            {
                first.Load();
                this.first = first;
                this.multisession = multisession;
                int size = first.size;
                while (first.next != null)
                {
                    size -= first.body.Length;
                    BlobImpl prev = first;
                    first = first.next;
                    first.Load();
                    prev.Invalidate();
                    prev.next = null;
                    pos = 0;
                }

                curr = first;
                pos = size;
            }
Exemple #4
0
            //UPGRADE_NOTE: The equivalent of method 'java.io.InputStream.skip' is not an override method.
            public long Skip(long offs)
            {
                if (offs > rest)
                {
                    offs = rest;
                }

                int len = (int) offs;
                while (len > 0)
                {
                    if (pos == curr.body.Length)
                    {
                        BlobImpl prev = curr;
                        curr = curr.next;
                        curr.Load();
                        prev.Invalidate();
                        prev.next = null;
                        pos = 0;
                    }

                    int n = len > curr.body.Length - pos ? curr.body.Length - pos : len;
                    pos += n;
                    len -= n;
                    rest -= n;
                }

                return offs;
            }
Exemple #5
0
            public override int Read(byte[] b, int off, int len)
            {
                if (len > rest)
                    len = rest;

                int beg = off;
                while (len > 0)
                {
                    if (pos == curr.body.Length)
                    {
                        BlobImpl prev = curr;
                        curr = curr.next;
                        curr.Load();
                        prev.Invalidate();
                        prev.next = null;
                        pos = 0;
                    }

                    int n = len > curr.body.Length - pos ? curr.body.Length - pos : len;
                    Array.Copy(curr.body, pos, b, off, n);
                    pos += n;
                    off += n;
                    len -= n;
                    rest -= n;
                }

                return off - beg;
            }
Exemple #6
0
 public override void Close()
 {
     curr = null;
     rest = 0;
 }
Exemple #7
0
 protected internal BlobInputStream(BlobImpl first)
 {
     first.Load();
     curr = first;
     rest = first.size;
 }