Files that are ReadOnly cannot be parsed with TagLib
Lukáš Lalinský
lalinsky at gmail.com
Tue Nov 20 13:18:20 UTC 2012
Thank you. You are right, the code should be checking for
INVALID_HANDLE_VALUE. I've fixed it in
https://github.com/taglib/taglib/commit/ade8dc1a218e43c3909c4eede58f4e28e09da73a
Lukas
On Mon, Nov 19, 2012 at 8:55 PM, Ulrich Decker <info at udse.de> wrote:
> 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
>
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
More information about the taglib-devel
mailing list