diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index 7847a71fe..ac4fd533d 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -61,8 +61,15 @@ File::File(const char *file) { d = new FilePrivate(::strdup(file)); - d->readOnly = !isWritable(file); - d->file = fopen(file, d->readOnly ? "rb" : "rb+"); + // First try with read/write mode, if that fails, fall back to read only. + // We can't use ::access() since that works in odd ways on some file systems. + + d->file = fopen(file, "rb+"); + + if(d->file) + d->readOnly = false; + else + d->file = fopen(file,"rb"); if(!d->file) debug("Could not open file " + String(file)); diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h index d736dcb90..02c87816f 100644 --- a/taglib/toolkit/tfile.h +++ b/taglib/toolkit/tfile.h @@ -198,11 +198,15 @@ namespace TagLib { /*! * Returns true if \a file can be opened for reading. If the file does not * exist, this will return false. + * + * \deprecated */ static bool isReadable(const char *file); /*! * Returns true if \a file can be opened for writing. + * + * \deprecated */ static bool isWritable(const char *name);