]> git.lyx.org Git - lyx.git/blobdiff - src/lastfiles.C
bug 183
[lyx.git] / src / lastfiles.C
index da4d4d9a54297421cb65cc59e0f3283ccd081839..088a1d73e03e44929d857463307ff94a1d34321d 100644 (file)
@@ -4,7 +4,7 @@
  *           LyX, The Document Processor
  *      
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995-2001 The LyX Team.
  *
  * ====================================================== */
 
 #endif
 
 #include <fstream>
-using std::ifstream;
-using std::ofstream;
-using std::copy;
-using std::ostream_iterator;
-
 #include <algorithm>
-using std::find;
 
 #include "support/FileInfo.h"
 #include "lastfiles.h"
 #include "debug.h"
 
+using std::getline;
+using std::endl;
+
+
 LastFiles::LastFiles(string const & filename, bool st, unsigned int num)
        : dostat(st)
 {
@@ -53,11 +51,11 @@ void LastFiles::readFile(string const & filename)
 {
        // we will not complain if we can't find filename nor will
        // we issue a warning. (Lgb)
-       ifstream ifs(filename.c_str());
+       std::ifstream ifs(filename.c_str());
        string tmp;
        FileInfo fileInfo;
 
-       while(getline(ifs, tmp) && files.size() < num_files) {
+       while (getline(ifs, tmp) && files.size() < num_files) {
                if (dostat) {
                        if (!(fileInfo.newFile(tmp).exist() &&
                              fileInfo.isRegular()))
@@ -70,23 +68,10 @@ void LastFiles::readFile(string const & filename)
 
 void LastFiles::writeFile(string const & filename) const
 {
-       ofstream ofs(filename.c_str());
+       std::ofstream ofs(filename.c_str());
        if (ofs) {
-#if 0
-               for (Files::const_iterator cit = files.begin();
-                    cit != files.end();
-                    ++cit) {
-                       ofs << (*cit) << '\n';
-               }
-#else
-               // Ok, ok. It is not required to do it this way...but it
-               // is kindo nice and shows the versiality of iterators and
-               // algorithms. I'll leave this in, and if I get reports
-               // about compilations errors I take it out again before
-               // 1.1.4. (Lgb)
-               copy(files.begin(), files.end(),
-                    ostream_iterator<string>(ofs, "\n"));
-#endif
+               std::copy(files.begin(), files.end(),
+                         std::ostream_iterator<string>(ofs, "\n"));
        } else
                lyxerr << "LyX: Warning: unable to save LastFiles: "
                       << filename << endl;
@@ -96,7 +81,7 @@ void LastFiles::writeFile(string const & filename) const
 void LastFiles::newFile(string const & file)
 {
        // If file already exist, delete it and reinsert at front.
-       Files::iterator it = find(files.begin(), files.end(), file);
+       Files::iterator it = std::find(files.begin(), files.end(), file);
        if (it != files.end())
                files.erase(it);
        files.push_front(file);
@@ -105,7 +90,7 @@ void LastFiles::newFile(string const & file)
 }
 
 
-string LastFiles::operator[](unsigned int i) const
+string const LastFiles::operator[](unsigned int i) const
 {
        if (i < files.size())
                return files[i];