]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
Reformat mangled filenames for (xhtml) export to have them sorted.
[lyx.git] / src / support / FileName.cpp
index a6b849407a5156d4da27263e30a9b1533f10a0f2..729e3d024070b130830d7b3f70ef2f60bed53773 100644 (file)
@@ -35,7 +35,7 @@
 #include <QThread>
 #endif
 
-#include <boost/crc.hpp>
+#include "support/checksum.h"
 
 #include <algorithm>
 #include <iterator>
@@ -89,7 +89,7 @@ struct FileName::Private
                : fi(toqstr(handleTildeName(abs_filename)))
        {
                name = fromqstr(fi.absoluteFilePath());
-               fi.setCaching(fi.exists() ? true : false);
+               fi.setCaching(fi.exists());
        }
        ///
        inline void refresh()
@@ -519,7 +519,12 @@ time_t FileName::lastModified() const
        // been touched between the object creation and now, we refresh the file
        // information.
        d->refresh();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+       return d->fi.lastModified().toSecsSinceEpoch();
+#else
        return d->fi.lastModified().toTime_t();
+#endif
+       
 }
 
 
@@ -537,20 +542,14 @@ bool FileName::link(FileName const & name) const
 
 unsigned long checksum_ifstream_fallback(char const * file)
 {
-       unsigned long result = 0;
        //LYXERR(Debug::FILES, "lyx::sum() using istreambuf_iterator (fast)");
        ifstream ifs(file, ios_base::in | ios_base::binary);
        if (!ifs)
-               return result;
-
-       istreambuf_iterator<char> beg(ifs);
-       istreambuf_iterator<char> end;
-       boost::crc_32_type crc;
-       crc = for_each(beg, end, crc);
-       result = crc.checksum();
-       return result;
+               return 0;
+       return support::checksum(ifs);
 }
 
+
 unsigned long FileName::checksum() const
 {
        if (!exists()) {
@@ -583,11 +582,9 @@ unsigned long FileName::checksum() const
        qint64 size = fi.size();
        uchar * ubeg = qf.map(0, size);
        uchar * uend = ubeg + size;
-       boost::crc_32_type ucrc;
-       ucrc.process_block(ubeg, uend);
+       result = support::checksum(ubeg, uend);
        qf.unmap(ubeg);
        qf.close();
-       result = ucrc.checksum();
 
 #else // QT_VERSION
 
@@ -616,12 +613,10 @@ unsigned long FileName::checksum() const
                return 0;
        }
 
-       char * beg = static_cast<char*>(mm);
-       char * end = beg + info.st_size;
+       unsigned char * beg = static_cast<unsigned char*>(mm);
+       unsigned char * end = beg + info.st_size;
 
-       boost::crc_32_type crc;
-       crc.process_block(beg, end);
-       result = crc.checksum();
+       result = support::checksum(beg, end);
 
        munmap(mm, info.st_size);
        close(fd);
@@ -958,7 +953,7 @@ string DocFileName::outputFileName(string const & path) const
 string DocFileName::mangledFileName(string const & dir) const
 {
        return mangledFileName(dir, true, false);
-};
+}
 
 string DocFileName::mangledFileName(string const & dir, bool use_counter, bool encrypt_path) const
 {
@@ -988,7 +983,7 @@ string DocFileName::mangledFileName(string const & dir, bool use_counter, bool e
 #endif
                hash = hash.toHex();
                mname = fromqstr(QString(hash));
-               mname = mname + "_" + onlyFileName();
+               mname = "export_" + onlyFileName() + "_" + mname;
                }
 
        // The mangled name must be a valid LaTeX name.