inVtero.net.Scanner.MapScanFile C# (CSharp) Method

MapScanFile() static private method

static private MapScanFile ( String File, long From, int ScanData, int Count ) : IEnumerable
File String
From long
ScanData int
Count int
return IEnumerable
        static IEnumerable<long> MapScanFile(String File, long From, int ScanData, int Count)
        {
            List<long> rv = new List<long>();

            // TODO: These streams should be persistent across these calls right?
            // TODO: This path is only 1 time and pretty infrequent so far though 
            using (var fs = new FileStream(File, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                var mapName = Path.GetFileNameWithoutExtension(File) + From.ToString("X16");
                using (var mmap =
                    MemoryMappedFile.CreateFromFile(fs, mapName, 0, MemoryMappedFileAccess.Read,
                    null, HandleInheritability.Inheritable, false))
                {
                    using (var reader = mmap.CreateViewAccessor(From, Count * 4, MemoryMappedFileAccess.Read))
                    {
                        var LocatedScanTarget = UnsafeHelp.ScanBytes(reader, ScanData, Count);
                        if (LocatedScanTarget.Count() > 0)
                        {
                            foreach (var ioff in LocatedScanTarget)
                            {
                                var target = From + ioff;

                                //WriteColor($"Found input @ {(target):X}");
                                rv.Add(target);
                                yield return target;
                            }
                        }
                    }

                }
            }
            yield break;
        }