mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-09 17:49:45 +00:00
Improve sys_fs_ftruncate
Handle stream API lock (EBUSY) Handle append mode
This commit is contained in:
parent
b415b0e737
commit
83e139cd1a
1 changed files with 15 additions and 1 deletions
|
@ -1129,7 +1129,21 @@ error_code sys_fs_ftruncate(u32 fd, u64 size)
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(file->mp->mutex);
|
std::lock_guard<std::mutex> lock(file->mp->mutex);
|
||||||
|
|
||||||
if (!file->file.trunc(size))
|
if (file->lock)
|
||||||
|
{
|
||||||
|
return CELL_EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file->flags & CELL_FS_O_APPEND)
|
||||||
|
{
|
||||||
|
const u64 fsize = file->file.size();
|
||||||
|
|
||||||
|
if (size > fsize && !file->file.write(std::vector<u8>(size - fsize)))
|
||||||
|
{
|
||||||
|
return CELL_ENOSPC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!file->file.trunc(size))
|
||||||
{
|
{
|
||||||
switch (auto error = fs::g_tls_error)
|
switch (auto error = fs::g_tls_error)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue