/// <summary> /// Mounts the specified iso path. /// </summary> /// <param name="isoPath">The iso path.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="visibleToAllProcesses">if set to <c>true</c> [visible to all processes].</param> /// <returns>IsoMount.</returns> /// <exception cref="System.ArgumentNullException">isoPath</exception> /// <exception cref="System.IO.IOException">Unable to create mount.</exception> public async Task <IIsoMount> Mount(string isoPath, CancellationToken cancellationToken, bool visibleToAllProcesses = true) { if (string.IsNullOrEmpty(isoPath)) { throw new ArgumentNullException("isoPath"); } PfmFileMount mount; var err = PfmApi.FileMountCreate(out mount); if (err != 0) { throw new IOException("Unable to create mount for " + isoPath); } _hasInitialized = true; var fmp = new PfmFileMountCreateParams { }; fmp.ui = _myPfmFileMountUi ?? (_myPfmFileMountUi = new MyPfmFileMountUi(_logger)); fmp.fileMountFlags |= PfmFileMountFlag.inProcess; if (visibleToAllProcesses) { fmp.visibleProcessId = PfmVisibleProcessId.all; } fmp.mountFileName = isoPath; // unc only fmp.mountFlags |= PfmMountFlag.uncOnly; fmp.mountFlags |= PfmMountFlag.noShellNotify; fmp.mountFlags |= PfmMountFlag.readOnly; _logger.Info("Mounting {0}", isoPath); await _mountSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); err = mount.Start(fmp); if (err != 0) { _mountSemaphore.Release(); mount.Dispose(); throw new IOException("Unable to start mount for " + isoPath); } err = mount.WaitReady(); if (err != 0) { _mountSemaphore.Release(); mount.Dispose(); throw new IOException("Unable to start mount for " + isoPath); } return(new PismoMount(mount, isoPath, this, _logger)); }
/// <summary> /// Mounts the specified iso path. /// </summary> /// <param name="isoPath">The iso path.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="visibleToAllProcesses">if set to <c>true</c> [visible to all processes].</param> /// <returns>IsoMount.</returns> /// <exception cref="System.ArgumentNullException">isoPath</exception> /// <exception cref="System.IO.IOException">Unable to create mount.</exception> public async Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken, bool visibleToAllProcesses = true) { if (string.IsNullOrEmpty(isoPath)) { throw new ArgumentNullException("isoPath"); } PfmFileMount mount; var err = PfmApi.FileMountCreate(out mount); if (err != 0) { throw new IOException("Unable to create mount for " + isoPath); } _hasInitialized = true; var fmp = new PfmFileMountCreateParams { }; fmp.ui = _myPfmFileMountUi ?? (_myPfmFileMountUi = new MyPfmFileMountUi(_logger)); fmp.fileMountFlags |= PfmFileMountFlag.inProcess; if (visibleToAllProcesses) { fmp.visibleProcessId = PfmVisibleProcessId.all; } fmp.mountFileName = isoPath; // unc only fmp.mountFlags |= PfmMountFlag.uncOnly; fmp.mountFlags |= PfmMountFlag.noShellNotify; fmp.mountFlags |= PfmMountFlag.readOnly; _logger.Info("Mounting {0}", isoPath); await _mountSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); err = mount.Start(fmp); if (err != 0) { _mountSemaphore.Release(); mount.Dispose(); throw new IOException("Unable to start mount for " + isoPath); } err = mount.WaitReady(); if (err != 0) { _mountSemaphore.Release(); mount.Dispose(); throw new IOException("Unable to start mount for " + isoPath); } return new PismoMount(mount, isoPath, this, _logger); }