]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
More requires --> required, for C++2a.
[lyx.git] / src / Buffer.cpp
index 9b6727fd46c54af1751b59b5af1ff5069c5fc1fb..a300b2dd4bd829853c63b74192786acae02d678f 100644 (file)
@@ -4235,91 +4235,6 @@ void Buffer::setGuiDelegate(frontend::GuiBufferDelegate * gui)
 }
 
 
-
-namespace {
-
-class AutoSaveBuffer : public ForkedProcess {
-public:
-       ///
-       AutoSaveBuffer(Buffer const & buffer, FileName const & fname)
-               : buffer_(buffer), fname_(fname) {}
-       ///
-       virtual shared_ptr<ForkedProcess> clone() const
-       {
-               return make_shared<AutoSaveBuffer>(*this);
-       }
-       ///
-       int start()
-       {
-               command_ = to_utf8(bformat(_("Auto-saving %1$s"),
-                                                from_utf8(fname_.absFileName())));
-               return run(DontWait);
-       }
-private:
-       ///
-       virtual int generateChild();
-       ///
-       Buffer const & buffer_;
-       FileName fname_;
-};
-
-
-int AutoSaveBuffer::generateChild()
-{
-#if defined(__APPLE__)
-       /* FIXME fork() is not usable for autosave on Mac OS X 10.6 (snow leopard)
-        *   We should use something else like threads.
-        *
-        * Since I do not know how to determine at run time what is the OS X
-        * version, I just disable forking altogether for now (JMarc)
-        */
-       pid_t const pid = -1;
-#else
-       // tmp_ret will be located (usually) in /tmp
-       // will that be a problem?
-       // Note that this calls ForkedCalls::fork(), so it's
-       // ok cross-platform.
-       pid_t const pid = fork();
-       // If you want to debug the autosave
-       // you should set pid to -1, and comment out the fork.
-       if (pid != 0 && pid != -1)
-               return pid;
-#endif
-
-       // pid = -1 signifies that lyx was unable
-       // to fork. But we will do the save
-       // anyway.
-       bool failed = false;
-       TempFile tempfile("lyxautoXXXXXX.lyx");
-       tempfile.setAutoRemove(false);
-       FileName const tmp_ret = tempfile.name();
-       if (!tmp_ret.empty()) {
-               if (!buffer_.writeFile(tmp_ret))
-                       failed = true;
-               else if (!tmp_ret.moveTo(fname_))
-                       failed = true;
-       } else
-               failed = true;
-
-       if (failed) {
-               // failed to write/rename tmp_ret so try writing direct
-               if (!buffer_.writeFile(fname_)) {
-                       // It is dangerous to do this in the child,
-                       // but safe in the parent, so...
-                       if (pid == -1) // emit message signal.
-                               buffer_.message(_("Autosave failed!"));
-               }
-       }
-
-       if (pid == 0) // we are the child so...
-               _exit(0);
-
-       return pid;
-}
-
-} // namespace
-
-
 FileName Buffer::getEmergencyFileName() const
 {
        return FileName(d->filename.absFileName() + ".emergency");