]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.cpp
Transfer tempName() implementation to FileName.
[lyx.git] / src / support / filetools.cpp
index cc77812708580b7ddc40427df9fa3e73da35bbd4..f86fe835f632d059d2263263f774a41c20c912b8 100644 (file)
 #include <fstream>
 #include <sstream>
 
-using std::endl;
-using std::getline;
-using std::make_pair;
-using std::string;
-using std::ifstream;
-using std::ostringstream;
-using std::vector;
-using std::pair;
+using namespace std;
 
 namespace lyx {
 namespace support {
@@ -329,14 +322,14 @@ static FileName createTmpDir(FileName const & tempdir, string const & mask)
        LYXERR(Debug::FILES, "createTmpDir: tempdir=`" << tempdir << "'\n"
                << "createTmpDir:    mask=`" << mask << '\'');
 
-       FileName const tmpfl(tempName(tempdir, mask));
-       // lyx::tempName actually creates a file to make sure that it
+       FileName const tmpfl = FileName::tempName(tempdir, mask);
+       // FileName::tempName actually creates a file to make sure that it
        // stays unique. So we have to delete it before we can create
        // a dir with the same name. Note also that we are not thread
        // safe because of the gap between unlink and mkdir. (Lgb)
        tmpfl.removeFile();
 
-       if (tmpfl.empty() || mkdir(tmpfl, 0700)) {
+       if (tmpfl.empty() || !tmpfl.createDirectory(0700)) {
                lyxerr << "LyX could not create the temporary directory '"
                       << tmpfl << "'" << endl;
                return FileName();
@@ -355,7 +348,7 @@ string const createBufferTmpDir()
                package().temp_dir().absFilename() + "/lyx_tmpbuf" +
                convert<string>(count++);
 
-       if (mkdir(FileName(tmpfl), 0777)) {
+       if (!FileName(tmpfl).createDirectory(0777)) {
                lyxerr << "LyX could not create the temporary directory '"
                       << tmpfl << "'" << endl;
                return string();
@@ -369,7 +362,7 @@ FileName const createLyXTmpDir(FileName const & deflt)
        if (deflt.empty() || deflt.absFilename() == "/tmp")
                return createTmpDir(FileName("/tmp"), "lyx_tmpdir");
 
-       if (!mkdir(deflt, 0777)) 
+       if (deflt.createDirectory(0777)) 
                return deflt;
 
        if (deflt.isDirWritable()) {
@@ -894,7 +887,7 @@ string const readBB_from_PSFile(FileName const & file)
 
        static boost::regex bbox_re(
                "^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
-       std::ifstream is(file_.toFilesystemEncoding().c_str());
+       ifstream is(file_.toFilesystemEncoding().c_str());
        while (is) {
                string s;
                getline(is,s);