Пример #1
0
 public S3ResourceStream(S3StoreInfo store, string bucketName, string physicalPath)
 {
     fFile   = new S3ResourceFile(store, bucketName, physicalPath);
     fCursor = 0;
     // start with an empty buffer
     fBuffer = fFile.GetBufferWithRetry(0, BufferBytes);
 }
Пример #2
0
            public override int Read(byte[] buffer, int offset, int count)
            {
                int totalBytesRead = 0;
                // how many bytes will we read?
                int bytesToRead = Math.Min(count, (int)Math.Min(Int32.MaxValue, fFile.TotalBytes - fCursor));

                do
                {
                    // attempt to read from the current buffer?
                    int bytesRead = fBuffer.ReadAt(fCursor, buffer, offset, bytesToRead);
                    // adjust pointers
                    bytesToRead    -= bytesRead;
                    fCursor        += bytesRead;
                    offset         += bytesRead;
                    totalBytesRead += bytesRead;
                    // do we need to refill the buffer?
                    if (bytesToRead > 0 && (bytesRead == 0 || fCursor >= fBuffer.Offset + fBuffer.ValidBufferBytes))
                    {
                        fBuffer = fFile.GetBufferWithRetry(fCursor, BufferBytes);
                    }
                } while (bytesToRead > 0);
                return(totalBytesRead);
            }