mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Database: Removed obsolete ::getCurrentDataFile
This commit is contained in:
parent
e70424f32b
commit
7db6f68b92
2 changed files with 0 additions and 42 deletions
|
@ -37,34 +37,12 @@
|
||||||
void Database::initialize (const std::string& location)
|
void Database::initialize (const std::string& location)
|
||||||
{
|
{
|
||||||
_location = location;
|
_location = location;
|
||||||
auto current = currentDataFile ();
|
|
||||||
|
|
||||||
// Because the data files have names YYYY-MM.data, sorting them by name also
|
// Because the data files have names YYYY-MM.data, sorting them by name also
|
||||||
// sorts by the intervals within.
|
// sorts by the intervals within.
|
||||||
Directory d (_location);
|
Directory d (_location);
|
||||||
auto files = d.list ();
|
auto files = d.list ();
|
||||||
std::sort (files.begin (), files.end ());
|
std::sort (files.begin (), files.end ());
|
||||||
|
|
||||||
// Ensure the list always contains the name of the current file, even if it
|
|
||||||
// does not exist.
|
|
||||||
if (std::find (files.begin (), files.end (), current) == files.end ())
|
|
||||||
files.push_back (current);
|
|
||||||
|
|
||||||
for (auto& file : files)
|
|
||||||
{
|
|
||||||
// If it looks like a data file.
|
|
||||||
if (file.find (".data") == file.length () - 5)
|
|
||||||
{
|
|
||||||
Datafile df;
|
|
||||||
df.initialize (file);
|
|
||||||
|
|
||||||
// New files need the set of current exclusions.
|
|
||||||
if (! File (file).exists ())
|
|
||||||
df.setExclusions (_exclusions);
|
|
||||||
|
|
||||||
_files.push_back (df);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -203,31 +181,12 @@ std::string Database::dump () const
|
||||||
for (auto& exclusion : _exclusions)
|
for (auto& exclusion : _exclusions)
|
||||||
out << " Exclusion: " << exclusion << "\n";
|
out << " Exclusion: " << exclusion << "\n";
|
||||||
|
|
||||||
out << "Datafiles\n";
|
|
||||||
for (auto& df : _files)
|
for (auto& df : _files)
|
||||||
out << df.dump ();
|
out << df.dump ();
|
||||||
|
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
std::string Database::currentDataFile () const
|
|
||||||
{
|
|
||||||
time_t current;
|
|
||||||
time (¤t);
|
|
||||||
struct tm* t = gmtime (¤t);
|
|
||||||
|
|
||||||
std::stringstream out;
|
|
||||||
out << _location
|
|
||||||
<< '/'
|
|
||||||
<< std::setw (4) << std::setfill ('0') << (t->tm_year + 1900)
|
|
||||||
<< '-'
|
|
||||||
<< std::setw (2) << std::setfill ('0') << (t->tm_mon + 1)
|
|
||||||
<< ".data";
|
|
||||||
|
|
||||||
return out.str ();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
unsigned int Database::getDatafile (int year, int month)
|
unsigned int Database::getDatafile (int year, int month)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,6 @@ public:
|
||||||
std::string dump () const;
|
std::string dump () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string currentDataFile () const;
|
|
||||||
unsigned int getDatafile (int, int);
|
unsigned int getDatafile (int, int);
|
||||||
std::vector <Daterange> segmentRange (const Daterange&);
|
std::vector <Daterange> segmentRange (const Daterange&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue