コード例 #1
0
        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);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public ZipFileFile(IMountPoint mountPoint, string fullPath, string name, ZipArchiveEntry entry)
     : base(mountPoint, fullPath, name)
 {
     _entry      = entry;
     _mountPoint = (ZipFileMountPoint)mountPoint;
 }
コード例 #5
0
 public ZipFileDirectory(IMountPoint mountPoint, string fullPath, string name)
     : base(mountPoint, fullPath, name)
 {
     _mountPoint = (ZipFileMountPoint)mountPoint;
 }
コード例 #6
0
        public void DisposeMountPoint(IMountPoint mountPoint)
        {
            ZipFileMountPoint mp = mountPoint as ZipFileMountPoint;

            mp?.Archive?.Dispose();
        }