[*] Beyond dumb fio offset issue
This commit is contained in:
parent
a59fc20d56
commit
e29843dc7e
@ -103,10 +103,19 @@ namespace Aurora::IO::FS
|
||||
break;
|
||||
}
|
||||
case EFileOpenMode::eReadWrite:
|
||||
{
|
||||
CreateDirectories(pathex, true);
|
||||
fileHandle = CreateFileW(win32Path.c_str(), GENERIC_WRITE | GENERIC_READ, NtLockAdvisoryToShare(lock), NULL, OPEN_ALWAYS, flags, NULL);
|
||||
if (fileHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
fileHandle = CreateFileW(win32Path.c_str(), GENERIC_WRITE | GENERIC_READ, NtLockAdvisoryToShare(lock), NULL, CREATE_ALWAYS, flags, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EFileOpenMode::eWrite:
|
||||
{
|
||||
CreateDirectories(pathex, true);
|
||||
fileHandle = CreateFileW(win32Path.c_str(), (openMode == EFileOpenMode::eReadWrite) ? (GENERIC_WRITE | GENERIC_READ) : GENERIC_WRITE, NtLockAdvisoryToShare(lock), NULL, CREATE_ALWAYS, flags, NULL);
|
||||
fileHandle = CreateFileW(win32Path.c_str(), GENERIC_WRITE, NtLockAdvisoryToShare(lock), NULL, CREATE_ALWAYS, flags, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ namespace Aurora::IO::FS
|
||||
|
||||
void WinFileStream::Init(HANDLE handle, const AuString &path)
|
||||
{
|
||||
handle_ = handle;
|
||||
path_ = path;
|
||||
this->handle_ = handle;
|
||||
this->path_ = path;
|
||||
}
|
||||
|
||||
AuUInt64 WinFileStream::GetOffset()
|
||||
@ -32,13 +32,13 @@ namespace Aurora::IO::FS
|
||||
LARGE_INTEGER distance {};
|
||||
LARGE_INTEGER pos {};
|
||||
|
||||
if (handle_ == INVALID_HANDLE_VALUE)
|
||||
if (this->handle_ == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
SysPushErrorUninitialized();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SetFilePointerEx(handle_, distance, &pos, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
|
||||
if (SetFilePointerEx(this->handle_, distance, &pos, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
AuLogWarn("SetFilePointerEx IO Error: 0x{:x}, {}", GetLastError(), path_);
|
||||
SysPushErrorIO();
|
||||
@ -53,7 +53,7 @@ namespace Aurora::IO::FS
|
||||
LARGE_INTEGER distance {};
|
||||
LARGE_INTEGER pos {};
|
||||
|
||||
if (handle_ == INVALID_HANDLE_VALUE)
|
||||
if (this->handle_ == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
SysPushErrorUninitialized();
|
||||
return false;
|
||||
@ -61,7 +61,7 @@ namespace Aurora::IO::FS
|
||||
|
||||
distance.QuadPart = offset;
|
||||
|
||||
if (SetFilePointerEx(handle_, distance, &pos, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
|
||||
if (SetFilePointerEx(this->handle_, distance, &pos, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
AuLogWarn("SetFilePointerEx IO Error: 0x{:x}, {}", GetLastError(), path_);
|
||||
SysPushErrorIO();
|
||||
@ -81,7 +81,7 @@ namespace Aurora::IO::FS
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!GetFileSizeEx(handle_, &length))
|
||||
if (!GetFileSizeEx(this->handle_, &length))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return 0;
|
||||
@ -238,10 +238,19 @@ namespace Aurora::IO::FS
|
||||
break;
|
||||
}
|
||||
case EFileOpenMode::eReadWrite:
|
||||
{
|
||||
CreateDirectories(pathex, true);
|
||||
fileHandle = CreateFileW(win32Path.c_str(), GENERIC_WRITE | GENERIC_READ, NtLockAdvisoryToShare(lock), NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (fileHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
fileHandle = CreateFileW(win32Path.c_str(), GENERIC_WRITE, NtLockAdvisoryToShare(lock), NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EFileOpenMode::eWrite:
|
||||
{
|
||||
CreateDirectories(pathex, true);
|
||||
fileHandle = CreateFileW(win32Path.c_str(), (openMode == EFileOpenMode::eReadWrite) ? (GENERIC_WRITE | GENERIC_READ) : GENERIC_WRITE, NtLockAdvisoryToShare(lock), NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
fileHandle = CreateFileW(win32Path.c_str(), GENERIC_WRITE, NtLockAdvisoryToShare(lock), NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user