Example #1
0
 static void PlatformDetection_DetectIso9660(string path, Iso9660 disc, PlatformList platforms)
 {
     if (DetectDirectoryNode != null)
     {
         DetectDirectoryNode(path, disc.Root, platforms);
     }
 }
Example #2
0
        public static DirectoryNode GetDirectoryStructure(this PlatformData platform, string path)
        {
            platform.Session["path"] = path;

            if (Directory.Exists(path))
            {
                DirectoryNode root = DirectoryNode.FromPath(path, platform.Cache, FileAccess.Read, FileShare.Read);
                platform.Session["rootdirnode"] = root;
                return(root);
            }
            else if (File.Exists(path))
            {
                Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                platform.Cache.AddStream(stream);

                try {
                    stream.Position = 0;
                    Iso9660 iso = new Iso9660(stream);
                    platform.Session["iso"]         = iso;
                    platform.Session["rootdirnode"] = iso.Root;
                    return(iso.Root);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as ISO: " + path);
                }

                try {
                    stream.Position = 0;
                    Disc disc = new Disc(stream);

                    platform.Session["wiidisc"] = disc;

                    Partition partition = disc.DataPartition;
                    if (partition == null)
                    {
                        throw new FormatException();
                    }

                    platform.Session["rootdirnode"] = partition.Root.Root;
                    return(partition.Root.Root);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as Wiidisc: " + path);
                }

                try {
                    stream.Position = 0;
                    U8 u8 = new U8(stream);
                    platform.Session["u8"]          = u8;
                    platform.Session["rootdirnode"] = u8.Root;
                    return(u8.Root);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as U8: " + path);
                }
            }

            Exceptions.Error("Could not find a proper file type handler for " + path);
            throw new NotSupportedException();
        }
Example #3
0
        static void PlatformDetection_DetectFile(string path, Stream stream, PlatformList platforms)
        {
            if (DetectWiiDisc != null)
            {
                try {
                    stream.Position = 0;
                    Disc disc = new Disc(stream);
                    DetectWiiDisc(path, disc, platforms);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as Wiidisc: " + path);
                }
            }

            if (DetectIso9660 != null)
            {
                try {
                    stream.Position = 0;
                    Iso9660 disc = new Iso9660(stream);
                    DetectIso9660(path, disc, platforms);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as ISO: " + path);
                }
            }

            if (DetectXbox360Dlc != null)
            {
                try {
                    stream.Position = 0;
                    StfsArchive stfs = new StfsArchive(stream);
                    DetectXbox360Dlc(path, stfs, platforms);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as 360 DLC: " + path);
                }
            }

            if (DetectWiiU8 != null)
            {
                try {
                    stream.Position = 0;
                    U8 u8 = new U8(stream);
                    DetectWiiU8(path, u8, platforms);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as U8: " + path);
                }
            }

            if (DetectWiiDlcBin != null)
            {
                try {
                    stream.Position = 0;
                    DlcBin dlc = new DlcBin(stream);
                    DetectWiiDlcBin(path, dlc, platforms);
                } catch (FormatException) { } catch (Exception exception) {
                    Exceptions.Warning(exception, "Trying to open as Wii DLC: " + path);
                }
            }

            if (DetectHarmonixArk != null)
            {
                string extension = Path.GetExtension(path).ToLower();
                if (extension.EndsWith(".ark") || extension.EndsWith(".hdr"))
                {
                    PlatformDetection_DetectDirectory(Path.GetDirectoryName(path), platforms);
                }
            }
        }
Example #4
0
File: CD.cs Project: jgennari/NCR
        static void cISO_OnProgress(Iso9660.EventIso9660 e)
        {
            frmMain mf = (frmMain)Application.OpenForms["frmMain"];
            bool update = false;

            MethodInvoker action = delegate
            {
                foreach (ListViewItem lvi in mf.lvRips.Items)
                {

                    float fPercent = e.WrittenSize / float.Parse(cISO.SizeOfCD.ToString());

                    if (lvi.SubItems[0].Text == "ISO" && lvi.SubItems[2].Text != fPercent.ToString("0.0%"))
                    {
                        lvi.SubItems[1].Text = strIsoFile;
                        lvi.SubItems[2].Text = fPercent.ToString("0.0%");

                        if (fPercent == 1)
                            lvi.Remove();
                    }

                    update = true;
                }

                if (!update)
                {
                    ListViewItem lvitem = new ListViewItem(new string[] { "ISO", strIsoFile, "0%" });
                    mf.lvRips.Items.Add(lvitem);
                }
            };

            mf.BeginInvoke(action);
        }
