#include <QList>
#include <QTime>
-#include <boost/assert.hpp>
+#include "support/lassert.h"
#include <boost/scoped_array.hpp>
#include <map>
bool FileName::copyTo(FileName const & name) const
{
+ LYXERR(Debug::FILES, "Copying " << name);
QFile::remove(name.d->fi.absoluteFilePath());
bool success = QFile::copy(d->fi.absoluteFilePath(), name.d->fi.absoluteFilePath());
if (!success)
- lyxerr << "FileName::copyTo(): Could not copy file "
- << *this << " to " << name << endl;
+ LYXERR0("FileName::copyTo(): Could not copy file "
+ << *this << " to " << name);
return success;
}
}
+string FileName::onlyFileNameWithoutExt() const
+{
+ return fromqstr(d->fi.baseName());
+}
+
+
FileName FileName::onlyPath() const
{
FileName path;
- path.d->fi.setFile(d->fi.filePath());
+ path.d->fi.setFile(d->fi.path());
return path;
}
time_t FileName::lastModified() const
{
+ // QFileInfo caches information about the file. So, in case this file has
+ // been touched between the object creation and now, we refresh the file
+ // information.
+ d->fi.refresh();
return d->fi.lastModified().toTime_t();
}
bool FileName::createDirectory(int permission) const
{
- BOOST_ASSERT(!empty());
+ LASSERT(!empty(), /**/);
return mymkdir(toFilesystemEncoding().c_str(), permission) == 0;
}
bool FileName::createPath() const
{
- BOOST_ASSERT(!empty());
+ LASSERT(!empty(), /**/);
if (isDirectory())
return true;
void DocFileName::set(string const & name, string const & buffer_path)
{
FileName::set(name);
- if (!isAbsolute())
+ bool const nameIsAbsolute = isAbsolute();
+ save_abs_path_ = nameIsAbsolute;
+ if (!nameIsAbsolute)
FileName::set(makeAbsPath(name, buffer_path).absFilename());
zipped_valid_ = false;
}