Beispiel #1
0
        protected static IEnumerable <IndexRange> GetNonEmptyRanges(Stream stream, IEnumerable <IndexRange> uploadableRanges)
        {
            Program.SyncOutput.MessageDetectingActualDataBlocks();
            var manager             = BufferManager.CreateBufferManager(Int32.MaxValue, MaxBufferSize);
            int totalRangeCount     = uploadableRanges.Count();
            int processedRangeCount = 0;

            foreach (var range in uploadableRanges)
            {
                var dataWithRange = new DataWithRange(manager)
                {
                    Data  = ReadBytes(stream, range, manager),
                    Range = range
                };
                using (dataWithRange)
                {
                    if (dataWithRange.IsAllZero())
                    {
                        Program.SyncOutput.DebugEmptyBlockDetected(dataWithRange.Range);
                    }
                    else
                    {
                        yield return(dataWithRange.Range);
                    }
                }
                Program.SyncOutput.ProgressEmptyBlockDetection(++processedRangeCount, totalRangeCount);
            }

            Program.SyncOutput.MessageDetectingActualDataBlocksCompleted();
            yield break;
        }
        protected static IEnumerable<IndexRange> GetNonEmptyRanges(Stream stream, IEnumerable<IndexRange> uploadableRanges)
        {
            Program.SyncOutput.MessageDetectingActualDataBlocks();
            var manager = BufferManager.CreateBufferManager(Int32.MaxValue, MaxBufferSize);
            int totalRangeCount = uploadableRanges.Count();
            int processedRangeCount = 0;
            foreach (var range in uploadableRanges)
            {
                var dataWithRange = new DataWithRange(manager)
                {
                    Data = ReadBytes(stream, range, manager),
                    Range = range
                };
                using(dataWithRange)
                {
                    if(dataWithRange.IsAllZero())
                    {
                        Program.SyncOutput.DebugEmptyBlockDetected(dataWithRange.Range);
                    }
                    else
                    {
                        yield return dataWithRange.Range;
                    }
                }
                Program.SyncOutput.ProgressEmptyBlockDetection(++processedRangeCount, totalRangeCount);
            }

            Program.SyncOutput.MessageDetectingActualDataBlocksCompleted();
            yield break;
        }