Core/Enum: Convert OpenMode and StreamOption to the new flags system

This commit is contained in:
Lynix
2016-11-27 13:40:47 +01:00
parent 1a5617bc55
commit a34d1e410c
17 changed files with 78 additions and 60 deletions

View File

@@ -24,7 +24,7 @@ namespace Nz
* \param openMode Reading/writing mode for the stream
*/
ByteStream::ByteStream(ByteArray* byteArray, UInt32 openMode) :
ByteStream::ByteStream(ByteArray* byteArray, OpenModeFlags openMode) :
ByteStream()
{
SetStream(byteArray, openMode);
@@ -67,7 +67,7 @@ namespace Nz
* \param openMode Reading/writing mode for the stream
*/
void ByteStream::SetStream(ByteArray* byteArray, UInt32 openMode)
void ByteStream::SetStream(ByteArray* byteArray, OpenModeFlags openMode)
{
std::unique_ptr<Stream> stream(new MemoryStream(byteArray, openMode));

View File

@@ -64,7 +64,7 @@ namespace Nz
* \param openMode Flag of the file
*/
File::File(const String& filePath, UInt32 openMode) :
File::File(const String& filePath, OpenModeFlags openMode) :
File()
{
Open(filePath, openMode);
@@ -311,7 +311,7 @@ namespace Nz
* \remark Produces a NazaraError if OS error to open a file
*/
bool File::Open(unsigned int openMode)
bool File::Open(OpenModeFlags openMode)
{
NazaraLock(m_mutex)
@@ -352,7 +352,7 @@ namespace Nz
* \remark Produces a NazaraError if OS error to open a file
*/
bool File::Open(const String& filePath, unsigned int openMode)
bool File::Open(const String& filePath, OpenModeFlags openMode)
{
NazaraLock(m_mutex)

View File

@@ -65,7 +65,7 @@ namespace Nz
* \remark Produces a NazaraAssert if byteArray is nullptr
*/
void MemoryStream::SetBuffer(ByteArray* byteArray, UInt32 openMode)
void MemoryStream::SetBuffer(ByteArray* byteArray, OpenModeFlags openMode)
{
NazaraAssert(byteArray, "Invalid ByteArray");

View File

@@ -49,7 +49,7 @@ namespace Nz
return static_cast<UInt64>(position);
}
bool FileImpl::Open(const String& filePath, UInt32 mode)
bool FileImpl::Open(const String& filePath, OpenModeFlags mode)
{
int flags;
mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;

View File

@@ -36,7 +36,7 @@ namespace Nz
bool EndOfFile() const;
void Flush();
UInt64 GetCursorPos() const;
bool Open(const String& filePath, UInt32 mode);
bool Open(const String& filePath, OpenModeFlags mode);
std::size_t Read(void* buffer, std::size_t size);
bool SetCursorPos(CursorPosition pos, Int64 offset);
bool SetSize(UInt64 size);

View File

@@ -55,12 +55,12 @@ namespace Nz
return position.QuadPart;
}
bool FileImpl::Open(const String& filePath, UInt32 mode)
bool FileImpl::Open(const String& filePath, OpenModeFlags mode)
{
DWORD access = 0;
DWORD shareMode = FILE_SHARE_READ;
DWORD openMode = 0;
if (mode & OpenMode_ReadOnly)
{
access |= GENERIC_READ;
@@ -68,7 +68,7 @@ namespace Nz
if (mode & OpenMode_MustExit || (mode & OpenMode_WriteOnly) == 0)
openMode |= OPEN_EXISTING;
}
if (mode & OpenMode_WriteOnly)
{
if (mode & OpenMode_Append)

View File

@@ -29,7 +29,7 @@ namespace Nz
bool EndOfFile() const;
void Flush();
UInt64 GetCursorPos() const;
bool Open(const String& filePath, UInt32 mode);
bool Open(const String& filePath, OpenModeFlags mode);
std::size_t Read(void* buffer, std::size_t size);
bool SetCursorPos(CursorPosition pos, Int64 offset);
bool SetSize(UInt64 size);