blob: 6524fd234a6fe83fa733f6761c7e3ab766ae103d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
using System;
namespace MediaBrowser.IsoMounter
{
/// <summary>
/// Class IsoMount
/// </summary>
internal class IsoMount : IIsoMount
{
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("IsoMount");
/// <summary>
/// Gets or sets the iso path.
/// </summary>
/// <value>The iso path.</value>
public string IsoPath { get; internal set; }
/// <summary>
/// Gets the mounted path.
/// </summary>
/// <value>The mounted path.</value>
public string MountedPath { get; internal set; }
/// <summary>
/// The PFM file mount
/// </summary>
private PfmFileMount _pfmFileMount;
/// <summary>
/// The _iso manager
/// </summary>
private readonly IsoManager _isoManager;
/// <summary>
/// Prevents a default instance of the <see cref="IsoMount" /> class from being created.
/// </summary>
/// <param name="mount">The mount.</param>
/// <param name="isoPath">The iso path.</param>
/// <param name="isoManager">The iso manager.</param>
internal IsoMount(PfmFileMount mount, string isoPath, IsoManager isoManager)
{
_pfmFileMount = mount;
IsoPath = isoPath;
_isoManager = isoManager;
MountedPath = mount.GetMount().GetUncName();
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
UnMount();
}
/// <summary>
/// Uns the mount.
/// </summary>
private void UnMount()
{
if (_pfmFileMount != null)
{
Logger.Info("Unmounting {0}", IsoPath);
_pfmFileMount.Cancel();
_pfmFileMount.Detach();
_isoManager.OnUnmount(this);
_pfmFileMount.Dispose();
_pfmFileMount = null;
}
}
}
}
|