<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi all,<br>
<br>
I think that there is a small bug in tfilestream.cpp, because
whenever I try to parse a file that is marked as readOnly (or is
writeprotected by the filesystem, e.g. network), then the
file->isValid() returns false.<br>
<br>
The problem might be located in
FileStream::FileStreamPrivate::FileStreamPrivate(FileName fileName,
bool openReadOnly) :<br>
<br>
The condition if(file) should be if(file!=INVALID_HANDLE_VALUE),
because CreateFileW returns <strong style="color: rgb(69, 69, 69);
font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial,
Helvetica, sans-serif; font-size: 14px; font-style: normal;
font-variant: normal; letter-spacing: normal; line-height: 20px;
orphans: 2; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: 2; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">INVALID_HANDLE_VALUE</strong>
if the stream could not be openend and according to WinBase.h this
is defined as ((HANDLE)(LONG_PTR)-1)...<br>
<br>
So I guess it should be something linke this:<br>
<br>
FileStream::FileStreamPrivate::FileStreamPrivate(FileName fileName,
bool openReadOnly) :<br>
file(INVALID_HANDLE_VALUE),<br>
name(fileName),<br>
readOnly(true),<br>
size(0)<br>
{<br>
// First try with read / write mode, if that fails, fall back to
read only.<br>
<br>
if(!openReadOnly)<br>
file = openFile(name, false);<br>
<br>
if(file!=INVALID_HANDLE_VALUE)<br>
readOnly = false;<br>
else<br>
file = openFile(name, true);<br>
<br>
if(file==INVALID_HANDLE_VALUE) {<br>
debug("Could not open file " + String((const char *) name));<br>
}<br>
}<br>
<br>
I'm not a C++ coder at all and I might be wrong; therefore I would
appreciate your opinion...<br>
<br>
Best regards<br>
Ulrich
</body>
</html>