Rework the read-only check so that it gets along better with networked file systems.

CCMAIL:apoikos@gmail.com


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@633092 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Scott Wheeler 2007-02-13 07:21:45 +00:00
parent 2e8c6ea0f4
commit 320b76d95a
2 changed files with 13 additions and 2 deletions

View File

@ -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));

View File

@ -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);