diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 35300de6..6077d705 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -52,6 +52,8 @@ namespace { // Using native file handles instead of file descriptors for reducing the resource consumption. + const HANDLE InvalidFile = INVALID_HANDLE_VALUE; + HANDLE openFile(const FileName &path, bool readOnly) { DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE); @@ -88,6 +90,8 @@ namespace { // For non-Windows + FILE *const InvalidFile = 0; + struct FileNameHandle : public std::string { FileNameHandle(FileName name) : std::string(name) {} @@ -125,7 +129,7 @@ public: }; FileStream::FileStreamPrivate::FileStreamPrivate(FileName fileName, bool openReadOnly) : - file(0), + file(InvalidFile), name(fileName), readOnly(true), size(0) @@ -135,12 +139,12 @@ FileStream::FileStreamPrivate::FileStreamPrivate(FileName fileName, bool openRea if(!openReadOnly) file = openFile(name, false); - if(file) + if(file != InvalidFile) readOnly = false; else file = openFile(name, true); - if(!file) { + if(file == InvalidFile) { debug("Could not open file " + String((const char *) name)); } }