Transfert enumeration from file to enums

Former-commit-id: 0d9e191373affda50d0eb6c2376c7a23720e591b
This commit is contained in:
Gawaboumga
2015-08-21 11:22:35 +02:00
parent 8cda289b82
commit 3dbcb25384
16 changed files with 85 additions and 77 deletions

View File

@@ -51,33 +51,33 @@ bool NzFileImpl::Open(const NzString& filePath, unsigned int mode)
int flags;
mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
if (mode & NzFile::ReadOnly)
if (mode & nzOpenMode_ReadOnly)
flags = O_RDONLY;
else if (mode & NzFile::ReadWrite)
else if (mode & nzOpenMode_ReadWrite)
{
flags = O_CREAT | O_RDWR;
if (mode & NzFile::Append)
if (mode & nzOpenMode_Append)
flags |= O_APPEND;
if (mode & NzFile::Truncate)
if (mode & nzOpenMode_Truncate)
flags |= O_TRUNC;
}
else if (mode & NzFile::WriteOnly)
else if (mode & nzOpenMode_WriteOnly)
{
flags = O_CREAT | O_WRONLY;
if (mode & NzFile::Append)
if (mode & nzOpenMode_Append)
flags |= O_APPEND;
if (mode & NzFile::Truncate)
if (mode & nzOpenMode_Truncate)
flags |= O_TRUNC;
}
else
return false;
///TODO: lock
// if ((mode & NzFile::Lock) == 0)
// if ((mode & nzOpenMode_Lock) == 0)
// shareMode |= FILE_SHARE_WRITE;
m_fileDescriptor = open64(filePath.GetConstBuffer(), flags, permissions);
@@ -98,20 +98,20 @@ std::size_t NzFileImpl::Read(void* buffer, std::size_t size)
return 0;
}
bool NzFileImpl::SetCursorPos(NzFile::CursorPosition pos, nzInt64 offset)
bool NzFileImpl::SetCursorPos(nzCursorPosition pos, nzInt64 offset)
{
int moveMethod;
switch (pos)
{
case NzFile::AtBegin:
case nzCursorPosition_AtBegin:
moveMethod = SEEK_SET;
break;
case NzFile::AtCurrent:
case nzCursorPosition_AtCurrent:
moveMethod = SEEK_CUR;
break;
case NzFile::AtEnd:
case nzCursorPosition_AtEnd:
moveMethod = SEEK_END;
break;

View File

@@ -35,7 +35,7 @@ class NzFileImpl : NzNonCopyable
nzUInt64 GetCursorPos() const;
bool Open(const NzString& filePath, unsigned int mode);
std::size_t Read(void* buffer, std::size_t size);
bool SetCursorPos(NzFile::CursorPosition pos, nzInt64 offset);
bool SetCursorPos(nzCursorPosition pos, nzInt64 offset);
std::size_t Write(const void* buffer, std::size_t size);
static bool Copy(const NzString& sourcePath, const NzString& targetPath);