mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-21 14:16:13 +00:00
Always cache placeholder file. Switch to ftell for preventing appending
This commit is contained in:
parent
dac951f72b
commit
cf06cb7628
1 changed files with 11 additions and 7 deletions
|
@ -166,10 +166,14 @@ namespace sts::ncm {
|
||||||
}
|
}
|
||||||
} R_END_TRY_CATCH;
|
} R_END_TRY_CATCH;
|
||||||
|
|
||||||
auto file_guard = SCOPE_GUARD { fclose(f); };
|
ON_SCOPE_EXIT {
|
||||||
|
this->placeholder_accessor.StoreToCache(f, placeholder_id);
|
||||||
|
};
|
||||||
|
|
||||||
u64 size = 0;
|
if (fseek(f, 0, SEEK_END) != 0) {
|
||||||
R_TRY(GetSizeFromPlaceHolderId(&size, placeholder_id));
|
return fsdevGetLastResult();
|
||||||
|
}
|
||||||
|
u64 size = ftell(f);
|
||||||
|
|
||||||
/* We can't disable append with stdio, so check this manually. */
|
/* We can't disable append with stdio, so check this manually. */
|
||||||
if (offset + data.num_elements > size) {
|
if (offset + data.num_elements > size) {
|
||||||
|
@ -188,8 +192,6 @@ namespace sts::ncm {
|
||||||
fflush(f);
|
fflush(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->placeholder_accessor.StoreToCache(f, placeholder_id);
|
|
||||||
file_guard.Cancel();
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
R_DEBUG_END
|
R_DEBUG_END
|
||||||
}
|
}
|
||||||
|
@ -645,8 +647,10 @@ namespace sts::ncm {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
};
|
};
|
||||||
|
|
||||||
u64 size = 0;
|
if (fseek(f, 0, SEEK_END) != 0) {
|
||||||
R_TRY(GetSizeFromContentId(&size, content_id));
|
return fsdevGetLastResult();
|
||||||
|
}
|
||||||
|
u64 size = ftell(f);
|
||||||
|
|
||||||
/* We can't disable append with stdio, so check this manually. */
|
/* We can't disable append with stdio, so check this manually. */
|
||||||
if (offset + data.num_elements > size) {
|
if (offset + data.num_elements > size) {
|
||||||
|
|
Loading…
Reference in a new issue