using MediaBrowser.Common.IO;
using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
using System;
namespace MediaBrowser.IsoMounter
{
///
/// Class IsoMount
///
internal class PismoMount : IIsoMount
{
///
/// The logger
///
private static readonly ILogger Logger = LogManager.GetLogger("IsoMount");
///
/// 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;
///
/// Prevents a default instance of the class from being created.
///
/// The mount.
/// The iso path.
/// The iso manager.
internal PismoMount(PfmFileMount mount, string isoPath, PismoIsoManager isoManager)
{
_pfmFileMount = mount;
IsoPath = isoPath;
_isoManager = isoManager;
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;
}
}
}
}