Example #1
0
        private void iOpen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Title    = "RPFTool Archive";
            ofd.Filter   = "RPF Files (*.rpf)|*.rpf";
            ofd.FileName = _lastOpenPath;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                currentFileName = ofd.FileName;
                filelistview.ClearObjects();
                removeBreadCrumb(0);
                searching  = false;
                currentDir = null;
                try
                {
                    if (archiveFile != null)
                    {
                        archiveFile.Close();
                    }
                }
                catch
                {
                    MessageBox.Show("Failed to close the archive, please restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                bgwListBuilder.RunWorkerAsync();
            }
        }
Example #2
0
 private void listView1_DoubleClick(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count == 1)
     {
         if (listView1.SelectedItems[0].Tag.ToString() == "dir")
         {
             RPFLib.Common.Directory directory = new RPFLib.Common.Directory();
             foreach (RPFLib.Common.fileSystemObject entry in masterlist)
             {
                 if (entry.Name == listView1.SelectedItems[0].Text)
                 {
                     directory = entry as RPFLib.Common.Directory;
                 }
             }
             listView1.Items.Clear();
             buildlist(directory);
             //addBreadCrumb(directory);
         }
         else
         {
             RPFLib.Common.File file = new RPFLib.Common.File();
             foreach (RPFLib.Common.fileSystemObject entry in masterlist)
             {
                 if (entry.Name == listView1.SelectedItems[0].Text)
                 {
                     file = entry as RPFLib.Common.File;
                 }
             }
         }
     }
 }
Example #3
0
        private void buildlist(RPFLib.Common.Directory dir)
        {
            masterlist.Clear();
            currentDir = dir;

            //Setup return dir
            if (dir.ParentDirectory != null)
            {
                RPFLib.Common.ReturnDir returnDir = new ReturnDir();
                returnDir.Tag = dir.ParentDirectory;
                masterlist.Add(returnDir);
            }
            foreach (fileSystemObject item in dir)
            {
                if (item.IsDirectory)
                {
                    var subdir = item as RPFLib.Common.Directory;
                    masterlist.Add(item);
                }
                else
                {
                    var subFile = item as RPFLib.Common.File;
                    masterlist.Add(item);
                }
            }
            setViewObjects(masterlist);
        }
Example #4
0
        private void BuildFS()
        {
            RootDirectory = new RPFLib.Common.Directory();
            TOCEntry entry = _rpfFile.TOC[0];

            BuildFSDirectory(entry as DirectoryEntry, RootDirectory);
        }
Example #5
0
        public override List <fileSystemObject> search(RPFLib.Common.Directory dir, string searchText)
        {
            List <fileSystemObject> searchList = new List <fileSystemObject>();

            subsearch(dir, searchList, searchText);
            return(searchList);
        }
Example #6
0
        public override List <fileSystemObject> search(RPFLib.Common.Directory dir, string searchText)
        {
            List <fileSystemObject> searchList = new List <fileSystemObject>();

            searchList.AddRange((from pv in dir._fsObjectsByName
                                 where pv.Key.Contains(searchText)
                                 select pv.Value));
            subsearch(dir, searchList, searchText);
            return(searchList);
        }
Example #7
0
        private int FolderCount(RPFLib.Common.Directory directory)
        {
            int ctr = 0;

            foreach (fileSystemObject x in directory)
            {
                if (x.IsDirectory)
                {
                    ctr++;
                }
            }
            return(ctr);
        }
Example #8
0
 public void subsearch(RPFLib.Common.Directory dir, List <fileSystemObject> searchList, string searchText)
 {
     foreach (fileSystemObject item in dir)
     {
         if (item.IsDirectory)
         {
             var subdir = item as RPFLib.Common.Directory;
             searchList.AddRange((from pv in subdir._fsObjectsByName
                                  where pv.Key.Contains(searchText)
                                  select pv.Value));
             subsearch(subdir, searchList, searchText);
         }
     }
 }
Example #9
0
 public int CountFilesInHier(RPFLib.Common.Directory dir)
 {
     foreach (RPFLib.Common.fileSystemObject d in dir)
     {
         if (d.IsDirectory)
         {
             Task taskA = Task.Factory.StartNew(() => CountFilesInHier(d as RPFLib.Common.Directory));
             taskA.Wait();
         }
         else
         {
             countOfFiles++;
         }
     }
     return(countOfFiles);
 }
