]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
Fix samba related crashes
[lyx.git] / src / support / FileName.cpp
index e8a8ab997be6c6a1c6ca728f61c56427c0d0e0ad..470ff9091133ff9f0c9fcd4c68fb01e489794dab 100644 (file)
@@ -543,7 +543,9 @@ unsigned long FileName::checksum() const
                return result;
 
        struct stat info;
-       fstat(fd, &info);
+       if (fstat(fd, &info))
+               // bug 5891
+               return result;
 
        void * mm = mmap(0, info.st_size, PROT_READ,
                         MAP_PRIVATE, fd, 0);
@@ -922,12 +924,6 @@ string FileName::guessFormatFromContents() const
 
                else if (contains(str, "BITPIX"))
                        format = "fits";
-
-               else if (contains(str, encryptionGuessString())) {
-                       string ver = token(str, '-', 1);
-                       string key = token(str, '-', 2);
-                       format = encryptionGuessString() + "-" + ver + "-" + key;
-               }
        }
 
        // Dia knows also compressed form
@@ -952,57 +948,6 @@ bool FileName::isZippedFile() const
 }
 
 
-bool FileName::isEncryptedFile() const
-{
-       string const type = guessFormatFromContents();
-       string const guess = encryptionGuessString();
-       return toqstr(type).contains(toqstr(guess));
-}
-
-std::string FileName::encryptionGuessString()
-{
-       return "LyXEncrypted";
-}
-
-std::string FileName::encryptionPrefix(int version, int keytype)
-{
-       // A encrypted file starts with the bytes "LyXEncrypted-001-001-"
-       // the first number describes the encryption version which could
-       // change with the time. the second number describes how the key 
-       // is generated, ATM only passwords are supported.
-       QString guess = toqstr(encryptionGuessString());
-       QString vstr = QString::number(version);
-       QString kstr = QString::number(keytype);
-       vstr = vstr.rightJustified(3, '0');
-       kstr = kstr.rightJustified(3, '0');
-       return fromqstr(guess + "-" + vstr + "-" + kstr + "-");
-}
-
-
-int FileName::encryptionVersion() const
-{
-       string const type = guessFormatFromContents();
-       string ver = token(type, '-', 1);
-       bool ok = false;
-       int version = toqstr(ver).toInt(&ok);
-       if (!ok)
-               return -1;
-       return version;
-}
-
-int FileName::encryptionKeytype() const
-{
-       string const type = guessFormatFromContents();
-       string ver = token(type, '-', 2);
-       bool ok = false;
-       int keytype = toqstr(ver).toInt(&ok);
-       if (!ok)
-               return -1;
-       return keytype;
-}
-
-
-
 docstring const FileName::relPath(string const & path) const
 {
        // FIXME UNICODE
@@ -1166,7 +1111,7 @@ string DocFileName::mangledFileName(string const & dir) const
        // 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++] = '_';