Exemplo n.º 1
0
 public bool FileExist(string path)
 {
     using (var fs = new FileStream(IsoFileInfo.FullName, FileMode.Open, FileAccess.Read))
     {
         IsoReader reader = new IsoReader();
         reader.Parse(fs);
         var ret = DirectoryRecord.GetAllRecords(reader.WorkPvd.RootDir);
         return(ret.Any(x => x.IsFile && (x.FullPath.ToLower() == path.ToLower() || Path.Combine(mountInfo.MountTarget.FullName, x.FullPath).ToLower() == path.ToLower())));
     }
 }
Exemplo n.º 2
0
        public string ReadAllText(IFileInfo file)
        {
            using (var fs = new FileStream(IsoFileInfo.FullName, FileMode.Open, FileAccess.Read))
            {
                IsoReader reader = new IsoReader();
                reader.Parse(fs);
                //var ret = DirectoryRecord.GetAllRecords(reader.WorkPvd.RootDir);
                //var fr = ret.First(x => x.IsFile && x.FullPath.ToLower() == file.FullName.ToLower());

                var          dat = (file as IsoFileWrapper).record.GetFileData(fs, reader.WorkPvd);
                MemoryStream ms  = new MemoryStream(dat);
                var          rdr = new StreamReader(ms);
                return(rdr.ReadToEnd());
            }
        }
Exemplo n.º 3
0
        internal void LoadIso(string fullName)
        {
            try
            {
                IsoReader reader = new IsoReader();
                reader.Parse(fullName);
                pvdd = reader.Pvds.Last();

                UpdateList(pvdd.RootDir);
            }
            catch (UnauthorizedAccessException ex)
            {
                MessageBox.Show("Access error.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
 public IFileInfo GetFile(string path)
 {
     using (var fs = new FileStream(IsoFileInfo.FullName, FileMode.Open, FileAccess.Read))
     {
         IsoReader reader = new IsoReader();
         reader.Parse(fs);
         var ret = DirectoryRecord.GetAllRecords(reader.WorkPvd.RootDir);
         var aa  = ret.First(x => x.IsFile && x.FullPath.ToLower() == path.ToLower());
         return(new IsoFileWrapper(new MountInfo()
         {
             IsoPath = IsoFileInfo
         }, aa)
         {
             Filesystem = this
         });
     }
 }
Exemplo n.º 5
0
        internal static void MountIso(MountInfo mountInfo)
        {
            Stuff.MountInfos.Add(mountInfo);
            //extract .indx/meta.xml
            var f = mountInfo;

            if (f.Reader == null)
            {
                IsoReader reader = new IsoReader();
                reader.Parse(f.IsoPath.FullName);
                f.Reader = reader;
            }
            var r = new IsoDirectoryInfoWrapper(f, f.Reader.WorkPvd.RootDir);

            //r.Parent = null;
            r.Filesystem = new IsoFilesystem(f)
            {
                IsoFileInfo = f.IsoPath
            };
            if (r.Filesystem.FileExist(".indx\\meta.xml"))
            {
                var txt = r.Filesystem.ReadAllText(".indx\\meta.xml");
                var doc = XDocument.Parse(txt);
                foreach (var item in doc.Descendants("tag"))
                {
                    var nm   = item.Attribute("name").Value;
                    var tagg = Stuff.AddTag(new TagInfo()
                    {
                        Name = nm
                    });
                    foreach (var fitem in item.Descendants("file"))
                    {
                        var pt   = fitem.Value;
                        var path = Path.Combine(mountInfo.MountTarget.FullName, pt);
                        var fls  = Stuff.GetAllFiles(mountInfo.MountTarget);
                        var fr   = fls.First(z => z.FullName.ToLower() == path.ToLower());
                        tagg.AddFile(fr);
                        //tagg.AddFile((r.Filesystem as IsoFilesystem).GetFile(path));
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void mouseIsoAction(FileListControl sender, IFileInfo obj, IDirectoryInfo target)
        {
            var t = fileListControl1;

            if (target == null)
            {
                if (t == sender)
                {
                    t = fileListControl2;
                }
                target = t.CurrentDirectory;
            }
            if (Stuff.Question("Mount: " + obj.FullName + " to " + target.FullName + "?") == DialogResult.Yes)
            {
                var minf = new MountInfo();
                minf.IsoPath   = obj;
                minf.Path      = target.FullName;
                minf.IsMounted = true;
                if (minf.Reader == null)
                {
                    IsoReader reader = new IsoReader();
                    reader.Parse(minf.IsoPath.FullName);
                    minf.Reader = reader;
                }
                var r = new IsoDirectoryInfoWrapper(minf, minf.Reader.WorkPvd.RootDir);
                r.Parent         = new DirectoryInfoWrapper(minf.Path);
                minf.MountTarget = r;
                r.Filesystem     = new IsoFilesystem(minf)
                {
                    IsoFileInfo = minf.IsoPath
                };

                Stuff.MountIso(minf);
                if (target == null)
                {
                    t.UpdateList(target.FullName);
                }
            }
        }
Exemplo n.º 7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = "iso|*.iso";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    using (var fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
                    {
                        IsoReader reader = new IsoReader();
                        reader.Parse(fs);
                        pvdd = reader.Pvds[0];

                        UpdateList(pvdd.RootDir);
                    }
                }
                catch (UnauthorizedAccessException ex)
                {
                    MessageBox.Show("Access error.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 8
0
        private void isoExtractAction(FileListControl arg1, IFileInfo arg2)
        {
            var target = arg1;

            if (target == fileListControl1)
            {
                target = fileListControl2;
            }
            else
            {
                target = fileListControl1;
            }
            using (var fs = new FileStream(arg2.FullName, FileMode.Open, FileAccess.Read))
            {
                IsoReader reader = new IsoReader();
                reader.Parse(fs);
                var pvd = reader.WorkPvd;

                string savePath = Path.Combine(target.CurrentDirectory.FullName, Path.GetFileNameWithoutExtension(arg2.Name));
                if (!Directory.Exists(savePath))
                {
                    Directory.CreateDirectory(savePath);
                }
                var ret = DirectoryRecord.GetAllRecords(pvd.RootDir);

                foreach (var directoryRecord in ret)
                {
                    if (!directoryRecord.IsDirectory)
                    {
                        continue;
                    }
                    if (directoryRecord.LBA == pvd.RootDir.LBA)
                    {
                        continue;
                    }
                    if (directoryRecord.Parent != null && directoryRecord.Parent.LBA == directoryRecord.LBA)
                    {
                        continue;
                    }
                    if (directoryRecord.Parent != null &&
                        directoryRecord.Parent.Parent != null &&
                        directoryRecord.Parent.Parent.LBA == directoryRecord.LBA)
                    {
                        continue;
                    }

                    var pp = Path.Combine(savePath, directoryRecord.FullPath);
                    if (!Directory.Exists(pp))
                    {
                        Directory.CreateDirectory(pp);
                    }
                }


                foreach (var directoryRecord in ret)
                {
                    if (!directoryRecord.IsFile)
                    {
                        continue;
                    }
                    var data = directoryRecord.GetFileData(fs, pvd);
                    var pp   = Path.Combine(savePath, directoryRecord.FullPath);
                    File.WriteAllBytes(pp, data);
                }

                Stuff.Info("Extraction complete!");
            }
        }