Example #10
0
 private void ExtractToPath(RPFLib.Common.Directory dir, string path, DoWorkEventArgs e)
 {
     foreach (fileSystemObject item in dir)
     {
         if ((backgroundWorker1.CancellationPending == true))
         {
             e.Cancel = true;
             break;
         }
         if (item.IsReturnDirectory)
         {
             continue;
         }
         else if (item.IsDirectory)
         {
             try
             {
                 System.IO.Directory.CreateDirectory(path + item.Name);
                 ExtractToPath(item as RPFLib.Common.Directory, Path.Combine(path, item.Name) + "\\", e);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             try
             {
                 int test = Convert.ToInt32(((double)fileprogress / filecount) * 100.0);
                 backgroundWorker1.ReportProgress(test);
                 var file = item as RPFLib.Common.File;
                 this.Invoke(new MethodInvoker(delegate { label_filename.Text = "Extracting: " + file.Name; }));
                 byte[] data = file.GetData(false);
                 System.IO.File.WriteAllBytes(Path.Combine(path, file.Name), data);
                 fileprogress++;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Example #11
0
 private bool ReIndex(RPFLib.Common.Directory dir)
 {
     try
     {
         dir.Reorder();
         foreach (var fsobject in dir)
         {
             entryIndex++;
             if (fsobject is RPFLib.Common.File)
             {
                 var file = fsobject as RPFLib.Common.File;
                 file.SetIndex(entryIndex);
             }
             else if (fsobject is RPFLib.Common.Directory)
             {
                 var directory = fsobject as RPFLib.Common.Directory;
                 directory.SetNewContentIndex(entryIndex);
             }
         }
         if (dir._Contentcount != null)
         {
             dir.SetContentCount();
         }
         foreach (var fsobject in dir)
         {
             if (fsobject is RPFLib.Common.Directory)
             {
                 RPFLib.Common.Directory dirEntry = fsobject as RPFLib.Common.Directory;
                 dirEntry.SetContentIndex(entryIndex + 1);
                 if (!ReIndex(dirEntry))
                 {
                     return(false);
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         //throw new Exception(ex.Message, ex);
         return(false);
     }
 }
Example #12
0
 private void startBreadCrumb(RPFLib.Common.Directory directory)
 {
     try
     {
         BarButtonItem barItem = new BarButtonItem();
         barItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;
         barItem.Glyph      = RPFTool.Properties.Resources.Home;
         barItem.Id         = mainStatusbar.ItemLinks.Count + 1;
         barItem.Tag        = directory;
         barItem.Caption    = "Root";
         this.barManager.Items.Add(barItem);
         barItem.ItemClick += new ItemClickEventHandler(barButtonItem_ItemClick);
         mainStatusbar.AddItem(barItem);
     }
     catch
     {
         mainStatusbar.ItemLinks.Clear();
     }
 }
Example #13
0
 private int dirCount(RPFLib.Common.Directory dir, int filecount)
 {
     foreach (fileSystemObject item in dir)
     {
         if (item.IsReturnDirectory)
         {
             continue;
         }
         else if (item.IsDirectory)
         {
             filecount = dirCount(item as RPFLib.Common.Directory, filecount);
         }
         else
         {
             filecount++;
         }
     }
     return(filecount);
 }
Example #14
0
        private void buildlist(RPFLib.Common.Directory dir)
        {
            masterlist.Clear();
            currentDir = dir;

            //Setup return dir
            foreach (fileSystemObject item in dir)
            {
                if (item.IsDirectory)
                {
                    var subdir = item as RPFLib.Common.Directory;
                    masterlist.Add(item);
                }
                else
                {
                    var subFile = item as RPFLib.Common.File;
                    masterlist.Add(item);
                }
            }
            setViewObjects(masterlist);
            pathLabel.Text = currentDir.FullName;
        }
Example #15
0
 public void BrowseHier(RPFLib.Common.Directory dir, RPFLib.Common.Directory rDir)
 {
     foreach (RPFLib.Common.fileSystemObject d in dir)
     {
         if (d.IsDirectory)
         {
             BrowseHier(d as RPFLib.Common.Directory, rDir);
             System.IO.Directory.CreateDirectory(extrPath + "\\" + rDir.Name + "\\" + d.FullName.Replace(rDir.FullName + "\\", ""));
         }
         else
         {
             currentCount++;
             RPFLib.Common.File file = d as RPFLib.Common.File;
             byte[]             data = file.GetData(false);
             if (!(System.IO.Directory.Exists(extrPath + "\\" + rDir.Name + "\\" + file.FullName.Replace(rDir.FullName + "\\", "").Replace(file.Name, ""))))
             {
                 System.IO.Directory.CreateDirectory(extrPath + "\\" + rDir.Name + "\\" + file.FullName.Replace(rDir.FullName + "\\", "").Replace(file.Name, ""));
             }
             System.IO.File.WriteAllBytes(extrPath + "\\" + rDir.Name + "\\" + file.FullName.Replace(rDir.FullName + "\\", ""), data);
         }
     }
 }
Example #16
0
        private void addBreadCrumb(RPFLib.Common.Directory directory)
        {
            try
            {
                BarStaticItem bartextItem = new BarStaticItem();
                bartextItem.Border    = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
                bartextItem.Caption   = ">";
                bartextItem.Alignment = BarItemLinkAlignment.Left;
                mainStatusbar.AddItem(bartextItem);

                BarButtonItem barItem = new BarButtonItem();
                barItem.Id         = mainStatusbar.ItemLinks.Count + 1;
                barItem.Tag        = directory;
                barItem.Caption    = directory.Name;
                barItem.ItemClick += new ItemClickEventHandler(barButtonItem_ItemClick);
                barItem.Alignment  = BarItemLinkAlignment.Left;
                mainStatusbar.AddItem(barItem);
            }
            catch
            {
                mainStatusbar.ItemLinks.Clear();
            }
        }
Example #17
0
        private void Add(RPFLib.Common.Directory fsDirectory, byte[] data)
        {
            FileEntry newFileEntry = new FileEntry(_rpfFile.TOC);

            _rpfFile.TOC.Add(newFileEntry as TOCEntry);

            var file = new Common.File();

            file._dataLoad   = getCustom => LoadData(newFileEntry, getCustom);
            file._dataStore  = setdata => StoreData(newFileEntry, setdata);
            file._dataCustom = () => newFileEntry.CustomData != null;
            file.d1          = () => newFileEntry.getSize();
            file._Index      = nIndex => newFileEntry.setIndex(nIndex);
            file._delete     = () => newFileEntry.Delete();

            file.CompressedSize  = newFileEntry.SizeInArchive;
            file.IsCompressed    = newFileEntry.IsCompressed;
            file.Name            = GetName(newFileEntry);
            file.IsResource      = newFileEntry.IsResourceFile;
            file.ParentDirectory = fsDirectory;
            fsDirectory.AddObject(file);

            newFileEntry.SetCustomData(data);
        }
Example #18
0
 private void btn_goto_Click(object sender, EventArgs e)
 {
     try
     {
         if (filelistview.SelectedObjects.Count == 1)
         {
             using (Cursors.WaitCursor)
             {
                 List <RPFLib.Common.Directory> pathList = new List <RPFLib.Common.Directory>();
                 var    currentfile = filelistview.SelectedObject as fileSystemObject;
                 string filename    = currentfile.Name;
                 var    currentDir  = currentfile.ParentDirectory;
                 while (currentDir != null)
                 {
                     pathList.Add(currentDir);
                     currentDir = currentDir.ParentDirectory;
                 }
                 pathList.Reverse();
                 for (int i = 1; i < pathList.Count; i++)
                 {
                     var dir = pathList[i] as RPFLib.Common.Directory;
                     addBreadCrumb(dir);
                 }
                 buildlist(pathList[pathList.Count - 1]);
                 filelistview.SelectedIndex = filelistview.FindMatchingRow(filename, 0, SearchDirectionHint.Down);
                 filelistview.EnsureModelVisible(filelistview.SelectedObject);
                 searching = false;
             }
         }
     }
     catch
     {
         MessageBox.Show("Failed to find file folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         reset();
     }
 }
Example #19
0
 private void btn_goto_Click(object sender, EventArgs e)
 {
     try
     {
         if (filelistview.SelectedObjects.Count == 1)
         {
             using (Cursors.WaitCursor)
             {
                 List<RPFLib.Common.Directory> pathList = new List<RPFLib.Common.Directory>();
                 var currentfile = filelistview.SelectedObject as fileSystemObject;
                 string filename = currentfile.Name;
                 var currentDir = currentfile.ParentDirectory;
                 while (currentDir != null)
                 {
                     pathList.Add(currentDir);
                     currentDir = currentDir.ParentDirectory;
                 }
                 pathList.Reverse();
                 for (int i = 1; i < pathList.Count; i++)
                 {
                     var dir = pathList[i] as RPFLib.Common.Directory;
                     addBreadCrumb(dir);
                 }
                 buildlist(pathList[pathList.Count - 1]);
                 filelistview.SelectedIndex = filelistview.FindMatchingRow(filename, 0, SearchDirectionHint.Down);
                 filelistview.EnsureModelVisible(filelistview.SelectedObject);
                 searching = false;
             }
         }
     }
     catch
     {
         MessageBox.Show("Failed to find file folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         reset();
     }
 }
Example #20
0
        private void buildlist(RPFLib.Common.Directory dir)
        {
            masterlist.Clear();
            currentDir = dir;

            //Setup return dir
            if (dir.ParentDirectory != null)
            {
                RPFLib.Common.ReturnDir returnDir = new ReturnDir();
                returnDir.Tag = dir.ParentDirectory;
                masterlist.Add(returnDir);
            }
            foreach (fileSystemObject item in dir)
            {
                if (item.IsDirectory)
                {
                    var subdir = item as RPFLib.Common.Directory;
                    masterlist.Add(item);
                }
                else
                {
                    var subFile = item as RPFLib.Common.File;
                    masterlist.Add(item);
                }
            }
            setViewObjects(masterlist);
        }
Example #21
0
        private void backgroundWorker3_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (backButton.GetCurrentParent().InvokeRequired)
                {
                    backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = false));
                }
                else
                {
                    backButton.Enabled = false;
                }
                if (extrButton.GetCurrentParent().InvokeRequired)
                {
                    extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = false));
                }
                else
                {
                    extrButton.Enabled = false;
                }
                if (extrAllButton.GetCurrentParent().InvokeRequired)
                {
                    extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = false));
                }
                else
                {
                    extrAllButton.Enabled = false;
                }
                if (uncompressButton.GetCurrentParent().InvokeRequired)
                {
                    uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = false));
                }
                else
                {
                    uncompressButton.Enabled = false;
                }
                using (FolderBrowserDialog sfrm = new FolderBrowserDialog())
                {
                    DialogResult testthing = DialogResult.None;
                    if (this.InvokeRequired)
                    {
                        this.Invoke((MethodInvoker)(() => testthing = sfrm.ShowDialog(this)));
                    }
                    else
                    {
                        testthing = sfrm.ShowDialog(this);
                    }
                    if (testthing == DialogResult.OK)
                    {
                        extrPath     = sfrm.SelectedPath;
                        countOfFiles = 0;
                        Task taskA = Task.Factory.StartNew(() =>
                        {
                            foreach (RPFLib.Common.fileSystemObject entry in masterlist)
                            {
                                if (entry.IsDirectory)
                                {
                                    RPFLib.Common.Directory dir = entry as RPFLib.Common.Directory;
                                    CountFilesInHier(dir);
                                }
                                else
                                {
                                    countOfFiles++;
                                }
                            }
                        });
                        taskA.Wait();

                        if (toolStripProgressBar1.GetCurrentParent().InvokeRequired)
                        {
                            toolStripProgressBar1.GetCurrentParent().Invoke((MethodInvoker)(() =>
                            {
                                timer1.Enabled = true;
                                timer1.Start();
                            }));
                        }
                        else
                        {
                            timer1.Enabled = true;
                            timer1.Start();
                        }

                        Task taskB = Task.Factory.StartNew(() =>
                        {
                            foreach (RPFLib.Common.fileSystemObject entry in masterlist)
                            {
                                if (entry.IsDirectory)
                                {
                                    RPFLib.Common.Directory dir = entry as RPFLib.Common.Directory;
                                    System.IO.Directory.CreateDirectory(extrPath + "\\" + dir.Name);
                                    BrowseHier(dir, dir);
                                }
                                else
                                {
                                    RPFLib.Common.File file = entry as RPFLib.Common.File;
                                    byte[] data             = file.GetData(false);
                                    System.IO.File.WriteAllBytes(sfrm.SelectedPath + "\\" + file.Name, data);
                                }
                            }
                        });
                        taskB.Wait();

                        if (toolStripProgressBar1.GetCurrentParent().InvokeRequired)
                        {
                            toolStripProgressBar1.GetCurrentParent().Invoke((MethodInvoker)(() =>
                            {
                                timer1.Stop();
                                timer1.Enabled = false;
                                toolStripProgressBar1.Value = 0;
                            }));
                        }
                        else
                        {
                            timer1.Stop();
                            timer1.Enabled = false;
                            toolStripProgressBar1.Value = 0;
                        }
                    }
                }
                if (backButton.GetCurrentParent().InvokeRequired)
                {
                    backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = true));
                }
                else
                {
                    backButton.Enabled = true;
                }
                if (extrButton.GetCurrentParent().InvokeRequired)
                {
                    extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = true));
                }
                else
                {
                    extrButton.Enabled = true;
                }
                if (extrAllButton.GetCurrentParent().InvokeRequired)
                {
                    extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = true));
                }
                else
                {
                    extrAllButton.Enabled = true;
                }
                if (uncompressButton.GetCurrentParent().InvokeRequired)
                {
                    uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = true));
                }
                else
                {
                    uncompressButton.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                Application.Exit();
            }
        }
Example #22
0
        private void iOpen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var ofd = new OpenFileDialog();
            ofd.Title = "RPFTool Archive";
            ofd.Filter = "RPF Files (*.rpf)|*.rpf";
            ofd.FileName = _lastOpenPath;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                currentFileName = ofd.FileName;
                filelistview.ClearObjects();
                removeBreadCrumb(0);
                searching = false;
                currentDir = null;
                try
                {
                    if (archiveFile != null)
                    {
                        archiveFile.Close();
                    }
                }
                catch
                {
                    MessageBox.Show("Failed to close the archive, please restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                bgwListBuilder.RunWorkerAsync();
            }
        }
Example #23
0
        private void BuildFSDirectory(DirectoryEntry dirEntry, RPFLib.Common.Directory fsDirectory)
        {
            try
            {
                fsDirectory.Name = GetName(dirEntry);
                for (int i = 0; i < dirEntry.ContentEntryCount; i++)
                {
                    TOCEntry entry = _rpfFile.TOC[dirEntry.ContentEntryIndex + i];
                    if (entry.IsDirectory)
                    {
                        var subdirEntry = entry as DirectoryEntry;
                        var dir         = new RPFLib.Common.Directory();
                        dir._Contentcount   = nCount => subdirEntry.setContentcount(nCount);
                        dir._ContentIndex   = ContentIndex => subdirEntry.setContentIndex(ContentIndex);
                        dir._Index          = NewContentIndex => subdirEntry.setNewContentIndex(NewContentIndex);
                        dir.nameHash        = (uint)subdirEntry.NameOffset;
                        dir.ParentDirectory = fsDirectory;
                        dir.Attributes      = "Folder";
                        BuildFSDirectory(entry as DirectoryEntry, dir);
                        fsDirectory.AddObject(dir);
                    }
                    else
                    {
                        var fileEntry = entry as FileEntry;
                        var file      = new Common.File();
                        file._dataLoad   = getCustom => LoadData(fileEntry, getCustom);
                        file._dataStore  = data => StoreData(fileEntry, data);
                        file._dataCustom = () => fileEntry.CustomData != null;
                        file.d1          = () => fileEntry.getSize();
                        file._Index      = nIndex => fileEntry.setIndex(nIndex);
                        file._delete     = () => fileEntry.Delete();

                        file.CompressedSize  = fileEntry.SizeInArchive;
                        file.IsCompressed    = fileEntry.IsCompressed;
                        file.nameHash        = (uint)fileEntry.NameOffset;
                        file.Name            = GetName(fileEntry);
                        file.IsResource      = fileEntry.IsResourceFile;
                        file.resourcetype    = (int)fileEntry.ResourceType;//Convert.ToString((ResourceType)fileEntry.ResourceType);
                        file.ParentDirectory = fsDirectory;

                        StringBuilder attributes = new StringBuilder();
                        if (file.IsResource)
                        {
                            attributes.Append(string.Format("Resource [Version {0}", fileEntry.ResourceType));
                            if (file.IsCompressed)
                            {
                                attributes.Append(", Compressed");
                            }
                            attributes.Append("]");
                        }
                        else if (file.IsCompressed)
                        {
                            attributes.Append("Compressed");
                        }
                        else
                        {
                            attributes.Append("None");
                        }
                        file.Attributes = attributes.ToString();
                        fsDirectory.AddObject(file);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
Example #24
0
        private void BuildFS()
        {
            RootDirectory = new RPFLib.Common.Directory();

            TOCEntry entry = _rpfFile.TOC[0];
            BuildFSDirectory(entry as DirectoryEntry, RootDirectory);
        }
Example #25
0
        private void BuildFSDirectory(DirectoryEntry dirEntry, RPFLib.Common.Directory fsDirectory)
        {
            try
            {
                fsDirectory.Name = GetName(dirEntry);
                for (int i = 0; i < dirEntry.ContentEntryCount; i++)
                {

                    TOCEntry entry = _rpfFile.TOC[dirEntry.ContentEntryIndex + i];
                    if (entry.IsDirectory)
                    {
                        var subdirEntry = entry as DirectoryEntry;
                        var dir = new RPFLib.Common.Directory();
                        dir._Contentcount = nCount => subdirEntry.setContentcount(nCount);
                        dir._ContentIndex = ContentIndex => subdirEntry.setContentIndex(ContentIndex);
                        dir._Index = NewContentIndex => subdirEntry.setNewContentIndex(NewContentIndex);
                        dir.Attributes = "Folder";
                        //dir.entryNum = dirEntry.ContentEntryIndex + i;
                        dir.ParentDirectory = fsDirectory;
                        BuildFSDirectory(entry as DirectoryEntry, dir);
                        fsDirectory.AddObject(dir);
                    }
                    else
                    {
                        var fileEntry = entry as FileEntry;
                        var file = new Common.File();
                        file._dataLoad = getCustom => LoadData(fileEntry, getCustom);
                        file._dataStore = data => StoreData(fileEntry, data);
                        file._dataCustom = () => fileEntry.CustomData != null;
                        file.d1 = () => fileEntry.getSize();
                        file._Index = nIndex => fileEntry.setIndex(nIndex);
                        file._delete = () => fileEntry.Delete();

                        //file.entryNum = dirEntry.ContentEntryIndex + i;
                        file.CompressedSize = fileEntry.SizeInArchive;
                        file.IsCompressed = fileEntry.IsCompressed;
                        file.Name = GetName(fileEntry);
                        //file.Size = fileEntry.Size;
                        file.IsResource = fileEntry.IsResourceFile;
                        file.ParentDirectory = fsDirectory;
                        StringBuilder attributes = new StringBuilder();
                        if (file.IsResource)
                        {
                            attributes.Append(string.Format("Resource [Version {0}", fileEntry.ResourceType));
                            if (file.IsCompressed)
                            {
                                attributes.Append("Compressed");
                            }
                            attributes.Append("]");
                        }
                        else if (file.IsCompressed)
                        {
                            attributes.Append("Compressed");
                        }
                        else
                            attributes.Append("None");
                        fsDirectory.AddObject(file);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
Example #26
0
 private void listView1_DoubleClick(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count == 1)
     {
         if (listView1.SelectedItems[0].Tag.ToString() == "dir")
         {
             RPFLib.Common.Directory directory = new RPFLib.Common.Directory();
             foreach (RPFLib.Common.fileSystemObject entry in masterlist)
             {
                 if (entry.Name == listView1.SelectedItems[0].Text)
                 {
                     directory = entry as RPFLib.Common.Directory;
                 }
             }
             listView1.Items.Clear();
             buildlist(directory);
             //addBreadCrumb(directory);
         }
         else
         {
             RPFLib.Common.File file = new RPFLib.Common.File();
             foreach (RPFLib.Common.fileSystemObject entry in masterlist)
             {
                 if (entry.Name == listView1.SelectedItems[0].Text)
                 {
                     file = entry as RPFLib.Common.File;
                 }
             }
         }
     }
 }
Example #27
0
 public abstract List <fileSystemObject> search(RPFLib.Common.Directory dir, string searchText);
Example #28
0
        private void buildlist(RPFLib.Common.Directory dir)
        {
            masterlist.Clear();
            currentDir = dir;

            //Setup return dir
            foreach (fileSystemObject item in dir)
            {
                if (item.IsDirectory)
                {
                    var subdir = item as RPFLib.Common.Directory;
                    masterlist.Add(item);
                }
                else
                {
                    var subFile = item as RPFLib.Common.File;
                    masterlist.Add(item);
                }
            }
            setViewObjects(masterlist);
            pathLabel.Text = currentDir.FullName;
        }