Example #1
0
/*
 *      // incomplete function
 *      static bool createXISO(string infolder, string outfile)
 *      {
 *          XBoxISO.ISOWriter xiso = new ISOWriter();
 *          xiso.IsXbox360Iso = false;
 *          xiso.SetFileSource();
 *          return true;
 *      }
 */
        static void convertISO(string infile, string outfile)
        {
            XboxISOFileSource xisosrc = new XboxISOFileSource(infile);

            if (xisosrc.GetISOType() != Format.Xbox1)
            {
                Console.Write("This utility only supports ORIGINAL XBox ISOs");
                return;
            }
            ISOWriter              xiso      = new ISOWriter();
            FileSystemEntry        xfs       = xisosrc.GetFileSystem();
            List <FileSystemEntry> fslist    = xfs.GetFileList();
            FSManipulator          xfsm      = new FSManipulator();
            FSFileOptimiseComparer xiso_sort = new FSFileOptimiseComparer();

            XBoxISO.CrossLinkChecker clc = new CrossLinkChecker();
            CopyStatus cs     = new CopyStatus();
            bool       result = false;

            ISOPartitionDetails isop = xisosrc.GetPartitionDetails();

            Console.Write("Optimizing XISO Filesystem Layout...");

            if ((long)isop.GamePartitionSize > XBoxDVDReader.DVD5MaxSize)
            {
                result = xfsm.OptimiseDVD9(xfs, false, true, true, isop);
            }
            else
            {
                result = xfsm.OptimiseDVD5(xfs, false, false, true, true, false, 0, false, isop);
            }
            if (result)
            {
                Console.WriteLine(" Success.");
            }
            else
            {
                Console.WriteLine(" Failed... but thats okay, continuing.");
            }

            Console.WriteLine("Checking for crosslinkable files...");
            BackgroundWorker clc_bw = new BackgroundWorker();

            clc_bw.WorkerReportsProgress      = true;
            clc_bw.WorkerSupportsCancellation = true;
            clc_bw.ProgressChanged           += clc_bw_ProgressChanged;
            clc.CrossLinkCheck(xfs, cs, clc_bw);
            Console.WriteLine();

            Console.WriteLine("Writing ISO to " + outfile + "...");
            BackgroundWorker main_bw = new BackgroundWorker();

            main_bw.WorkerReportsProgress      = true;
            main_bw.WorkerSupportsCancellation = true;
            main_bw.ProgressChanged           += main_bw_ProgressChanged;
            xiso.writeISO(outfile, xfs, main_bw, false);
            Console.WriteLine();
            Console.WriteLine("Done!");
        }
Example #2
0
        // Unused but functional function
        static bool extractISO(string infile, string outfolder = null, int blocksize = 32768)
        {
            if (outfolder == null)
            {
                List <string> tmp = infile.Split('/').Last().Split('.').ToList();
                tmp.RemoveAt(tmp.Count - 1);
                outfolder = String.Join(".", tmp);
                Console.WriteLine(outfolder);
            }

            if (!Directory.Exists(outfolder))
            {
                Directory.CreateDirectory(outfolder);
            }

            XboxISOFileSource      xisosrc = new XboxISOFileSource(infile);
            FileSystemEntry        xfs     = xisosrc.GetFileSystem();
            List <FileSystemEntry> fslist  = xfs.GetFileList();

            foreach (FileSystemEntry fsentry in fslist)
            {
                if (fsentry.FileName == "XDFS Root")
                {
                    continue;
                }

                if (fsentry.IsFolder)
                {
                    Directory.CreateDirectory(outfolder + "\\" + fsentry.FileName);
                    continue;
                }

                Stream z_in = fsentry.GetStream();
                if (z_in.CanRead)
                {
                    FileStream z_out = File.Create(outfolder + "\\" + fsentry.FullPath);

                    int  this_read    = 0;
                    int  total_read   = 0;
                    long left_to_read = z_in.Length;

                    while (left_to_read > 0)
                    {
                        int    local_bs = getReadSize(left_to_read, blocksize);
                        byte[] data     = new byte[local_bs + 1];
                        this_read = z_in.Read(data, 0, local_bs);
                        z_out.Write(data, 0, this_read);
                        total_read   += this_read;
                        left_to_read -= this_read;
                        Console.Write("\rWriting File: " + fsentry.FullPath + ":\t" + friendlyBytes((long)total_read) + "/" + friendlyBytes((long)z_in.Length) + "         ");
                    }
                    Console.Write("\n");
                    z_in.Close();
                    z_out.Close();
                }
                else
                {
                    Console.WriteLine("Internal Error: Could not read ISO file " + fsentry.FullPath);
                    z_in.Close();
                    return(false);
                }
            }
            return(true);
        }
        public static void Gather(Media medium, Stream infile)
        {
            string            failed  = "";
            XboxISOFileSource xboxIso = XboxISOFileSource.TryOpen(infile);

            if (xboxIso != null)
            {
                XDvdFsFileSystemEntry xdvdfs = xboxIso.GetFileSystem();
                Gather(medium, xdvdfs, null);
                infile.Dispose();
                return;
            }
            failed += "XDVDFS\n";

            if (CDReader.Detect(infile))
            {
                CDReader cdReader = new CDReader(infile, true, false);
                Gather(medium, cdReader.Root, null);
                infile.Dispose();
                return;
            }
            failed += "ISO9660\n";

            if (UdfReader.Detect(infile))
            {
                UdfReader udfReader = new UdfReader(infile);

                if (udfReader != null)
                {
                    try
                    {
                        Gather(medium, udfReader.Root, null);
                        return;
                    }
                    catch (Exception)
                    {
                        AzusaContext.GetInstance().DatabaseDriver.ForgetFilesystemContents(medium.Id);
                    }
                }
            }
            failed += "UDF\n";

            if (FatFileSystem.Detect(infile))
            {
                FatFileSystem fat = new FatFileSystem(infile);
                Gather(medium, fat.Root, null);
                infile.Dispose();
                return;
            }
            failed += "FAT32\n";

            if (infile.Length < 3200)
            {
                FileStream fileStream = infile as FileStream;
                if (fileStream != null)
                {
                    fileStream.Dispose();
                    FileInfo fi          = new FileInfo(fileStream.Name);
                    Stream   gdRomStream = GDROMReader.BuildGdRomStream(fi);
                    if (CDReader.Detect(gdRomStream))
                    {
                        CDReader cdReader = new CDReader(gdRomStream, true, false);
                        Gather(medium, cdReader.Root, null);
                        infile.Dispose();
                        return;
                    }
                }
            }
            failed += "GD-ROM\n";

            infile.Position = 0;
            byte[] firstSector = new byte[2352];
            if (infile.Read(firstSector, 0, firstSector.Length) == firstSector.Length)
            {
                byte[] firstSectorSync = new byte[cdromSyncBytes.Length];
                Array.Copy(firstSector, firstSectorSync, cdromSyncBytes.Length);
                if (memcmp(cdromSyncBytes, firstSectorSync))
                {
                    byte mode = firstSector[15];
                    if (mode == 1 || mode == 2)
                    {
                        infile.Position = 0;
                        RawCdRomStream rawCdRomStream = new RawCdRomStream(infile);
                        Gather(medium, rawCdRomStream);
                        return;
                    }
                }
            }
            failed += "RAW CD-ROM";

            MessageBox.Show("Konnte kein Dateisystem erkennen. Versucht wurden:" + failed);
        }