libnx fsFsCreateDirectory cannot create subdirectory?

Post Reply
Posts: 1
Joined: Thu Jan 31, 2019 4:08 pm

libnx fsFsCreateDirectory cannot create subdirectory?

Post by Icarus » Wed May 11, 2022 10:58 am

So I switched from stdio.h to libnx's file system and have created the following code:

Code: Select all

//only including this part of the code for clarity
TimeCalendarTime dumpdreamtime = util::getDreamTime();
char dreamtime[128];
const char* date_format = "%02d-%02d-%04d_at_%02d-%02d";
sprintf(dreamtime, date_format,, dumpdreamtime.month, dumpdreamtime.year, dumpdreamtime.hour, dumpdreamtime.minute);
std::string strislandname = util::getIslandNameASCII();
std::string g_pathOut = /config/luna/dump/;
g_pathOut += strislandname.empty() ? "[DA-" + util::getDreamAddrString(g_mainAddr) + "]" : ("[DA-" + util::getDreamAddrString(g_mainAddr) + "] " + strislandname);
util::PrintToNXLink((g_pathOut + "\n").c_str());

//here is the FS stuff
Result rc = fsFsCreateDirectory(&g_fsSdmc, g_pathOut.c_str());

//boom, issue
g_pathOut += "/" + std::string(dreamtime);
util::PrintToNXLink((g_pathOut + "\n").c_str());
rc = fsFsCreateDirectory(&g_fsSdmc, g_pathOut.c_str());
this produces the following output in my console over nxlink:

Code: Select all

/config/luna/dump/[DA-8037-5177-6075] Andromeda
Result: 2000-0000 | Value: 0x0
/config/luna/dump/[DA-8037-5177-6075] Andromeda/28-03-2022_at_07-07
Result: 2001-0106 | Value: 0xD401
As you can see, the creation of the first directory happens without error. Then, when the subdirectory is to be created, it errors.
I checked the error code on SwitchBrew, which Note reads "InvalidCurrentMemory".
That seems awfully ambiguous to me, so now I have no real idea why it has an issue with the filepath specified. i tried multiple formats, but couldn't find one, where it doesn't error out.

I would appreciate further assistance, thank you for your time.

Site Admin
Posts: 1567
Joined: Tue Aug 09, 2005 3:21 am
Location: UK

Re: libnx fsFsCreateDirectory cannot create subdirectory?

Post by WinterMute » Tue May 31, 2022 12:52 pm

Generally we would advise sticking with stdio functions rather than using these functions directly unless there's a particularly good reason.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest