1 #include "recentfiles.hpp"
5 recent_files::recent_files(const std::string
& _cfgfile
, size_t _maxcount
)
11 void recent_files::add(const std::string
& file
)
13 std::list
<std::string
> ents
;
16 std::ifstream
in(cfgfile
);
23 //Probe for existence.
24 delete &open_file_relative(f
, "");
25 } catch(std::exception
& e
) {
33 //Search for matches. If found, move to front, otherwise push to first.
34 auto itr
= ents
.begin();
35 for(; itr
!= ents
.end(); itr
++)
40 ents
.push_front(file
);
41 //Write up to maxcount entries.
44 std::ofstream
out(cfgfile
);
45 for(itr
= ents
.begin(); itr
!= ents
.end() && i
< maxcount
; itr
++, i
++)
46 out
<< *itr
<< std::endl
;
52 void recent_files::add_hook(hook
& h
)
57 void recent_files::remove_hook(hook
& h
)
59 for(auto itr
= hooks
.begin(); itr
!= hooks
.end(); itr
++)
66 std::list
<std::string
> recent_files::get()
69 std::list
<std::string
> ents
;
72 std::ifstream
in(cfgfile
);
87 recent_files::recent_files::hook::~hook()