protected IEncoder(Schema schema, ArrayAccess arrayAccess, MapAccess mapAccess) { Schema = schema; _arrayAccess = arrayAccess; _mapAccess = mapAccess; _writer = ResolveWriter(schema); }
protected PreresolvingDatumWriter(Schema schema, ArrayAccess arrayAccess, MapAccess mapAccess) { Schema = schema; _arrayAccess = arrayAccess; _mapAccess = mapAccess; _writer = ResolveWriter(schema); }
internal MapViewStream(MemoryMappedFile backingFile, long mapSize, bool isWriteable) { if (backingFile == null) { throw new MMException("MapViewStream.MapViewStream - backingFile is null"); } if (!backingFile.IsOpen) { throw new MMException("MapViewStream.MapViewStream - backingFile is not open"); } if ((mapSize < 1) || (mapSize > backingFile.MaxSize)) { throw new MMException(string.Format("MapViewStream.MapViewStream - mapSize is invalid. mapSize == {0}, backingFile.MaxSize == {1}", mapSize, backingFile.MaxSize)); } _backingFile = backingFile; _isWriteable = isWriteable; _access = isWriteable ? MapAccess.FileMapWrite : MapAccess.FileMapRead; _mapSize = mapSize; _isOpen = true; Seek(0, SeekOrigin.Begin); }
public Stream MapView(MapAccess access, long offset, IntPtr size) { if (!IsOpen) { throw new ObjectDisposedException("MMF already closed"); } IntPtr baseAddress = IntPtr.Zero; baseAddress = Win32MapApis.MapViewOfFile( _hMap, (int)access, (int)((offset >> 32) & 0xFFFFFFFF), (int)(offset & 0xFFFFFFFF), size ); if (baseAddress == IntPtr.Zero) { throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); } // Find out what MapProtection to use // based on the MapAccess flags... MapProtection protection; if (access == MapAccess.FileMapRead) { protection = MapProtection.PageReadOnly; } else { protection = MapProtection.PageReadWrite; } return(new MapViewStream(baseAddress, size.ToInt64(), protection)); }
/// <summary> /// Constructor used internally by MemoryMappedFile. /// </summary> /// <param name="backingFile">Preconstructed MemoryMappedFile</param> /// <param name="mapSize">Size of the view, in bytes.</param> /// <param name="isWriteable">True if Read/Write access is desired, False otherwise</param> internal MapViewStream(MemoryMappedFile backingFile, long mapSize, bool isWriteable) { if (backingFile == null) { throw new Exception("MapViewStream.MapViewStream - backingFile is null"); } if (!backingFile.IsOpen) { throw new Exception("MapViewStream.MapViewStream - backingFile is not open"); } if ((mapSize < 1) || (mapSize > backingFile.MaxSize)) { throw new Exception(string.Format("MapViewStream.MapViewStream - mapSize is invalid. mapSize == {0}, backingFile.MaxSize == {1}", mapSize, backingFile.MaxSize)); } _backingFile = backingFile; _isWriteable = isWriteable; _access = isWriteable ? MapAccess.FileMapWrite : MapAccess.FileMapRead; // Need a backingFile.SupportsAccess function that takes a MapAccess compares it against its stored MapProtection protection and returns bool _mapSize = mapSize; _isOpen = true; // Map the first view Seek(0, SeekOrigin.Begin); }
public IntPtr Map(MapAccess access) { unsafe { var result = Gl.MapBuffer(Target, (uint)access); GlHelper.GetError(); return(new IntPtr(result)); } }
private object ReadMap(object reuse, Decoder decoder, MapAccess mapAccess, ReadItem valueReader) { object map = mapAccess.Create(reuse); for (int n = (int)decoder.ReadMapStart(); n != 0; n = (int)decoder.ReadMapNext()) { mapAccess.AddElements(map, n, valueReader, decoder, false); } return(map); }
/// <summary> /// Open an existing named File Mapping object /// </summary> /// <param name="access">desired access to the map</param> /// <param name="name">name of object</param> /// <returns>The memory mapped file instance</returns> public static MemoryMappedFile Open(MapAccess access, String name) { MemoryMappedFile map = new MemoryMappedFile(); map._hMap = Win32MapApis.OpenFileMapping((int)access, false, name); if (map._hMap == NULL_HANDLE) throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); return map; }
/// <summary> /// /// </summary> /// <param name="fileName"></param> /// <param name="protection"></param> /// <param name="access"></param> /// <param name="maxSize"></param> /// <param name="name"></param> public MemoryMappedFile(String fileName, MapProtection protection, MapAccess access, long maxSize, String name) { //try to open the mmf by name. if failed create the file and mmf. IntPtr hFile = IntPtr.Zero; try { m_hMap = Win32MapApis.OpenFileMapping((int)access, false, name); if (m_hMap == NULL_HANDLE) { int desiredAccess = GENERIC_READ; if ((protection == MapProtection.PageReadWrite) || (protection == MapProtection.PageWriteCopy)) { desiredAccess |= GENERIC_WRITE; } hFile = Win32MapApis.CreateFile( GetMMFDir() + fileName, desiredAccess, 0, IntPtr.Zero, OPEN_ALWAYS, 0, IntPtr.Zero ); if (hFile != NULL_HANDLE) { m_hMap = Win32MapApis.CreateFileMapping( hFile, IntPtr.Zero, (int)protection, 0, (int)(maxSize & 0xFFFFFFFF), name ); if (m_hMap != NULL_HANDLE) { m_maxSize = maxSize; } else { throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); } } else { throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); } } } catch (Exception Err) { throw Err; } finally { if (!(hFile == NULL_HANDLE)) { Win32MapApis.CloseHandle(hFile); } } }
/// <summary> /// Open an existing named File Mapping object /// </summary> /// <param name="access">desired access to the map</param> /// <param name="name">name of object</param> /// <returns>The memory mapped file instance</returns> public static MemoryMappedFile Open(MapAccess access, String name) { MemoryMappedFile map = new MemoryMappedFile { _hMap = Win32MapApis.OpenFileMapping((int)access, false, name) }; if (map._hMap == NULL_HANDLE) { throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); } map._maxSize = -1; // debug unknown return(map); }
/// <summary> /// Open an existing named File Mapping object /// </summary> /// <param name="access">desired access to the map</param> /// <param name="name">name of object</param> /// <returns>The memory mapped file instance</returns> public static MemoryMappedFile Open(MapAccess access, String name) { MemoryMappedFile map = new MemoryMappedFile(); // Debug.Log("mem map start"); map._hMap = Win32MapApis.OpenFileMapping((int)access, false, name); if (map._hMap == NULL_HANDLE) { // Debug.Log("mem map doesnt exist"); return(null); } //throw new FileMapIOException ( Marshal.GetHRForLastWin32Error() ); return(map); }
/// <summary> /// /// </summary> /// <param name="access"></param> /// <param name="name"></param> public bool Open(MapAccess access, String name) { bool RV = true; try { m_hMap = Win32MapApis.OpenFileMapping((int)access, false, name); if (m_hMap == NULL_HANDLE) { RV = false; } return(RV); } catch { return(RV); } }
/// <summary> /// /// </summary> /// <param name="access"></param> /// <param name="offset"></param> /// <param name="size"></param> /// <param name="path"></param> /// <returns></returns> public MapViewStream MapView(MapAccess access, long offset, int size, string path) { IntPtr baseAddress = IntPtr.Zero; try { baseAddress = Win32MapApis.MapViewOfFile( m_hMap, (int)access, (int)((offset >> 32) & 0xFFFFFFFF), (int)(offset & 0xFFFFFFFF), size ); if (baseAddress != IntPtr.Zero) { MapProtection protection; if (access == MapAccess.FileMapRead) { protection = MapProtection.PageReadOnly; } else { protection = MapProtection.PageReadWrite; } if (path != "") { System.IO.FileInfo oFi = new System.IO.FileInfo(GetMMFDir() + path); m_maxSize = (int)oFi.Length; } return(new MapViewStream(baseAddress, m_maxSize, protection)); } return(null); } catch { throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); } }
public IntPtr MapView(MapAccess access, long offset, long size) { if (!IsOpen) { throw new ObjectDisposedException("Memmoryfile Already closed"); } IntPtr mapSize = new IntPtr(size); IntPtr baseAddress = Win32MapApis.MapViewOfFile( _hMap, (int)access, (int)((offset >> 32) & 0xFFFFFFFF), (int)(offset & 0xFFFFFFFF), mapSize ); if (baseAddress == IntPtr.Zero) { throw new MMException(Marshal.GetHRForLastWin32Error()); } return(baseAddress); }
public IntPtr MapView(MapAccess access, long offset, long size) { if (!IsOpen) { throw new ObjectDisposedException("Winterdom.IO.FileMap.MemoryMappedFile.MapView - MMF already closed"); } // Throws OverflowException if (a) this is a 32-bit platform AND (b) size is out of bounds (ie. int bounds) with respect to this platform IntPtr mapSize = new IntPtr(size); IntPtr baseAddress = Win32MapApis.MapViewOfFile( _hMap, (int)access, (int)((offset >> 32) & 0xFFFFFFFF), (int)(offset & 0xFFFFFFFF), mapSize ); if (baseAddress == IntPtr.Zero) { throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); } return(baseAddress); }
public IntPtr Map(int offset, int length, MapAccess access) { context.Bindings.Buffers.ByTarget(target).Set(this); return(GL.MapBufferRange((int)target, (IntPtr)offset, (IntPtr)length, (int)access)); }
/// <summary> /// Map a view of the file mapping object /// This returns a stream, giving you easy access to the memory, /// as you can use StreamReaders and StreamWriters on top of it /// </summary> /// <param name="access">desired access to the view</param> /// <param name="offset">offset of the file mapping object to /// start view at</param> /// <param name="size">size of the view</param> public Stream MapView( MapAccess access, long offset, int size ) { if ( !IsOpen ) throw new ObjectDisposedException("MMF already closed"); IntPtr baseAddress = IntPtr.Zero; baseAddress = Win32MapApis.MapViewOfFile ( _hMap, (int)access, (int)((offset >> 32) & 0xFFFFFFFF), (int)(offset & 0xFFFFFFFF), size ); if ( baseAddress == IntPtr.Zero ) throw new FileMapIOException ( Marshal.GetHRForLastWin32Error() ); // Find out what MapProtection to use // based on the MapAccess flags... MapProtection protection; if ( access == MapAccess.FileMapRead ) protection = MapProtection.PageReadOnly; else protection = MapProtection.PageReadWrite; return new MapViewStream ( baseAddress, size, protection ); }
/// <summary> /// Open an existing named File Mapping object /// </summary> /// <param name="access">desired access to the map</param> /// <param name="name">name of object</param> /// <returns>The memory mapped file instance</returns> public static MemoryMappedFile Open( MapAccess access, String name ) { MemoryMappedFile map = new MemoryMappedFile(); map._hMap = Win32MapApis.OpenFileMapping ( (int)access, false, name ); if ( map._hMap == NULL_HANDLE ) throw new FileMapIOException ( Marshal.GetHRForLastWin32Error() ); return map; }
/// <summary> /// Map a view of the file mapping object /// This returns a stream, giving you easy access to the memory, /// as you can use StreamReaders and StreamWriters on top of it /// </summary> /// <param name="access">desired access to the view</param> /// <param name="offset">offset of the file mapping object to /// start view at</param> /// <param name="size">size of the view</param> public Stream MapView(MapAccess access, long offset, int size) { // Debug.Log("start mapview with size "+ size); return(MapView(access, offset, new IntPtr(size))); }
public IntPtr MapView(MapAccess access, long offset, long size) { if (!IsOpen) throw new ObjectDisposedException("Winterdom.IO.FileMap.MemoryMappedFile.MapView - MMF already closed"); // Throws OverflowException if (a) this is a 32-bit platform AND (b) size is out of bounds (ie. int bounds) with respect to this platform IntPtr mapSize = new IntPtr(size); IntPtr baseAddress = Win32MapApis.MapViewOfFile( _hMap, (int)access, (int)((offset >> 32) & 0xFFFFFFFF), (int)(offset & 0xFFFFFFFF), mapSize ); if (baseAddress == IntPtr.Zero) throw new FileMapIOException(Marshal.GetHRForLastWin32Error()); return baseAddress; }
public static extern byte *MapViewOfFile(SafeFileHandle hFileMappingObject, MapAccess dwDesiredAccess, int dwFileOffsetHigh, int dwFileOffsetLow, IntPtr dwNumBytesToMap);
IntPtr _viewBaseAddr = IntPtr.Zero; // Pointer to the base address of the currently mapped view #endregion Fields #region Constructors /// <summary> /// Constructor used internally by MemoryMappedFile. /// </summary> /// <param name="backingFile">Preconstructed MemoryMappedFile</param> /// <param name="mapSize">Size of the view, in bytes.</param> /// <param name="isWriteable">True if Read/Write access is desired, False otherwise</param> internal MapViewStream(MemoryMappedFile backingFile, long mapSize, bool isWriteable) { if (backingFile == null) { throw new Exception("MapViewStream.MapViewStream - backingFile is null"); } if (!backingFile.IsOpen) { throw new Exception("MapViewStream.MapViewStream - backingFile is not open"); } if ((mapSize < 1) || (mapSize > backingFile.MaxSize)) { throw new Exception(string.Format("MapViewStream.MapViewStream - mapSize is invalid. mapSize == {0}, backingFile.MaxSize == {1}", mapSize, backingFile.MaxSize)); } _backingFile = backingFile; _isWriteable = isWriteable; _access = isWriteable ? MapAccess.FileMapWrite : MapAccess.FileMapRead; // Need a backingFile.SupportsAccess function that takes a MapAccess compares it against its stored MapProtection protection and returns bool _mapSize = mapSize; _isOpen = true; // Map the first view Seek(0, SeekOrigin.Begin); }
/// <summary> /// Map a view of the file mapping object /// This returns a stream, giving you easy access to the memory, /// as you can use StreamReaders and StreamWriters on top of it /// </summary> /// <param name="access">desired access to the view</param> /// <param name="offset">offset of the file mapping object to /// start view at</param> /// <param name="size">size of the view</param> public Stream MapView(MapAccess access, long offset, int size) { return(MapView(access, offset, new IntPtr(size))); }
/// <summary> /// /// </summary> /// <param name="FileName"></param> /// <param name="protection"></param> /// <param name="name"></param> /// <param name="access"></param> /// <returns></returns> public bool OpenEx(string FileName, MapProtection protection, string name, MapAccess access) { bool RV = false; m_hMap = Win32MapApis.OpenFileMapping((int)access, false, name); if (m_hMap == NULL_HANDLE) { if (System.IO.File.Exists(GetMMFDir() + FileName)) { long maxSize; System.IO.FileStream stream = System.IO.File.Open(GetMMFDir() + FileName, System.IO.FileMode.Open); maxSize = stream.Length; stream.Close(); IntPtr hFile = INVALID_HANDLE_VALUE; OFSTRUCT ipStruct = new OFSTRUCT(); string MMFName = GetMMFDir() + FileName; hFile = Win32MapApis.OpenFile(MMFName, ipStruct , 2); // determine file access needed // we'll always need generic read access int desiredAccess = GENERIC_READ; if ((protection == MapProtection.PageReadWrite) || (protection == MapProtection.PageWriteCopy)) { desiredAccess |= GENERIC_WRITE; } // open or create the file // if it doesn't exist, it gets created m_hMap = Win32MapApis.CreateFileMapping( hFile, IntPtr.Zero, (int)protection, (int)((maxSize >> 32) & 0xFFFFFFFF), (int)(maxSize & 0xFFFFFFFF), name ); // close file handle, we don't need it if (!(hFile == NULL_HANDLE)) { Win32MapApis.CloseHandle(hFile); } RV = true; } } else { RV = true; } return(RV); }
/// <summary> /// Map a view of the file mapping object /// This returns a stream, giving you easy access to the memory, /// as you can use StreamReaders and StreamWriters on top of it /// </summary> /// <param name="access">desired access to the view</param> /// <param name="offset">offset of the file mapping object to /// start view at</param> /// <param name="size">size of the view</param> public Stream MapView(MapAccess access, long offset, int size) { return MapView(access, offset, new IntPtr(size)); }
public IntPtr Map(int offset, int length, MapAccess access) { context.Bindings.Buffers.ByTarget(target).Set(this); return GL.MapBufferRange((int)target, (IntPtr)offset, (IntPtr)length, (int)access); }