X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flastfiles.C;h=9c5449fb2d94f02fa700ad75fc32068ce1fa1ca1;hb=69cf3b62043861ccad5f8ad7ffb4981fe50b078d;hp=7a08ac16d20378657c8580b99aff025b388e96ff;hpb=a040c0bc6f017d0591bbc7ad1aa590589dbc40ff;p=lyx.git diff --git a/src/lastfiles.C b/src/lastfiles.C index 7a08ac16d2..9c5449fb2d 100644 --- a/src/lastfiles.C +++ b/src/lastfiles.C @@ -1,30 +1,33 @@ /* 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 +#include "lastfiles.h" +#include "debug.h" -#ifdef __GNUG__ -#pragma implementation -#endif +#include "support/FileInfo.h" #include +#include +#include + + using std::ifstream; using std::ofstream; - -#include +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) @@ -40,7 +43,7 @@ void LastFiles::setNumberOfFiles(unsigned int no) num_files = no; else { lyxerr << "LyX: lastfiles: too many files\n" - "\tdefault (= " << int(DEFAULTFILES) + "\tdefault (=" << int(DEFAULTFILES) << ") used." << endl; num_files = DEFAULTFILES; } @@ -55,7 +58,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())) @@ -70,11 +73,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; @@ -93,7 +93,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];