Example #5
0
File: CD.cs Project: jgennari/NCR
 static void cISO_OnMessage(Iso9660.EventIso9660 e)
 {
     string strError = e.ErrorMessage;
     boolIsoError = true;
 }
Example #6
0
File: CD.cs Project: jgennari/NCR
        static void cISO_OnFinish(Iso9660.EventIso9660 e)
        {
            boolIsoDone = true;

            frmMain mf = (frmMain)Application.OpenForms["frmMain"];
            MethodInvoker action = delegate
            {
                foreach (ListViewItem lvi in mf.lvRips.Items)
                {
                    if (lvi.SubItems[0].Text == "ISO")
                        lvi.Remove();
                }
            };

            mf.BeginInvoke(action);
        }
Example #7
0
        static void Main(string[] args)
        {
            string dir = string.Empty;

            if (args.Length == 2)
            {
                dir = args[1];
            }
            else if (args.Length == 1)
            {
                dir = args[0] + ".ext";
            }
            else
            {
                Console.WriteLine("Usage: wiidiscextractor /path/to/disc.iso /extract/path");
                return;
            }

            Directory.CreateDirectory(dir);

            try {
                if (!Directory.Exists(args[0]))
                {
                    throw new FormatException();
                }
                DelayedStreamCache cache = new DelayedStreamCache();
                DirectoryNode      dirn  = DirectoryNode.FromPath(args[0], cache, FileAccess.Read, FileShare.Read);
                DirectoryNode      gen   = dirn.Navigate("gen", false, true) as DirectoryNode;
                if (gen == null)                 // Just in case we're given the "wrong" directory that directly contains the ark
                {
                    gen = dirn;
                }

                List <Pair <int, Stream> > arkfiles = new List <Pair <int, Stream> >();
                Stream hdrfile = null;
                foreach (FileNode file in gen.Files)
                {
                    if (file.Name.ToLower().EndsWith(".hdr"))
                    {
                        hdrfile = file.Data;
                    }
                    else if (file.Name.ToLower().EndsWith(".ark"))
                    {
                        Match match = Regex.Match(file.Name.ToLower(), @"_(\d+).ark");
                        if (match.Success)
                        {
                            arkfiles.Add(new Pair <int, Stream>(int.Parse(match.Groups[1].Value), file.Data));
                        }
                        else
                        {
                            arkfiles.Add(new Pair <int, Stream>(0, file.Data));
                        }
                    }
                }

                // FreQuency/Amplitude where the header is the ark
                if (hdrfile == null)
                {
                    if (arkfiles.Count == 1)
                    {
                        hdrfile = arkfiles[0].Value;
                        arkfiles.Clear();
                    }
                    else
                    {
                        throw new FormatException();
                    }
                }

                Ark ark = new Ark(new EndianReader(hdrfile, Endianness.LittleEndian), arkfiles.OrderBy(f => f.Key).Select(f => f.Value).ToArray());
                ark.Root.Extract(dir);
                cache.Dispose();
            } catch (FormatException) {
                Stream stream = new FileStream(args[0], FileMode.Open, FileAccess.Read);
                try {
                    Iso9660 iso = new Iso9660(stream);
                    iso.Root.Extract(dir);
                } catch (Exception) {
                    try {
                        stream.Position = 0;
                        Disc disc = new Disc(stream);

                        File.WriteAllText(Path.Combine(dir, "title"), disc.Title);

                        foreach (var partition in disc.Partitions)
                        {
                            string path = Path.Combine(dir, "partition" + disc.Partitions.IndexOf(partition).ToString());
                            Directory.CreateDirectory(path);

                            partition.Root.Root.Extract(Path.Combine(path, "data"));

                            FileStream file = new FileStream(Path.Combine(path, "partition.tik"), FileMode.Create, FileAccess.Write);
                            partition.Ticket.Save(file);
                            file.Close();

                            file = new FileStream(Path.Combine(path, "partition.tmd"), FileMode.Create, FileAccess.Write);
                            partition.TMD.Save(file);
                            file.Close();

                            file = new FileStream(Path.Combine(path, "partition.certs"), FileMode.Create, FileAccess.Write);
                            file.Write(partition.CertificateChain);
                            file.Close();
                        }
                    } catch {
                        try {
                            stream.Position = 0;
                            DlcBin bin = new DlcBin(stream);
                            U8     u8  = new U8(bin.Data);
                            u8.Root.Extract(dir);
                        } catch {
                            try {
                                stream.Position = 0;
                                U8 u8 = new U8(stream);
                                u8.Root.Extract(dir);
                            } catch {
                                stream.Position = 0;
                                Rarc rarc = new Rarc(stream);
                                rarc.Root.Extract(dir);
                            }
                        }
                    }
                }
                stream.Close();
            }
        }