/// <summary> /// 是否能挂载此文件 /// </summary> /// <param name="path"></param> /// <returns></returns> public bool CanMount(string path, string container) { Logger.Debug("entry is canMount isoPath:[{0}],container:[{1}]", path, container); if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) { Logger.Debug("is canMount not windows", null); return(false); } bool isIsoPath = string.Equals(Path.GetExtension(path), ".iso", StringComparison.OrdinalIgnoreCase); if (!isIsoPath) { Logger.Debug("is not isoPath:" + path, null); return(false); } if (!PfmMount.CheckEnvironment()) { Logger.Error("ERROR: checkEnvironment is false.\n", null); return(false); } return(true); }
/// <summary> /// 异步执行挂载操作 /// </summary> /// <param name="isoPath"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task <IMediaMount> Mount(string isoPath, string container, CancellationToken cancellationToken) { Logger.Debug("Mount isoPath:[{0}],container:[{1}]", isoPath, container); PfmMount m = new PfmMount(this, MediaEncoder, Logger, FileSystem, isoPath, container); try { m.Mount(); if (m.MountedPath != null) { Logger.Debug("Mount success isoPath:[{0}],container:[{1}]", isoPath, container); return(Task.FromResult <IMediaMount>(m)); } } catch (Exception ex) { Logger.Info("WindowsMount Unhandled exception removing mount point, exception is [{0}].", ex.Message); } throw new IOException(String.Format( "An error occurred trying to mount image [$0].", isoPath )); }
private void test() { if (IsoManager != null) { /** * */ List <IMediaMounter> list = new List <IMediaMounter>(); list.Add(this); IsoManager.AddParts(list); Logger.Debug("isoManager init:", null); } Logger.Debug("**********************WinIsoMount inited", null); try { string testPath = @"D:\test.iso"; testPath = Environment.GetEnvironmentVariable("WinIsoTestIsoPath"); if (!File.Exists(testPath)) { Logger.Debug("**********************WinIsoMount test file not found,ignore test", null); return; } Logger.Debug("**********************WinIsoMount test path:" + testPath, null); PfmMount w = new PfmMount(this, MediaEncoder, Logger, FileSystem, testPath, MediaContainer.DvdIso.ToString()); w.Mount(); string mountedPath = w.MountedPath; if (mountedPath != null) { Logger.Debug("**********************testMountPath success:" + mountedPath, null); } w.UnMount(); } catch (Exception ex) { Logger.Info("**********************testMountPath fail,ex:{0}", ex.Message, null); } }