MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / savOpen

Method savOpen

switch/source/script/scripthost.cpp:114–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 }
113
114 int savOpen(int titleIdx, int kind) override
115 {
116 if (kind != 0 || titleIdx < 0 || titleIdx >= titleCount()) {
117 return -1; // no extdata on Switch
118 }
119 const int slot = freeSlot();
120 if (slot < 0) {
121 return -2;
122 }
123
124 Title title;
125 TitleCatalog::get().getTitle(title, g_currentUId, (size_t)titleIdx);
126
127 // Mount the save on the slot's own device name (the SaveDataSource::mount
128 // path hardcodes "save:", which belongs to the backup/restore worker).
129 FsFileSystem fileSystem;
130 Result res = 0;
131 switch (title.saveDataType()) {
132 case FsSaveDataType_Bcat:
133 res = FileSystem::mountBcatSave(&fileSystem, title.id());
134 break;
135 case FsSaveDataType_Device:
136 res = FileSystem::mountDeviceSave(&fileSystem, title.id());
137 break;
138 case FsSaveDataType_System:
139 res = FileSystem::mountSystemSave(&fileSystem, title.id(), title.saveDataSpaceId());
140 break;
141 default:
142 res = FileSystem::mountSave(&fileSystem, title.id(), title.userId());
143 break;
144 }
145 if (R_FAILED(res)) {
146 return (int)res;
147 }
148
149 snprintf(mSlots[slot].dev, sizeof(mSlots[slot].dev), "scr%d", slot);
150 if (fsdevMountDevice(mSlots[slot].dev, fileSystem) == -1) {
151 fsFsClose(&fileSystem);
152 return -1;
153 }
154
155 mSlots[slot].live = true;
156 return slot;
157 }
158
159 // Shared extdata is a 3DS concept (e.g. the Home Menu Play Coin
160 // archive); the Switch has no console-wide extdata, so this is always

Callers

nothing calls this directly

Calls 6

getFunction · 0.85
saveDataTypeMethod · 0.80
saveDataSpaceIdMethod · 0.80
userIdMethod · 0.80
getTitleMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected