romfs/source/main.c
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <3ds.h>
void printfile(const char* path)
{
FILE* f = fopen(path, "r");
if (f)
{
char mystring[100];
while (fgets(mystring, sizeof(mystring), f))
{
int a = strlen(mystring);
if (mystring[a-1] == '\n')
{
mystring[a-1] = 0;
if (mystring[a-2] == '\r')
mystring[a-2] = 0;
}
puts(mystring);
}
printf(">>EOF<<\n");
fclose(f);
}
}
int main()
{
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
Result rc = romfsInit();
if (rc)
printf("romfsInit: %08lX\n", rc);
else
{
printf("romfs Init Successful!\n");
printfile("romfs:/folder/file.txt");
// Test reading a file with non-ASCII characters in the name
printfile("romfs:/フォルダ/ファイル.txt");
}
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
}
romfsExit();
gfxExit();
return 0;
}
3ds.h
Central 3DS header.
aptMainLoop
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
consoleInit
PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)
Initialise the console.
gfxInitDefault
void gfxInitDefault(void)
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
GFX_TOP
@ GFX_TOP
Top screen.
Definition: gfx.h:26
gfxExit
void gfxExit(void)
Deinitializes and frees the LCD framebuffers.
gspWaitForVBlank
#define gspWaitForVBlank()
Waits for VBlank.
Definition: gspgpu.h:151
KEY_START
@ KEY_START
Start.
Definition: hid.h:15
hidKeysDown
u32 hidKeysDown(void)
Returns a bitmask of newly pressed buttons, this frame.
hidScanInput
void hidScanInput(void)
Scans HID for input data.
romfsInit
static Result romfsInit(void)
Wrapper for romfsMountSelf with the default "romfs" device name.
Definition: romfs.h:84
romfsExit
static Result romfsExit(void)
Wrapper for romfsUnmount with the default "romfs" device name.
Definition: romfs.h:90
Result
s32 Result
Function result.
Definition: types.h:42
u32
uint32_t u32
32-bit unsigned integer
Definition: types.h:23