public RemoteFileInfo GetFileInfo(ResourceLocation rl, out System.IO.Stream stream)
        {
            stream = null;

            remoteZipFile = new ZipRemoteFile(rl);
            remoteZipFile.Load();

            string entryName = GetZipEntryNameProperty(this.downloader);

            entry = remoteZipFile[entryName];

            RemoteFileInfo result = new RemoteFileInfo();
            result.AcceptRanges = false;  // TODO make resumeable
            result.FileSize = entry.Size;
            result.LastModified = entry.DateTime;
            result.MimeType = "application/zip";

            return result;
        }
Esempio n. 2
0
        public RemoteFileInfo GetFileInfo(ResourceLocation rl, out System.IO.Stream stream)
        {
            stream = null;

            remoteZipFile = new ZipRemoteFile(rl);
            remoteZipFile.Load();

            string entryName = GetZipEntryNameProperty(this.downloader);

            entry = remoteZipFile[entryName];

            RemoteFileInfo result = new RemoteFileInfo();

            result.AcceptRanges = false;  // TODO make resumeable
            result.FileSize     = entry.Size;
            result.LastModified = entry.DateTime;
            result.MimeType     = "application/zip";

            return(result);
        }
Esempio n. 3
0
        private void LoadZIP()
        {
            checkableTreeView1.Nodes.Clear();

            ResourceLocation rl = this.DownloadLocation;

            rl.BindProtocolProviderType();

            if (rl.ProtocolProviderType == null)
            {
                chkChooseZIP.Checked = false;

                MessageBox.Show("Invalid URL format, please check the location field.",
                    AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            ReleaseZIPThread();

            zipReaderThread = new Thread(
                delegate(object state)
                {
                    ZipRemoteFile zipFile = new ZipRemoteFile((ResourceLocation)state);

                    try
                    {
                        if (zipFile.Load())
                        {
                            this.BeginInvoke((MethodInvoker)delegate() { DisplayZIPOnTree(zipFile); waitControl1.Visible = false; });
                        }
                        else
                        {
                            this.BeginInvoke((MethodInvoker)delegate()
                            {
                                waitControl1.Visible = false;

                                MessageBox.Show("Unable to load ZIP contents.",
                                    AppManager.Instance.Application.MainForm.Text,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        this.BeginInvoke((MethodInvoker)delegate()
                        {
                            waitControl1.Visible = false;

                            MessageBox.Show("Unable to load ZIP contents: " + ex.Message,
                                AppManager.Instance.Application.MainForm.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                        });
                    }
                }
            );

            waitControl1.Visible = true;
            zipReaderThread.Start(rl);
        }
Esempio n. 4
0
        private void DisplayZIPOnTree(ZipRemoteFile zipFile)
        {
            checkableTreeView1.ImageList = FileTypeImageList.GetSharedInstance();
            checkableTreeView1.Nodes.Clear();

            foreach (ZipEntry entry in zipFile)
            {
                // skip folders...
                if (entry.Name.EndsWith("/"))
                {
                    continue;
                }

                string displayName;
                TreeNode parentNd = GetNodeFromPath(entry.Name, out displayName);

                TreeNode newNd = new TreeNode(displayName);
                newNd.Tag = entry;
                newNd.ImageIndex = FileTypeImageList.GetImageIndexByExtention(Path.GetExtension(entry.Name));
                newNd.SelectedImageIndex = newNd.ImageIndex;

                if (parentNd == null)
                {
                    checkableTreeView1.Nodes.Add(newNd);
                }
                else
                {
                    parentNd.Nodes.Add(newNd);
                }
            }
        }