}
lex.next();
- string const token(lex.getString());
+ string const token = lex.getString();
if (!lex) {
Alert::error(_("Document could not be read"),
// when Vietnamese is used, babel must directly be loaded with the
// language options, not in the class options, see
// http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
- int viet = language_options.str().find("vietnam");
+ size_t viet = language_options.str().find("vietnam");
// viet = string::npos when not found
if (lyxrc.language_global_options && !language_options.str().empty()
&& viet == string::npos)
// when Vietnamese is used, babel must directly be loaded with the
// language options, see
// http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
- int viet = lang_opts.find("vietnam");
+ size_t viet = lang_opts.find("vietnam");
// viet = string::npos when not found
if (!lyxrc.language_global_options || viet != string::npos)
return "\\usepackage[" + lang_opts + "]{babel}";
#include "support/qstring_helpers.h"
#include <QFile>
+#include <QFileInfo>
-#include <boost/assert.hpp>
+#include <boost/filesystem/exception.hpp>
+#include <boost/filesystem/operations.hpp>
#include <map>
#include <sstream>
using std::map;
using std::string;
-
namespace lyx {
namespace support {
-FileName::FileName()
-{}
-
-
-FileName::~FileName()
-{}
+/////////////////////////////////////////////////////////////////////
+//
+// FileName
+//
+/////////////////////////////////////////////////////////////////////
FileName::FileName(string const & abs_filename)
}
+bool FileName::exists() const
+{
+ return QFileInfo(toqstr(name_)).exists();
+}
+
+
+bool FileName::isReadOnly() const
+{
+ QFileInfo const fi(toqstr(name_));
+ return fi.isReadable() && !fi.isWritable();
+}
+
+
+std::time_t FileName::lastModified() const
+{
+ return boost::filesystem::last_write_time(toFilesystemEncoding());
+}
+
+
bool operator==(FileName const & lhs, FileName const & rhs)
{
return lhs.absFilename() == rhs.absFilename();
}
+/////////////////////////////////////////////////////////////////////
+//
+// DocFileName
+//
+/////////////////////////////////////////////////////////////////////
+
+
DocFileName::DocFileName()
: save_abs_path_(true)
{}
class FileName {
public:
/// Constructor for empty filenames
- FileName();
+ FileName() {}
/** Constructor for nonempty filenames.
* explicit because we don't want implicit conversion of relative
* paths in function arguments (e.g. of unlink).
* Encoding is always UTF-8.
*/
explicit FileName(std::string const & abs_filename);
- virtual ~FileName();
+ virtual ~FileName() {}
/** Set a new filename.
* \param filename the file in question. Must have an absolute path.
* Encoding is always UTF-8.
* Only use this for accessing the file, e.g. with an fstream.
*/
std::string const toFilesystemEncoding() const;
+
+ /// returns true if the file exists
+ bool exists() const;
+ /// returns time of last write access
+ std::time_t lastModified() const;
+ /// return true when file is readable but not writabel
+ bool isReadOnly() const;
+
/**
* Get a FileName from \p name in the encoding used by the file system.
* Only use this for filenames you got directly from the file system,
std::string const relFilename(std::string const & buffer_path = std::string()) const;
/// \param buf_path if empty, uses `pwd`
std::string const outputFilename(std::string const & buf_path = std::string()) const;
-
+
/** @returns a mangled representation of the absolute file name
* suitable for use in the temp dir when, for example, converting
* an image file to another format.