X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flastfiles.C;h=615b9de7ee35c8e52338e9dd516aca4369f6526d;hb=9833278ed8cd7f85dbabcfe0e2e8747c5db2db3d;hp=a30deaba21ddf5b7c481c24cb20402827ce2df8b;hpb=dfe1bc44b44903faf77ef454c98c4c3e56c1d5e3;p=lyx.git diff --git a/src/lastfiles.C b/src/lastfiles.C index a30deaba21..615b9de7ee 100644 --- a/src/lastfiles.C +++ b/src/lastfiles.C @@ -1,12 +1,12 @@ /* 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 @@ -15,12 +15,25 @@ #pragma implementation #endif -#include -#include -#include "support/FileInfo.h" #include "lastfiles.h" #include "debug.h" +#include "support/FileInfo.h" + +#include +#include +#include + + +using std::ifstream; +using std::ofstream; +using std::getline; +using std::endl; +using std::find; +using std::copy; +using std::ostream_iterator; + + LastFiles::LastFiles(string const & filename, bool st, unsigned int num) : dostat(st) { @@ -50,7 +63,7 @@ void LastFiles::readFile(string const & filename) 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())) @@ -65,11 +78,8 @@ void LastFiles::writeFile(string const & filename) const { 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(ofs, "\n")); } else lyxerr << "LyX: Warning: unable to save LastFiles: " << filename << endl; @@ -88,7 +98,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];