Example #1
0
 /// <summary>
 /// Construct a pointer with a restricted allowed area. The base is
 /// the given pointer whereas the end is p + sz (if not beyond the
 /// limit of p).
 /// </summary>
 /// <param name="p">Pointer to restrict</param>
 /// <param name="sz">Size of the allowed memory</param>
 public MapPtr(MapPtr p, int sz)
 {
     unsafe {
         Debug.Assert(p.e - p.p >= sz, "Wrong window size!");
         this.b = p.p;
         this.p = p.p;
         this.e = p.p + sz;
     }
 }
Example #2
0
        /// <summary>
        /// Build a MappedFile object. The file is open in sharing.
        /// </summary>
        /// <param name="path">Path to the file</param>
        public MappedFile(string path)
        {
            FileStream f = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);

            len = (int)f.Length;
            fm  = new FileMap(f);
            f.Close(); // Not needed anymore: the handle has been duplicated
            mv    = new MapView(fm, 0, len);
            start = mv.GetPointer();
        }