mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Database: Switched from file names to Datafile objects
This commit is contained in:
parent
eebc2afaaf
commit
b2f470d113
2 changed files with 16 additions and 9 deletions
|
@ -36,17 +36,23 @@ void Database::initialize (const std::string& location)
|
|||
{
|
||||
_location = location;
|
||||
|
||||
// _data_files[0] is always the current one, which may not exist.
|
||||
// _data_files[0] is always the current file.
|
||||
_current = currentDataFile ();
|
||||
_data_files.push_back (_current);
|
||||
Datafile currentFile;
|
||||
currentFile.initialize (_current);
|
||||
_files.push_back (currentFile);
|
||||
|
||||
Directory d (_location);
|
||||
for (const auto& file : d.list ())
|
||||
{
|
||||
if (1 /* looks like one of our data files */)
|
||||
if (1 /* TODO looks like one of our data files */)
|
||||
{
|
||||
if (file != _current)
|
||||
_data_files.push_back (file);
|
||||
{
|
||||
Datafile oldFile;
|
||||
oldFile.initialize (file);
|
||||
_files.push_back (oldFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,8 +64,8 @@ std::string Database::dump () const
|
|||
{
|
||||
std::stringstream out;
|
||||
out << "Database\n";
|
||||
for (const auto& file : _data_files)
|
||||
out << " Data: " << file << "\n";
|
||||
for (const auto& file : _files)
|
||||
out << " Datafile: " << file.name () << "\n";
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#ifndef INCLUDED_DATABASE
|
||||
#define INCLUDED_DATABASE
|
||||
|
||||
#include <Datafile.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -41,9 +42,9 @@ private:
|
|||
std::string currentDataFile () const;
|
||||
|
||||
private:
|
||||
std::string _location {"~/.timewarrior/data"};
|
||||
std::string _current {};
|
||||
std::vector <std::string> _data_files {};
|
||||
std::string _location {"~/.timewarrior/data"};
|
||||
std::string _current {};
|
||||
std::vector <Datafile> _files {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue