/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-1999 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
#include <config.h>
+#include "lastfiles.h"
+#include "debug.h"
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include "support/FileInfo.h"
#include <fstream>
+#include <algorithm>
+#include <iterator>
+
+
+using namespace lyx::support;
+
using std::ifstream;
using std::ofstream;
-
-#include <algorithm>
+using std::getline;
+using std::endl;
using std::find;
+using std::copy;
+using std::ostream_iterator;
-#include "support/FileInfo.h"
-#include "lastfiles.h"
-#include "debug.h"
LastFiles::LastFiles(string const & filename, bool st, unsigned int num)
: dostat(st)
num_files = no;
else {
lyxerr << "LyX: lastfiles: too many files\n"
- "\tdefault (= " << int(DEFAULTFILES)
+ "\tdefault (=" << int(DEFAULTFILES)
<< ") used." << endl;
num_files = DEFAULTFILES;
}
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()))
{
ofstream ofs(filename.c_str());
if (ofs) {
- for (Files::const_iterator cit = files.begin();
- cit != files.end();
- ++cit) {
- ofs << (*cit) << '\n';
- }
+ copy(files.begin(), files.end(),
+ ostream_iterator<string>(ofs, "\n"));
} else
lyxerr << "LyX: Warning: unable to save LastFiles: "
<< filename << endl;
}
-string LastFiles::operator[](unsigned int i) const
+string const LastFiles::operator[](unsigned int i) const
{
if (i < files.size())
return files[i];