Beispiel #1
0
 public VFSReadFacade(VFSFactory vfsFactory, VFSModeAdapterFacory vfsModeAdapterFacory, Decorator.VFS vfs)
     : base(vfsFactory, vfsModeAdapterFacory, vfs)
 {
     _vfsStream   = _vfsFactory.GetVFSStream(_vfs);
     VFSFileNames = new ArraySegment <string>();
     VFSModel     = new ArraySegment <VFSModel>();
 }
Beispiel #2
0
 public VFSStream GetVFSStream(Decorator.VFS vfs)
 {
     Validations.NotNull(vfs);
     using (var result = new VFSStream(vfs))
     {
         return(result);
     }
 }
        private static IntPtr VFSOpenHandler(IntPtr path, uint mode, uint hints)
        {
            var output = IntPtr.Zero;

            if (path == IntPtr.Zero)
            {
                return(output);
            }

            var pathStr = Marshal.PtrToStringAnsi(path);
            var access  = FileAccess.Read;

            if ((mode & Constants.RETRO_VFS_FILE_ACCESS_WRITE) == Constants.RETRO_VFS_FILE_ACCESS_WRITE)
            {
                access = FileAccess.Write;
            }
            if ((mode & Constants.RETRO_VFS_FILE_ACCESS_READ_WRITE) == Constants.RETRO_VFS_FILE_ACCESS_READ_WRITE)
            {
                access = FileAccess.ReadWrite;
            }

            var stream = default(Stream);

            try
            {
                stream = OpenFileStream?.Invoke(pathStr, access);
            }
            catch
            {
                return(output);
            }

            if (stream == null)
            {
                return(output);
            }

            var vfsStream = new VFSStream(pathStr, stream);
            var handle    = GCHandle.Alloc(vfsStream);

            output = GCHandle.ToIntPtr(handle);
            return(output);
        }