mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
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:
parent
2e8c6ea0f4
commit
320b76d95a
@ -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));
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user