public List<string> LoadCVM(Stream iso_file, string cvmOpen) { List<string> files = new List<string>(); try { using (MemoryStream mt = new MemoryStream()) { CDReader cr = new CDReader(iso_file, true); MemoryStream mem = new MemoryStream((int)iso_file.Length); cr.OpenFile(cvmOpen, FileMode.Open).CopyTo(mem); mem.Seek(0x1800, SeekOrigin.Begin); mem.CopyTo(mt); mem.Dispose(); mem.Close(); CDReader cvmRead = new CDReader(mt, true); DiscUtils.DiscFileInfo[] filescvm = cvmRead.Root.GetFiles("*.*", SearchOption.AllDirectories); foreach (DiscUtils.DiscFileInfo file in filescvm) { files.Add(file.FullName.ToString()); } mt.Dispose(); mt.Close(); return files; } } catch (OutOfMemoryException) { return null; } }
public void ExtractFile(String FileSource, String FileTarget) { FileStream FileISO = File.Open(FileName, FileMode.Open, FileAccess.Read); try { CDReader ReaderISO = new CDReader(FileISO, true); SparseStream _SourceStream = ReaderISO.OpenFile(FileSource, FileMode.Open, FileAccess.Read); Byte[] _ReadAllByte = new Byte[_SourceStream.Length]; _SourceStream.Read(_ReadAllByte, 0, _ReadAllByte.Length); _SourceStream.Close(); FileStream _FileCreated = new FileStream(FileTarget, FileMode.CreateNew); _FileCreated.Position = 0; _FileCreated.Write(_ReadAllByte, 0, _ReadAllByte.Length); _FileCreated.Close(); } catch (IOException ex) { if (ex.Message != "No such file") { Console.WriteLine("-----------------------------------------------------"); Console.WriteLine("ExtractFile(" + FileSource + ", " + FileTarget + ")"); Console.WriteLine(ex.Message); Console.WriteLine("-----------------------------------------------------"); } else { Console.WriteLine("ExtractFile(" + FileSource + ") --> " + Path.GetFileName(FileName)); } } FileISO.Close(); }
public void BuildISO(Stream ISOOpen, string pathSave) { CDReader cd = new CDReader(ISOOpen, true); CDBuilder cb = new CDBuilder(); cb.UseJoliet = true; foreach (DiscFileInfo file in cd.Root.GetFiles("*.*", SearchOption.AllDirectories)) { foreach (DiscDirectoryInfo dir in cd.Root.GetDirectories("*.*", SearchOption.AllDirectories)) { cb.AddDirectory(dir.Name); cb.AddFile(file.FullName, cd.OpenFile(file.FullName, FileMode.Open)); } } cb.Build(pathSave); }
public Byte[] ReadAllByte(String FileSource) { Byte[] result = { 0x0 }; FileStream FileISO = File.Open(FileName, FileMode.Open, FileAccess.Read); try { CDReader ReaderISO = new CDReader(FileISO, true); SparseStream _SourceStream = ReaderISO.OpenFile(FileSource, FileMode.Open, FileAccess.Read); Byte[] _ReadAllByte = new Byte[_SourceStream.Length]; _SourceStream.Read(_ReadAllByte, 0, _ReadAllByte.Length); result = _ReadAllByte; _SourceStream.Close(); } catch (Exception ex) { Console.WriteLine("-----------------------------------------------------"); Console.WriteLine("ReadAllByte(" + FileSource + ")"); Console.WriteLine(ex.Message); Console.WriteLine("-----------------------------------------------------"); } FileISO.Close(); return result; }
private void CloneCdDirectory(string dir, CDReader cdr, CDBuilder cdb) { foreach (string fileName in cdr.GetFiles(dir)) { if (fileName == "\\reactos\\unattend.inf") continue; var stream = cdr.OpenFile(fileName, FileMode.Open); cdb.AddFile(fileName.Remove(0, 1), stream); stream.Close(); } foreach (string dirName in cdr.GetDirectories(dir)) { CloneCdDirectory(dirName, cdr, cdb); } }
private void extractToolStripMenuItem_Click(object sender, EventArgs e) { RandFunctions rn = new RandFunctions(); SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = treeView1.SelectedNode.Text; if (sfd.ShowDialog() != DialogResult.OK) return; string savePath = sfd.FileName; string fullPath = treeView1.SelectedNode.FullPath; fullPath = fullPath.Remove(0, 1); int index = fullPath.IndexOf(".CVM"); if (index > 0 && !treeView1.SelectedNode.Text.Contains(".CVM")) { string root = fullPath.Substring(0, fullPath.IndexOf("\\")); string path = fullPath.Substring(fullPath.IndexOf("\\") + 1); CDReader cd = new CDReader(ISOFile, true); Stream cvmOpen = cd.OpenFile(root, FileMode.Open); cvmOpen.Seek(0x1800, SeekOrigin.Begin); using (MemoryStream ms = new MemoryStream()) { cvmOpen.CopyTo(ms, (int)cvmOpen.Length); CDReader cvm = new CDReader(ms, true); Stream fileCVM = cvm.OpenFile(path, FileMode.Open); rn.ExtractFile(savePath, fileCVM); MessageBox.Show(Path.GetFileName(savePath) + " saved to file!", "PersonaISOEditor"); cvmOpen.Dispose(); cvmOpen.Close(); } } else { CDReader cd = new CDReader(ISOFile, true); Stream file = cd.OpenFile(fullPath, FileMode.Open); rn.ExtractFile(savePath, file); MessageBox.Show(Path.GetFileName(savePath) + " saved to file!", "PersonaISOEditor"); } }