]> git.lyx.org Git - lyx.git/blobdiff - src/support/tempname.cpp
add FileName::renameTo() method.
[lyx.git] / src / support / tempname.cpp
index 049b863d7e5a4bd5f39798fcf2c80d873608a982..e5d19f30fe8b650776f21e93937aa7cd613da22e 100644 (file)
 #include "support/lyxlib.h"
 
 #include "support/convert.h"
+#include "support/debug.h"
 #include "support/filetools.h"
 #include "support/Package.h"
 
-#include "debug.h"
-
 #include <boost/scoped_array.hpp>
 
 #include <cstdlib>
@@ -43,10 +42,9 @@ extern "C" int mkstemp(char *);
 # endif
 #endif
 
-using boost::scoped_array;
+using namespace std;
 
-using std::string;
-using std::endl;
+using boost::scoped_array;
 
 namespace lyx {
 namespace support {
@@ -84,10 +82,9 @@ int make_tempfile(char * templ)
 
 FileName const tempName(FileName const & dir, string const & mask)
 {
-       string const tmpdir(dir.empty() ?
-                       package().temp_dir().absFilename() :
-                       dir.absFilename());
-       string tmpfl(to_filesystem8bit(from_utf8(addName(tmpdir, mask))));
+       string const tmpdir = dir.empty()
+               ? package().temp_dir().absFilename() : dir.absFilename();
+       string tmpfl = to_filesystem8bit(from_utf8(addName(tmpdir, mask)));
 #if defined (HAVE_GETPID)
        tmpfl += convert<string>(getpid());
 #elif defined (HAVE__GETPID)
@@ -112,15 +109,11 @@ FileName const tempName(FileName const & dir, string const & mask)
 #else
 # error No x() function.
 #endif
-               LYXERR(Debug::FILES) << "Temporary file `" << t
-                                    << "' created." << endl;
+               LYXERR(Debug::FILES, "Temporary file `" << t << "' created.");
                return FileName(t);
-       } else {
-               LYXERR(Debug::FILES)
-                       << "LyX Error: Unable to create temporary file."
-                       << endl;
-               return FileName();
        }
+       LYXERR(Debug::FILES, "LyX Error: Unable to create temporary file.");
+       return FileName();
 }
 
 } // namespace support