}
+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;
+}
+
unsigned long FileName::checksum() const
{
unsigned long result = 0;
return result;
struct stat info;
- if (fstat(fd, &info))
- // bug 5891
- return result;
+ if (fstat(fd, &info)){
+ // fstat fails on samba shares (bug 5891)
+ close(fd);
+ return checksum_ifstream_fallback(file);
+ }
void * mm = mmap(0, info.st_size, PROT_READ,
MAP_PRIVATE, fd, 0);
close(fd);
#else // no SUM_WITH_MMAP
-
- //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();
-
+ result = checksum_ifstream_fallback(file);
#endif // SUM_WITH_MMAP
#endif // QT_VERSION
format = "fits";
}
- // Dia knows also compressed form
- if ((format == "gzip") && (!compare_ascii_no_case(extension(), "dia")))
- format="dia";
-
if (!format.empty()) {
LYXERR(Debug::GRAPHICS, "Recognised Fileformat: " << format);
return format;