}
+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;
- fstat(fd, &info);
+ 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
// in the name.
static string const keep = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "+,-0123456789;=";
+ "+-0123456789;=";
string::size_type pos = 0;
while ((pos = mname.find_first_not_of(keep, pos)) != string::npos)
mname[pos++] = '_';