libctru  v2.3.1
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()
{
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())
{
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
}
return 0;
}
Central 3DS header.
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)
Initialise the console.
void gfxInitDefault(void)
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
@ GFX_TOP
Top screen.
Definition: gfx.h:26
void gfxExit(void)
Deinitializes and frees the LCD framebuffers.
#define gspWaitForVBlank()
Waits for VBlank.
Definition: gspgpu.h:151
@ KEY_START
Start.
Definition: hid.h:15
u32 hidKeysDown(void)
Returns a bitmask of newly pressed buttons, this frame.
void hidScanInput(void)
Scans HID for input data.
static Result romfsInit(void)
Wrapper for romfsMountSelf with the default "romfs" device name.
Definition: romfs.h:84
static Result romfsExit(void)
Wrapper for romfsUnmount with the default "romfs" device name.
Definition: romfs.h:90
s32 Result
Function result.
Definition: types.h:42
uint32_t u32
32-bit unsigned integer
Definition: types.h:23