Consider flags for CreateFileA(), Windows
- Implement dwDesiredAccess and dwCreationDisposition based on
the flags O_RDONLY, O_RDWR, O_CREAT | O_TRUNC and O_EXCL
- This updates how a file handle is created using CreateFileA()
under Windows, considering the flags. Use e.g.
DesiredAccess = GENERIC_READ | GENERIC_WRITE
dwCreationDisposition = OPEN_EXISTING
- CreateFileA(): Check for INVALID_HANDLE_VALUE and add output of error
messages using GetLastError() and FormatMessage()
- The error message provides correct output now, which error occurs.
e.g.: rrdtool.exe info not_existing_file.rrd
ERROR: opening 'not_existing_file.rrd':
The system cannot find the file specified.
Previously, the following error occurred later in the code:
ERROR: short read while reading header rrd->stat_head
And also empty files were left behind:
e.g. rrdtool.exe resize not_existing_file.rrd 0 GROW 5200
- Use <CharacterSet>MultiByte</CharacterSet> consistently
in .vcxproj files. There were 4 inadvertent occurrences of
<CharacterSet>Unicode</CharacterSet> in librrd-4.vcxproj.
Using MultiByte or NotSet instead of Unicode is required for
printing "(LPTSTR) lpMsgBuf" from FormatMessage() using %s, to avoid
unnecessary wide characters.
- This commit is an update to
a9671a7