[prev in list] [next in list] [prev in thread] [next in thread]
List: taglib-devel
Subject: Files that are ReadOnly cannot be parsed with TagLib
From: Ulrich Decker <info () udse ! de>
Date: 2012-11-19 19:55:31
Message-ID: 50AA8EB3.3060805 () udse ! de
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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
[Attachment #5 (text/html)]
<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>
_______________________________________________
taglib-devel mailing list
taglib-devel@kde.org
https://mail.kde.org/mailman/listinfo/taglib-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic