Skip to content

Commit

Permalink
Use accountGetPreselectedUser for getting the userID in the account a…
Browse files Browse the repository at this point in the history
…nd fs/save examples.
  • Loading branch information
yellows8 committed Jul 29, 2019
1 parent f89c157 commit 927256c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
11 changes: 3 additions & 8 deletions account/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

#include <switch.h>

//This example shows how to get info for the current user account. See libnx acc.h.
//This example shows how to get info for the preselected user account. See libnx acc.h.

int main(int argc, char **argv)
{
Result rc=0;

u128 userID=0;
bool account_selected=0;
AccountProfile profile;
AccountUserData userdata;
AccountProfileBase profilebase;
Expand All @@ -28,14 +27,10 @@ int main(int argc, char **argv)
}

if (R_SUCCEEDED(rc)) {
rc = accountGetActiveUser(&userID, &account_selected);
rc = accountGetPreselectedUser(&userID);

if (R_FAILED(rc)) {
printf("accountGetActiveUser() failed: 0x%x\n", rc);
}
else if(!account_selected) {
printf("No user is currently selected.\n");
rc = -1;
printf("accountGetPreselectedUser() failed: 0x%x\n", rc);
}

if (R_SUCCEEDED(rc)) {
Expand Down
11 changes: 3 additions & 8 deletions fs/save/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ int main(int argc, char **argv)

FsFileSystem tmpfs;
u128 userID=0;
bool account_selected=0;
u64 titleID=0x01007ef00011e000;//titleID of the save to mount, in this case BOTW.

consoleInit(NULL);

//Get the userID for save mounting. To mount common savedata, use FS_SAVEDATA_USERID_COMMONSAVE.

//Try to find savedata to use with get_save() first, otherwise fallback to the above hard-coded TID + the userID from accountGetActiveUser(). Note that you can use either method.
//Try to find savedata to use with get_save() first, otherwise fallback to the above hard-coded TID + the userID from accountGetPreselectedUser(). Note that you can use either method.
//See the account example for getting account info for an userID.
//See also the app_controldata example for getting info for a titleID.
if (R_FAILED(get_save(&titleID, &userID))) {
Expand All @@ -65,15 +64,11 @@ int main(int argc, char **argv)
}

if (R_SUCCEEDED(rc)) {
rc = accountGetActiveUser(&userID, &account_selected);
rc = accountGetPreselectedUser(&userID);
accountExit();

if (R_FAILED(rc)) {
printf("accountGetActiveUser() failed: 0x%x\n", rc);
}
else if(!account_selected) {
printf("No user is currently selected.\n");
rc = -1;
printf("accountGetPreselectedUser() failed: 0x%x\n", rc);
}
}
}
Expand Down

0 comments on commit 927256c

Please sign in to comment.