+#ifdef NEW_STORE
+ for (BufferStorage::iterator it = bstore.begin();
+ it != bstore.end(); ++it) {
+ if (!(*it)->isLyxClean()) {
+ bool madeit=false;
+
+ lyxerr <<_("lyx: Attempting to save"
+ " document ")
+ << (*it)->filename
+ << _(" as...") << endl;
+
+ for (int i = 0; i < 3 && !madeit; ++i) {
+ string s;
+
+ // We try to save three places:
+ // 1) Same place as document.
+ // 2) In HOME directory.
+ // 3) In "/tmp" directory.
+ if (i == 0) {
+ s = (*it)->filename;
+ } else if (i == 1) {
+ s = AddName(GetEnvPath("HOME"),
+ (*it)->filename);
+ } else { // MakeAbsPath to prepend the current drive letter on OS/2
+ s = AddName(MakeAbsPath("/tmp/"),
+ (*it)->filename);
+ }
+ s += ".emergency";
+
+ lyxerr << " " << i + 1 << ") " << s << endl;
+
+ if ((*it)->writeFile(s,true)) {
+ (*it)->markLyxClean();
+ lyxerr << _(" Save seems successful. "
+ "Phew.") << endl;
+ madeit = true;
+ } else if (i != 2) {
+ lyxerr << _(" Save failed! Trying...")
+ << endl;
+ } else {
+ lyxerr << _(" Save failed! Bummer. Document is lost.") << endl;
+ }
+ }
+ }
+ }
+#else