[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    Re: Files that are ReadOnly cannot be parsed with TagLib
From:       Lukáš Lalinský <lalinsky () gmail ! com>
Date:       2012-11-20 13:18:20
Message-ID: CAGUtLj9_+dZO7Z5yZRH0sTc_Ks1bR=9G+NyoCLwPYLwJuvNP=A () mail ! gmail ! com
[Download RAW message or body]

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@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@kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
_______________________________________________
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