Skip to content

Commit 927256c

Browse files
committed
Use accountGetPreselectedUser for getting the userID in the account and fs/save examples.
1 parent f89c157 commit 927256c

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

account/source/main.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
#include <switch.h>
55

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

88
int main(int argc, char **argv)
99
{
1010
Result rc=0;
1111

1212
u128 userID=0;
13-
bool account_selected=0;
1413
AccountProfile profile;
1514
AccountUserData userdata;
1615
AccountProfileBase profilebase;
@@ -28,14 +27,10 @@ int main(int argc, char **argv)
2827
}
2928

3029
if (R_SUCCEEDED(rc)) {
31-
rc = accountGetActiveUser(&userID, &account_selected);
30+
rc = accountGetPreselectedUser(&userID);
3231

3332
if (R_FAILED(rc)) {
34-
printf("accountGetActiveUser() failed: 0x%x\n", rc);
35-
}
36-
else if(!account_selected) {
37-
printf("No user is currently selected.\n");
38-
rc = -1;
33+
printf("accountGetPreselectedUser() failed: 0x%x\n", rc);
3934
}
4035

4136
if (R_SUCCEEDED(rc)) {

fs/save/source/main.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ int main(int argc, char **argv)
4848

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

5453
consoleInit(NULL);
5554

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

58-
//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.
57+
//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.
5958
//See the account example for getting account info for an userID.
6059
//See also the app_controldata example for getting info for a titleID.
6160
if (R_FAILED(get_save(&titleID, &userID))) {
@@ -65,15 +64,11 @@ int main(int argc, char **argv)
6564
}
6665

6766
if (R_SUCCEEDED(rc)) {
68-
rc = accountGetActiveUser(&userID, &account_selected);
67+
rc = accountGetPreselectedUser(&userID);
6968
accountExit();
7069

7170
if (R_FAILED(rc)) {
72-
printf("accountGetActiveUser() failed: 0x%x\n", rc);
73-
}
74-
else if(!account_selected) {
75-
printf("No user is currently selected.\n");
76-
rc = -1;
71+
printf("accountGetPreselectedUser() failed: 0x%x\n", rc);
7772
}
7873
}
7974
}

0 commit comments

Comments
 (0)