mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-04 14:08:30 +00:00
o_append implemented
This commit is contained in:
parent
2f4d6fc2a1
commit
ed6fb7cc43
7 changed files with 37 additions and 43 deletions
|
|
@ -404,11 +404,14 @@ bool rfile_t::open(const std::string& filename, u32 mode)
|
|||
|
||||
#ifdef _WIN32
|
||||
DWORD access = 0;
|
||||
switch (mode & (o_read | o_write))
|
||||
switch (mode & (o_read | o_write | o_append))
|
||||
{
|
||||
case o_read: access |= GENERIC_READ; break;
|
||||
case o_read | o_append: access |= GENERIC_READ; break;
|
||||
case o_write: access |= GENERIC_WRITE; break;
|
||||
case o_write | o_append: access |= FILE_APPEND_DATA; break;
|
||||
case o_read | o_write: access |= GENERIC_READ | GENERIC_WRITE; break;
|
||||
case o_read | o_write | o_append: access |= GENERIC_READ | FILE_APPEND_DATA; break;
|
||||
default:
|
||||
{
|
||||
LOG_ERROR(GENERAL, "rfile_t::open('%s') failed: neither o_read nor o_write specified (0x%x)", filename, mode);
|
||||
|
|
@ -427,7 +430,7 @@ bool rfile_t::open(const std::string& filename, u32 mode)
|
|||
case o_create | o_excl | o_trunc: disp = CREATE_NEW; break;
|
||||
}
|
||||
|
||||
if (!disp || (mode & ~(o_read | o_write | o_create | o_trunc | o_excl)))
|
||||
if (!disp || (mode & ~(o_read | o_write | o_append | o_create | o_trunc | o_excl)))
|
||||
{
|
||||
LOG_ERROR(GENERAL, "rfile_t::open('%s') failed: unknown mode specified (0x%x)", filename, mode);
|
||||
return false;
|
||||
|
|
@ -449,11 +452,12 @@ bool rfile_t::open(const std::string& filename, u32 mode)
|
|||
}
|
||||
}
|
||||
|
||||
if (mode & o_append) flags |= O_APPEND;
|
||||
if (mode & o_create) flags |= O_CREAT;
|
||||
if (mode & o_trunc) flags |= O_TRUNC;
|
||||
if (mode & o_excl) flags |= O_EXCL;
|
||||
|
||||
if (((mode & o_excl) && !(mode & o_create)) || (mode & ~(o_read | o_write | o_create | o_trunc | o_excl)))
|
||||
if (((mode & o_excl) && !(mode & o_create)) || (mode & ~(o_read | o_write | o_append | o_create | o_trunc | o_excl)))
|
||||
{
|
||||
LOG_ERROR(GENERAL, "rfile_t::open('%s') failed: unknown mode specified (0x%x)", filename, mode);
|
||||
return false;
|
||||
|
|
@ -538,15 +542,17 @@ bool rfile_t::close()
|
|||
#ifdef _WIN32
|
||||
if (CloseHandle(fd))
|
||||
{
|
||||
fd = INVALID_HANDLE_VALUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
fd = INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
if (!::close(fd))
|
||||
{
|
||||
fd = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
fd = -1;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ enum rfile_open_mode : u32
|
|||
{
|
||||
o_read = 1 << 0,
|
||||
o_write = 1 << 1,
|
||||
o_create = 1 << 2,
|
||||
o_trunc = 1 << 3,
|
||||
o_excl = 1 << 4,
|
||||
o_append = 1 << 2,
|
||||
o_create = 1 << 3,
|
||||
o_trunc = 1 << 4,
|
||||
o_excl = 1 << 5,
|
||||
};
|
||||
|
||||
struct rfile_t final
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue