mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Free support/FileName.cpp from boost::filesystem. Please use '-dbg files' in order to verify that everything works correctly.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21787 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0ef6b7c5fe
commit
23c291bb6c
@ -19,11 +19,13 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "lyxlib.h"
|
#include "lyxlib.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
#include <boost/filesystem/exception.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -37,7 +39,6 @@ using std::ifstream;
|
|||||||
using std::ostringstream;
|
using std::ostringstream;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
|
||||||
|
|
||||||
// FIXME: merge this
|
// FIXME: merge this
|
||||||
//
|
//
|
||||||
@ -284,19 +285,43 @@ FileName FileName::tempName(FileName const & dir, std::string const & mask)
|
|||||||
|
|
||||||
std::time_t FileName::lastModified() const
|
std::time_t FileName::lastModified() const
|
||||||
{
|
{
|
||||||
return fs::last_write_time(toFilesystemEncoding());
|
return QFileInfo(toqstr(name_)).lastModified().toTime_t();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool rmdir(QFileInfo const & fi)
|
||||||
|
{
|
||||||
|
QDir dir(fi.absoluteFilePath());
|
||||||
|
QFileInfoList list = dir.entryInfoList();
|
||||||
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
|
if (list.at(i).fileName() == ".")
|
||||||
|
continue;
|
||||||
|
if (list.at(i).fileName() == "..")
|
||||||
|
continue;
|
||||||
|
if (list.at(i).isDir()) {
|
||||||
|
LYXERR(Debug::FILES, "Erasing dir "
|
||||||
|
<< fromqstr(list.at(i).absoluteFilePath()) << endl);
|
||||||
|
if (!rmdir(list.at(i)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LYXERR(Debug::FILES, "Erasing file "
|
||||||
|
<< fromqstr(list.at(i).absoluteFilePath()) << endl);
|
||||||
|
dir.remove(list.at(i).fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QDir parent = fi.absolutePath();
|
||||||
|
return parent.rmdir(fi.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileName::destroyDirectory() const
|
bool FileName::destroyDirectory() const
|
||||||
{
|
{
|
||||||
try {
|
bool const success = rmdir(QFileInfo(toqstr(name_)));
|
||||||
return fs::remove_all(toFilesystemEncoding()) > 0;
|
if (!success)
|
||||||
} catch (fs::filesystem_error const & fe){
|
lyxerr << "Could not delete " << *this << "." << endl;
|
||||||
lyxerr << "Could not delete " << *this << ". (" << fe.what() << ")"
|
|
||||||
<< std::endl;
|
return success;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user