So I'm trying to write a simple text editor for the 3ds using ctrulib, sf2dlib, etc... and I've hit upon a snag.
What I'm trying to do is list all of the files and folders in a directory on the SD card, and I've seen many examples of where people do this on github, but they all seem to require me to use an older version of ctrulib as in the version I have (latest release I believe) the FS_Archive type is a simple u64 rather than a struct of {FS_ArchiveID someID ,FS_Path somePath} or something of the sort.
Not sure if this is just me not understanding properly how C++/ctrulib works or if there is something I'm missing or what.
Here is the code I have currently:
Now, the strange thing is, when I run my program in Citra, I get an output of all the files and folders in the /sdmc/ directory, whereas running on my 3ds I get no output, the program doesn't crash, but I don't get any output to the console past "Tried to read Directory".
¯\_(ツ)_/¯
Any help is appreciated and thanks for taking the time to stop by
What I'm trying to do is list all of the files and folders in a directory on the SD card, and I've seen many examples of where people do this on github, but they all seem to require me to use an older version of ctrulib as in the version I have (latest release I believe) the FS_Archive type is a simple u64 rather than a struct of {FS_ArchiveID someID ,FS_Path somePath} or something of the sort.
Not sure if this is just me not understanding properly how C++/ctrulib works or if there is something I'm missing or what.
Here is the code I have currently:
Code:
void tryReadDir(){
//Mostly copied from lpp-3ds, and edited a lil
Handle dirHandle;
FS_DirectoryEntry entry;
//Make a path object from the path string
const char *path = "/";
FS_Path dirPath = fsMakePath(PATH_ASCII, path);
//Create an archive object
FS_Archive sdmcArchive;
//Open the SD card into the archive object
FSUSER_OpenArchive( &sdmcArchive, ARCHIVE_SDMC, dirPath);
//Get a directory from the SD card archive ('/' in this case)
FSUSER_OpenDirectory(&dirHandle, sdmcArchive, dirPath);
//Init some vars for storing directory listing data
u32 entriesRead;
static char name[1024];
//Debug to show the function has gone this far
sConsole.appendLine("Tried to read Directory");
for (;;){
//Reset entries var
entriesRead=0;
//Read the next item in the directory
FSDIR_Read(dirHandle, &entriesRead, 1, (FS_DirectoryEntry*)&entry);
//If there is a next item
if (entriesRead){
//also from lpp-3ds, converts a utf-8 to a string
utf2ascii(&name[0], entry.name);
//Debug, prints file/folder name to console
sConsole.appendLine(std::string(name));
}else break;
}
//Close handles and archives.
FSDIR_Close(dirHandle);
svcCloseHandle(dirHandle);
FSUSER_CloseArchive(sdmcArchive);
}
Now, the strange thing is, when I run my program in Citra, I get an output of all the files and folders in the /sdmc/ directory, whereas running on my 3ds I get no output, the program doesn't crash, but I don't get any output to the console past "Tried to read Directory".
¯\_(ツ)_/¯
Any help is appreciated and thanks for taking the time to stop by