mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 20:22:30 +01:00
Improve sys_fs_ftruncate
Handle stream API lock (EBUSY) Handle append mode
This commit is contained in:
parent
b415b0e737
commit
83e139cd1a
@ -1129,7 +1129,21 @@ error_code sys_fs_ftruncate(u32 fd, u64 size)
|
||||
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user