Exemple #1
0
        internal static void BuildRomFS(string infile, string outfile)
        {
            OutFile = outfile;
            RootDir = infile;
            if (File.Exists(TempFile))
            {
                File.Delete(TempFile);
            }

            FileNameTable fnt = new FileNameTable(RootDir);

            RomfsFile[]           romFiles = new RomfsFile[fnt.NumFiles];
            LayoutManager.Input[] In       = new LayoutManager.Input[fnt.NumFiles];
            for (int i = 0; i < fnt.NumFiles; i++)
            {
                In[i] = new LayoutManager.Input {
                    FilePath = fnt.NameEntryTable[i].FullName, AlignmentSize = 0x10
                };
            }
            LayoutManager.Output[] Out = LayoutManager.Create(In);
            for (int i = 0; i < Out.Length; i++)
            {
                romFiles[i] = new RomfsFile {
                    Offset   = Out[i].Offset,
                    PathName = Out[i].FilePath.Replace(Path.GetFullPath(RootDir), "").Replace("\\", "/"),
                    FullName = Out[i].FilePath,
                    Size     = Out[i].Size
                };
            }
            using (MemoryStream memoryStream = new MemoryStream())
            {
                RomFS.BuildRomFSHeader(memoryStream, romFiles, RootDir);
                RomFS.MakeRomFSData(romFiles, memoryStream);
            }
        }
Exemple #2
0
        internal static void BuildRomFS(string outfile, string infile, RichTextBox TB_Progress = null, ProgressBar PB_Show = null)
        {
            OutFile = outfile;
            ROOT_DIR = infile;
            if (File.Exists(TempFile)) File.Delete(TempFile);

            FileNameTable FNT = new FileNameTable(ROOT_DIR);
            RomfsFile[] RomFiles = new RomfsFile[FNT.NumFiles];
            LayoutManager.Input[] In = new LayoutManager.Input[FNT.NumFiles];
            updateTB(TB_Progress, "Creating Layout...");
            for (int i = 0; i < FNT.NumFiles; i++)
            {
                In[i] = new LayoutManager.Input { FilePath = FNT.NameEntryTable[i].FullName, AlignmentSize = 0x10 };
            }
            LayoutManager.Output[] Out = LayoutManager.Create(In);
            for (int i = 0; i < Out.Length; i++)
            {
                RomFiles[i] = new RomfsFile
                {
                    Offset = Out[i].Offset,
                    PathName = Out[i].FilePath.Replace(Path.GetFullPath(ROOT_DIR), "").Replace("\\", "/"),
                    FullName = Out[i].FilePath,
                    Size = Out[i].Size
                };
            }
            using (MemoryStream memoryStream = new MemoryStream())
            {
                updateTB(TB_Progress, "Creating RomFS MetaData...");
                BuildRomFSHeader(memoryStream, RomFiles, ROOT_DIR);
                MakeRomFSData(RomFiles, memoryStream, TB_Progress, PB_Show);
            }
        }
Exemple #3
0
        internal static void BuildRomFS(string outfile, string infile, RichTextBox TB_Progress = null, ProgressBar PB_Show = null)
        {
            OutFile = outfile;
            ROOT_DIR = infile;
            if (File.Exists(TempFile)) File.Delete(TempFile);

            FileNameTable FNT = new FileNameTable(ROOT_DIR);
            RomfsFile[] RomFiles = new RomfsFile[FNT.NumFiles];
            LayoutManager.Input[] In = new LayoutManager.Input[FNT.NumFiles];
            updateTB(TB_Progress, "Creating Layout...");
            for (int i = 0; i < FNT.NumFiles; i++)
            {
                In[i] = new LayoutManager.Input { FilePath = FNT.NameEntryTable[i].FullName, AlignmentSize = 0x10 };
            }
            LayoutManager.Output[] Out = LayoutManager.Create(In);
            for (int i = 0; i < Out.Length; i++)
            {
                RomFiles[i] = new RomfsFile
                {
                    Offset = Out[i].Offset,
                    PathName = Out[i].FilePath.Replace(Path.GetFullPath(ROOT_DIR), "").Replace("\\", "/"),
                    FullName = Out[i].FilePath,
                    Size = Out[i].Size
                };
            }
            using (MemoryStream memoryStream = new MemoryStream())
            {
                updateTB(TB_Progress, "Creating RomFS MetaData...");
                BuildRomFSHeader(memoryStream, RomFiles, ROOT_DIR);
                MakeRomFSData(RomFiles, memoryStream, TB_Progress, PB_Show);
            }
        }
Exemple #4
0
        internal static Stream BuildRomFS(string outfile, string infile, string _patchDir)
        {
            OutFile  = outfile;
            ROOT_DIR = infile;
            if (outfile != null)
            {
                if (File.Exists(TempFile))
                {
                    File.Delete(TempFile);
                }
            }

            FileNameTable FNT = new FileNameTable(ROOT_DIR);

            RomfsFile[]           RomFiles = new RomfsFile[FNT.NumFiles];
            LayoutManager.Input[] In       = new LayoutManager.Input[FNT.NumFiles];
            updateTB("Creating Layout...");
            for (int i = 0; i < FNT.NumFiles; i++)
            {
                In[i] = new LayoutManager.Input {
                    FilePath = FNT.NameEntryTable[i].FullName, AlignmentSize = 0x10
                };
            }

            String[] _relativePaths = new String[FNT.NumFiles];
            for (int i = 0; i < _relativePaths.Length; ++i)
            {
                _relativePaths[i] = makePathRelative(In[i].FilePath, ROOT_DIR);
            }

            if (_patchDir != null)
            {
                string[] _altFiles = Directory.GetFiles(_patchDir, "*", SearchOption.AllDirectories);
                for (int i = 0; i < _altFiles.Length; ++i)
                {
                    string _stippedStart = makePathRelative(_altFiles[i], _patchDir);
                    int    j;
                    for (j = 0; j < In.Length; ++j)
                    {
                        if (_relativePaths[j] == _stippedStart)
                        {
                            In[j].FilePath = _altFiles[i];
                            break;
                        }
                    }
                }
            }

            LayoutManager.Output[] Out = LayoutManager.Create(In);
            for (int i = 0; i < Out.Length; i++)
            {
                RomFiles[i] = new RomfsFile
                {
                    Offset       = Out[i].Offset,
                    PathName     = _relativePaths[i],
                    FullName     = FNT.NameEntryTable[i].FullName,
                    realFilePath = In[i].FilePath,
                    Size         = Out[i].Size
                };
            }

            Stream _possibleRetStream;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                updateTB("Creating RomFS MetaData...");
                BuildRomFSHeader(memoryStream, RomFiles, ROOT_DIR);
                _possibleRetStream = MakeRomFSData(RomFiles, memoryStream, outfile != null ? outfile : null);
            }
            if (outfile != null)
            {
                return(null);
            }
            else
            {
                return(_possibleRetStream);
            }
        }