Implemented GetFileSize and and proper winrt file open (nw)

This commit is contained in:
Miodrag Milanovic 2016-11-12 15:42:47 +01:00
parent b73126e85a
commit f999805738
2 changed files with 9 additions and 5 deletions

View File

@ -232,9 +232,7 @@ osd_file::error osd_file::open(std::string const &orig_path, uint32_t openflags,
// get the file size
FILE_STANDARD_INFO file_info;
GetFileInformationByHandleEx(h, FileStandardInfo, &file_info, sizeof(file_info));
auto lower = file_info.EndOfFile.QuadPart;
if (INVALID_FILE_SIZE == lower)
if (INVALID_FILE_SIZE == file_info.EndOfFile.LowPart)
{
DWORD const err = GetLastError();
if (NO_ERROR != err)
@ -247,7 +245,7 @@ osd_file::error osd_file::open(std::string const &orig_path, uint32_t openflags,
try
{
file = std::make_unique<win_osd_file>(h);
filesize = lower;
filesize = file_info.EndOfFile.QuadPart;
return error::NONE;
}
catch (...)

View File

@ -93,6 +93,12 @@ extern "C" {
_Out_opt_ LPDWORD lpFileSizeHigh
)
{
return 0;
FILE_STANDARD_INFO file_info;
GetFileInformationByHandleEx(hFile, FileStandardInfo, &file_info, sizeof(file_info));
if(lpFileSizeHigh!=nullptr)
{
*lpFileSizeHigh = file_info.EndOfFile.HighPart;
}
return file_info.EndOfFile.LowPart;
}
}