[EMAIL PROTECTED] wrote: > Author: poenitz > Date: Fri Oct 19 01:03:51 2007 > New Revision: 21048 > > URL: http://www.lyx.org/trac/changeset/21048 > Log: > isome more FileName shuffling http://www.lyx.org/trac/file/lyx-devel/trunk/src/support/FileName.cpp?rev=21048 > ============================================================================== > --- lyx-devel/trunk/src/support/FileName.cpp (original) +++ > lyx-devel/trunk/src/support/FileName.cpp Fri Oct 19 01:03:51 2007 @@ > -16,6 +16,9 @@ > #include "support/os.h" > #include "support/qstring_helpers.h" > > +#include "debug.h" > +#include "lyxlib.h" > + > #include <QFile> > #include <QFileInfo> > > @@ -67,14 +70,14 @@ > } > > > -string const FileName::toFilesystemEncoding() const > +string FileName::toFilesystemEncoding() const > { > QByteArray const encoded = QFile::encodeName(toqstr(name_)); > return string(encoded.begin(), encoded.end()); > } > > > -FileName const FileName::fromFilesystemEncoding(string const & name) > +FileName FileName::fromFilesystemEncoding(string const & name) > { > QByteArray const encoded(name.c_str(), name.length()); > return FileName(fromqstr(QFile::decodeName(encoded))); > @@ -104,6 +107,40 @@ > { > QFileInfo const fi(toqstr(name_)); > return fi.isReadable(); > +} > + > + > +bool FileName::isFileReadable() const > +{ > + QFileInfo const fi(toqstr(name_)); > + return fi.isFile() && fi.isReadable(); > +} > + > + > +bool FileName::isWritable() const > +{ > + QFileInfo const fi(toqstr(name_)); > + return fi.isReadable(); > +} > + > + > +bool FileName::isDirWritable() const > +{ > + LYXERR(Debug::FILES) << "isDirWriteable: " << *this << std::endl; > + > + FileName const tmpfl(tempName(*this, "lyxwritetest")); > + > + if (tmpfl.empty()) > + return false; > + > + unlink(tmpfl); > + return true; > +} > + > + > +FileName FileName::tempName(FileName const & dir, std::string const & > mask) +{ > + return support::tempName(dir, mask); > }
This makes the source much more readable; obviously the right thing to do. However, I think it also makes sense to make that QFileInfo a member variable of FileName, no? You seem to be creating an awful lot of temporary objects for no real reason. Angus