Files that are ReadOnly cannot be parsed with TagLib
Ulrich Decker
info at udse.de
Mon Nov 19 19:55:31 UTC 2012
Hi all,
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.
The problem might be located in
FileStream::FileStreamPrivate::FileStreamPrivate(FileName fileName, bool
openReadOnly) :
The condition if(file) should be if(file!=INVALID_HANDLE_VALUE), because
CreateFileW returns *INVALID_HANDLE_VALUE* if the stream could not be
openend and according to WinBase.h this is defined as
((HANDLE)(LONG_PTR)-1)...
So I guess it should be something linke this:
FileStream::FileStreamPrivate::FileStreamPrivate(FileName fileName, bool
openReadOnly) :
file(INVALID_HANDLE_VALUE),
name(fileName),
readOnly(true),
size(0)
{
// First try with read / write mode, if that fails, fall back to read
only.
if(!openReadOnly)
file = openFile(name, false);
if(file!=INVALID_HANDLE_VALUE)
readOnly = false;
else
file = openFile(name, true);
if(file==INVALID_HANDLE_VALUE) {
debug("Could not open file " + String((const char *) name));
}
}
I'm not a C++ coder at all and I might be wrong; therefore I would
appreciate your opinion...
Best regards
Ulrich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20121119/67ae2aef/attachment.html>
More information about the taglib-devel
mailing list