@@ -194,6 +194,8 @@ Result CIAFile::WriteTitleMetadata() {
194
194
// TODO: Correct error code.
195
195
return FileSys::ResultFileNotFound;
196
196
}
197
+ if (content_count > 255 )
198
+ file.Close ();
197
199
}
198
200
199
201
if (container.GetTitleMetadata ().HasEncryptedContent ()) {
@@ -224,6 +226,8 @@ ResultVal<std::size_t> CIAFile::WriteContentData(u64 offset, std::size_t length,
224
226
// has been written since we might get a written buffer which contains multiple .app
225
227
// contents or only part of a larger .app's contents.
226
228
const u64 offset_max = offset + length;
229
+ if (content_written.size () > 255 )
230
+ content_files.clear ();
227
231
for (std::size_t i = 0 ; i < content_written.size (); i++) {
228
232
if (content_written[i] < container.GetContentSize (i)) {
229
233
// The size, minimum unwritten offset, and maximum unwritten offset of this content
@@ -243,7 +247,9 @@ ResultVal<std::size_t> CIAFile::WriteContentData(u64 offset, std::size_t length,
243
247
// Since the incoming TMD has already been written, we can use GetTitleContentPath
244
248
// to get the content paths to write to.
245
249
FileSys::TitleMetadata tmd = container.GetTitleMetadata ();
246
- auto & file = content_files[i];
250
+ auto path = GetTitleContentPath (media_type, tmd.GetTitleID (), i, is_update);
251
+ auto & file = content_written.size () > 255 ? content_files.emplace_back (path, " ab+" )
252
+ : content_files[i];
247
253
248
254
std::vector<u8> temp (buffer + (range_min - offset),
249
255
buffer + (range_min - offset) + available_to_write);
@@ -259,6 +265,8 @@ ResultVal<std::size_t> CIAFile::WriteContentData(u64 offset, std::size_t length,
259
265
content_written[i] += available_to_write;
260
266
LOG_DEBUG (Service_AM, " Wrote {:x} to content {}, total {:x}" , available_to_write, i,
261
267
content_written[i]);
268
+ if (content_written.size () > 255 )
269
+ file.Close ();
262
270
}
263
271
}
264
272
0 commit comments