FileName::isDirWritable(): make is safer.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25827 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-07-23 08:14:24 +00:00
parent 58303ecfa9
commit 68277d6e7f

View File

@ -308,9 +308,15 @@ bool FileName::isWritable() const
bool FileName::isDirWritable() const
{
LYXERR(Debug::FILES, "isDirWriteable: " << *this);
FileName const tmpfl = FileName::tempName(absFilename() + "lyxwritetest");
return !tmpfl.empty();
LASSERT(d->fi.isDir(), return false);
QFileInfo tmp(d->fi.absoluteDir(), "lyxwritetest");
QTemporaryFile qt_tmp(tmp.absoluteFilePath());
if (qt_tmp.open()) {
LYXERR(Debug::FILES, "Directory " << *this << " is writable");
return true;
}
LYXERR(Debug::FILES, "Directory " << *this << " is not writable");
return false;
}