using MediaBrowser.Common.IO;
using MediaBrowser.Model.Logging;
using System;
namespace MediaBrowser.IsoMounter
{
///
/// Class IsoMount
///
internal class PismoMount : IIsoMount
{
///
/// Gets or sets the iso path.
///
/// The iso path.
public string IsoPath { get; internal set; }
///
/// Gets the mounted path.
///
/// The mounted path.
public string MountedPath { get; internal set; }
///
/// The PFM file mount
///
private PfmFileMount _pfmFileMount;
///
/// The _iso manager
///
private readonly PismoIsoManager _isoManager;
///
/// Gets or sets the logger.
///
/// The logger.
private ILogger Logger { get; set; }
///
/// Prevents a default instance of the class from being created.
///
/// The mount.
/// The iso path.
/// The iso manager.
/// The logger.
internal PismoMount(PfmFileMount mount, string isoPath, PismoIsoManager isoManager, ILogger logger)
{
_pfmFileMount = mount;
IsoPath = isoPath;
_isoManager = isoManager;
Logger = logger;
MountedPath = mount.GetMount().GetUncName();
}
///
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
///
/// Releases unmanaged and - optionally - managed resources.
///
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
protected virtual void Dispose(bool dispose)
{
UnMount();
}
///
/// Uns the mount.
///
private void UnMount()
{
if (_pfmFileMount != null)
{
Logger.Info("Unmounting {0}", IsoPath);
_pfmFileMount.Cancel();
_pfmFileMount.Detach();
_isoManager.OnUnmount(this);
_pfmFileMount.Dispose();
_pfmFileMount = null;
}
}
}
}