mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Database: ::lastLine and ::allLines now initialize Datafiles
This commit is contained in:
parent
ebb3d63da5
commit
2d18970d18
1 changed files with 6 additions and 6 deletions
|
@ -37,12 +37,6 @@
|
||||||
void Database::initialize (const std::string& location)
|
void Database::initialize (const std::string& location)
|
||||||
{
|
{
|
||||||
_location = location;
|
_location = location;
|
||||||
|
|
||||||
// Because the data files have names YYYY-MM.data, sorting them by name also
|
|
||||||
// sorts by the intervals within.
|
|
||||||
Directory d (_location);
|
|
||||||
auto files = d.list ();
|
|
||||||
std::sort (files.begin (), files.end ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -67,6 +61,9 @@ std::vector <std::string> Database::files () const
|
||||||
// Note: Not an exclusion.
|
// Note: Not an exclusion.
|
||||||
std::string Database::lastLine ()
|
std::string Database::lastLine ()
|
||||||
{
|
{
|
||||||
|
if (! _files.size ())
|
||||||
|
initializeDatafiles ();
|
||||||
|
|
||||||
std::vector <Datafile>::reverse_iterator ri;
|
std::vector <Datafile>::reverse_iterator ri;
|
||||||
for (ri = _files.rbegin (); ri != _files.rend (); ri++)
|
for (ri = _files.rbegin (); ri != _files.rend (); ri++)
|
||||||
{
|
{
|
||||||
|
@ -81,6 +78,9 @@ std::string Database::lastLine ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::vector <std::string> Database::allLines ()
|
std::vector <std::string> Database::allLines ()
|
||||||
{
|
{
|
||||||
|
if (! _files.size ())
|
||||||
|
initializeDatafiles ();
|
||||||
|
|
||||||
std::vector <std::string> all;
|
std::vector <std::string> all;
|
||||||
for (auto& file : _files)
|
for (auto& file : _files)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue