bool IMountPointFactory.TryMount(IEngineEnvironmentSettings environmentSettings, IMountPoint?parent, string mountPointUri, out IMountPoint?mountPoint) { if (!Uri.TryCreate(mountPointUri, UriKind.Absolute, out var uri)) { mountPoint = null; return(false); } if (!uri.IsFile) { mountPoint = null; return(false); } ZipArchive archive; if (parent == null) { if (!environmentSettings.Host.FileSystem.FileExists(uri.LocalPath)) { mountPoint = null; return(false); } try { archive = new ZipArchive(environmentSettings.Host.FileSystem.OpenRead(uri.LocalPath), ZipArchiveMode.Read, false); } catch { mountPoint = null; return(false); } } else { IFile?file = parent.Root.FileInfo(uri.LocalPath); if (file == null || !file.Exists) { mountPoint = null; return(false); } try { archive = new ZipArchive(file.OpenRead(), ZipArchiveMode.Read, false); } catch { mountPoint = null; return(false); } } mountPoint = new ZipFileMountPoint(environmentSettings, parent, mountPointUri, archive); return(true); }
public void DisposeMountPoint(IMountPoint mountPoint) { ZipFileMountPoint mp = mountPoint as ZipFileMountPoint; if (mp != null) { if (mp.Parent != null) { mp.EnvironmentSettings.SettingsLoader.ReleaseMountPoint(mp.Parent); } mp.Archive?.Dispose(); } }
private static bool TryMount(IEngineEnvironmentSettings environmentSettings, IMountPoint parent, Guid id, string place, out IMountPoint mountPoint) { ZipArchive archive; if (parent == null) { if (!environmentSettings.Host.FileSystem.FileExists(place)) { mountPoint = null; return(false); } try { archive = new ZipArchive(environmentSettings.Host.FileSystem.OpenRead(place), ZipArchiveMode.Read, false); } catch { mountPoint = null; return(false); } } else { IFile file = parent.Root.FileInfo(place); if (!file.Exists) { mountPoint = null; return(false); } try { archive = new ZipArchive(file.OpenRead(), ZipArchiveMode.Read, false); } catch { mountPoint = null; return(false); } } MountPointInfo info = new MountPointInfo(parent?.Info?.MountPointId ?? Guid.Empty, FactoryId, id, place); mountPoint = new ZipFileMountPoint(environmentSettings, info, archive); return(true); }
public ZipFileFile(IMountPoint mountPoint, string fullPath, string name, ZipArchiveEntry entry) : base(mountPoint, fullPath, name) { _entry = entry; _mountPoint = (ZipFileMountPoint)mountPoint; }
public ZipFileDirectory(IMountPoint mountPoint, string fullPath, string name) : base(mountPoint, fullPath, name) { _mountPoint = (ZipFileMountPoint)mountPoint; }
public void DisposeMountPoint(IMountPoint mountPoint) { ZipFileMountPoint mp = mountPoint as ZipFileMountPoint; mp?.Archive?.Dispose(); }