mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Merge branch '1.4.3' of git@github.com:pbeckingham/task into 1.4.3
Conflicts: ChangeLog html/task.html src/task.cpp
This commit is contained in:
commit
ce42ae9622
35 changed files with 620 additions and 258 deletions
54
src/TDB.cpp
54
src/TDB.cpp
|
@ -37,7 +37,6 @@
|
|||
TDB::TDB ()
|
||||
: mPendingFile ("")
|
||||
, mCompletedFile ("")
|
||||
, mLogFile ("")
|
||||
, mId (1)
|
||||
{
|
||||
}
|
||||
|
@ -54,7 +53,6 @@ void TDB::dataDirectory (const std::string& directory)
|
|||
{
|
||||
mPendingFile = directory + "/pending.data";
|
||||
mCompletedFile = directory + "/completed.data";
|
||||
mLogFile = directory + "/command.log";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -288,58 +286,6 @@ bool TDB::modifyT (const T& t)
|
|||
return overwritePending (pending);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::logRead (std::vector <std::string>& entries) const
|
||||
{
|
||||
entries.clear ();
|
||||
return readLockedFile (mLogFile, entries);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::logCommand (int argc, char** argv) const
|
||||
{
|
||||
// Get time info.
|
||||
time_t now;
|
||||
time (&now);
|
||||
struct tm* t = localtime (&now);
|
||||
|
||||
// Generate timestamp.
|
||||
char timestamp[20];
|
||||
sprintf (timestamp, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
t->tm_year + 1900,
|
||||
t->tm_mon + 1,
|
||||
t->tm_mday,
|
||||
t->tm_hour,
|
||||
t->tm_min,
|
||||
t->tm_sec);
|
||||
|
||||
std::string command = timestamp;
|
||||
command += " \"";
|
||||
for (int i = 0; i < argc; ++i)
|
||||
command += std::string (i ? " " : "") + argv[i];
|
||||
command += "\"\n";
|
||||
|
||||
if (! access (mLogFile.c_str (), F_OK | W_OK))
|
||||
{
|
||||
FILE* out;
|
||||
if ((out = fopen (mLogFile.c_str (), "a")))
|
||||
{
|
||||
#ifdef HAVE_FLOCK
|
||||
int retry = 0;
|
||||
while (flock (fileno (out), LOCK_EX) && ++retry <= 3)
|
||||
delay (0.25);
|
||||
#endif
|
||||
|
||||
fputs (command.c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::lock (FILE* file) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue