mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-02 16:59:03 +00:00
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
#include "lib.h"
|
|
#include "dir.h"
|
|
#include "ncch.h"
|
|
#include "romfs.h"
|
|
#include "romfs_binary.h"
|
|
#include "romfs_import.h"
|
|
|
|
void FreeRomFsCtx(romfs_buildctx *ctx);
|
|
|
|
// RomFs Build Functions
|
|
int SetupRomFs(ncch_settings *ncchset, romfs_buildctx *ctx)
|
|
{
|
|
ctx->output = NULL;
|
|
ctx->romfsSize = 0;
|
|
|
|
// If Not Using RomFS Return
|
|
if(!ncchset->options.UseRomFS)
|
|
return 0;
|
|
|
|
if(ncchset->componentFilePtrs.romfs)// The user has specified a pre-built RomFs Binary
|
|
return PrepareImportRomFsBinaryFromFile(ncchset,ctx);
|
|
|
|
else // Otherwise build ROMFS
|
|
return PrepareBuildRomFsBinary(ncchset,ctx);
|
|
|
|
}
|
|
|
|
int BuildRomFs(romfs_buildctx *ctx)
|
|
{
|
|
// If Not Using RomFS Return
|
|
if(!ctx->romfsSize)
|
|
return 0;
|
|
|
|
int result = 0;
|
|
|
|
if(ctx->ImportRomfsBinary) // The user has specified a pre-built RomFs Binary
|
|
result = ImportRomFsBinaryFromFile(ctx);
|
|
else // Otherwise build ROMFS
|
|
result = BuildRomFsBinary(ctx);
|
|
|
|
FreeRomFsCtx(ctx);
|
|
|
|
return result;
|
|
}
|
|
|
|
void FreeRomFsCtx(romfs_buildctx *ctx)
|
|
{
|
|
if(ctx->romfsBinary)
|
|
fclose(ctx->romfsBinary);
|
|
if(ctx->fs){
|
|
fs_FreeFiles(ctx->fs);
|
|
fs_FreeDir(ctx->fs);
|
|
free(ctx->fs);
|
|
}
|
|
} |