Code Cleanup

- All objects now use the same convention for naming members.  The
  consistency is a good thing.
This commit is contained in:
Paul Beckingham
2011-08-25 21:54:28 -04:00
parent fb6dc5058f
commit dab06f8672
53 changed files with 1347 additions and 1349 deletions

View File

@@ -79,7 +79,7 @@ int CmdConfig::execute (std::string& output)
// Read .taskrc (or equivalent)
std::vector <std::string> contents;
File::read (context.config.original_file, contents);
File::read (context.config._original_file, contents);
// task config name value
// task config name ""
@@ -157,9 +157,9 @@ int CmdConfig::execute (std::string& output)
// Write .taskrc (or equivalent)
if (change)
{
File::write (context.config.original_file, contents);
File::write (context.config._original_file, contents);
out << "Config file "
<< context.config.original_file.data
<< context.config._original_file._data
<< " modified.\n";
}
else

View File

@@ -178,17 +178,17 @@ int CmdDiagnostics::execute (std::string& output)
// Config: .taskrc found, readable, writable
out << bold.colorize ("Configuration")
<< "\n"
<< " File: " << context.config.original_file.data
<< (context.config.original_file.exists () ? " (found)" : " (missing)")
<< ", " << context.config.original_file.size () << " bytes"
<< " File: " << context.config._original_file._data
<< (context.config._original_file.exists () ? " (found)" : " (missing)")
<< ", " << context.config._original_file.size () << " bytes"
<< ", mode "
<< std::setbase (8)
<< context.config.original_file.mode ()
<< context.config._original_file.mode ()
<< "\n";
// Config: data.location found, readable, writable
File location (context.config.get ("data.location"));
out << " Data: " << location.data
out << " Data: " << location._data
<< (location.exists () ? " (found)" : " (missing)")
<< ", " << (location.is_directory () ? "dir" : "?")
<< ", mode "

View File

@@ -600,11 +600,11 @@ bool CmdEdit::editFile (Task& task)
// Create a temp file name in data.location.
std::stringstream file;
file << "task." << getpid () << "." << task.id << ".task";
std::string path = location.data + "/" + file.str ();
std::string path = location._data + "/" + file.str ();
// Format the contents, T -> text, write to a file.
std::string before = formatTask (task);
int ignored = chdir (location.data.c_str ());
int ignored = chdir (location._data.c_str ());
++ignored; // Keep compiler quiet.
File::write (file.str (), before);

View File

@@ -77,7 +77,7 @@ int CmdInfo::execute (std::string& output)
if (context.config.getBoolean ("journal.info"))
{
Directory location (context.config.get ("data.location"));
std::string undoFile = location.data + "/undo.data";
std::string undoFile = location._data + "/undo.data";
File::read (undoFile, undo);
}

View File

@@ -63,7 +63,7 @@ int CmdMerge::execute (std::string& output)
Uri uri (file, "merge");
uri.parse();
if (uri.data.length ())
if (uri._data.length ())
{
Directory location (context.config.get ("data.location"));
@@ -73,14 +73,14 @@ int CmdMerge::execute (std::string& output)
Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL )
{
tmpfile = location.data + "/undo_remote.data";
tmpfile = location._data + "/undo_remote.data";
transport->recv (tmpfile);
delete transport;
file = tmpfile;
}
else
file = uri.path;
file = uri._path;
context.tdb.lock (context.config.getBoolean ("locking"));
context.tdb.merge (file);
@@ -91,10 +91,10 @@ int CmdMerge::execute (std::string& output)
if (tmpfile != "")
remove (tmpfile.c_str ());
if ( ((sAutopush == "ask") && (confirm ("Would you like to push the merged changes to \'" + uri.data + "\'?")) )
if ( ((sAutopush == "ask") && (confirm ("Would you like to push the merged changes to \'" + uri._data + "\'?")) )
|| (bAutopush) )
{
// context.task.set ("description", uri.data);
// context.task.set ("description", uri._data);
std::string out;
context.commands["push"]->execute (out);

View File

@@ -56,59 +56,59 @@ int CmdPull::execute (std::string& output)
Uri uri (file, "pull");
uri.parse ();
if (uri.data.length ())
if (uri._data.length ())
{
Directory location (context.config.get ("data.location"));
if (! uri.append ("{pending,undo,completed}.data"))
throw std::string ("The uri '") + uri.path + "' is not a directory. Did you forget a trailing '/'?";
throw std::string ("The uri '") + uri._path + "' is not a directory. Did you forget a trailing '/'?";
Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL)
{
transport->recv (location.data + "/");
transport->recv (location._data + "/");
delete transport;
}
else
{
// Verify that files are not being copied from rc.data.location to the
// same place.
if (Directory (uri.path) == Directory (context.config.get ("data.location")))
if (Directory (uri._path) == Directory (context.config.get ("data.location")))
throw std::string ("Cannot pull files when the source and destination are the same.");
// copy files locally
// remove {pending,undo,completed}.data
uri.path = uri.parent();
uri._path = uri.parent();
Path path1 (uri.path + "undo.data");
Path path2 (uri.path + "pending.data");
Path path3 (uri.path + "completed.data");
Path path1 (uri._path + "undo.data");
Path path2 (uri._path + "pending.data");
Path path3 (uri._path + "completed.data");
if (path1.exists() && path2.exists() && path3.exists())
{
// if (confirm ("xxxxxxxxxxxxx"))
// {
std::ofstream ofile1 ((location.data + "/undo.data").c_str(), std::ios_base::binary);
std::ifstream ifile1 (path1.data.c_str() , std::ios_base::binary);
std::ofstream ofile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary);
std::ifstream ifile1 (path1._data.c_str() , std::ios_base::binary);
ofile1 << ifile1.rdbuf();
std::ofstream ofile2 ((location.data + "/pending.data").c_str(), std::ios_base::binary);
std::ifstream ifile2 (path2.data.c_str() , std::ios_base::binary);
std::ofstream ofile2 ((location._data + "/pending.data").c_str(), std::ios_base::binary);
std::ifstream ifile2 (path2._data.c_str() , std::ios_base::binary);
ofile2 << ifile2.rdbuf();
std::ofstream ofile3 ((location.data + "/completed.data").c_str(), std::ios_base::binary);
std::ifstream ifile3 (path3.data.c_str() , std::ios_base::binary);
std::ofstream ofile3 ((location._data + "/completed.data").c_str(), std::ios_base::binary);
std::ifstream ifile3 (path3._data.c_str() , std::ios_base::binary);
ofile3 << ifile3.rdbuf();
// }
}
else
{
throw std::string ("At least one of the database files in '" + uri.path + "' is not present.");
throw std::string ("At least one of the database files in '" + uri._path + "' is not present.");
}
}
output += "Tasks transferred from " + uri.data + "\n";
output += "Tasks transferred from " + uri._data + "\n";
}
else
throw std::string ("No uri was specified for the pull. Either specify "

View File

@@ -46,7 +46,7 @@ CmdPush::CmdPush ()
}
////////////////////////////////////////////////////////////////////////////////
// Transfers the local data (from rc.location.data) to the remote path. Because
// Transfers the local data (from rc.location._data) to the remote path. Because
// this is potentially on another machine, no checking can be performed.
int CmdPush::execute (std::string& output)
{
@@ -58,41 +58,41 @@ int CmdPush::execute (std::string& output)
Uri uri (file, "push");
uri.parse ();
if (uri.data.length ())
if (uri._data.length ())
{
Directory location (context.config.get ("data.location"));
Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL )
{
transport->send (location.data + "/{pending,undo,completed}.data");
transport->send (location._data + "/{pending,undo,completed}.data");
delete transport;
}
else
{
// Verify that files are not being copied from rc.data.location to the
// same place.
if (Directory (uri.path) == Directory (context.config.get ("data.location")))
if (Directory (uri._path) == Directory (context.config.get ("data.location")))
throw std::string ("Cannot push files when the source and destination are the same.");
// copy files locally
if (! Path (uri.data).is_directory ())
throw std::string ("The uri '") + uri.path + "' is not a local directory.";
if (! Path (uri._data).is_directory ())
throw std::string ("The uri '") + uri._path + "' is not a local directory.";
std::ifstream ifile1 ((location.data + "/undo.data").c_str(), std::ios_base::binary);
std::ofstream ofile1 ((uri.path + "/undo.data").c_str(), std::ios_base::binary);
std::ifstream ifile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary);
std::ofstream ofile1 ((uri._path + "/undo.data").c_str(), std::ios_base::binary);
ofile1 << ifile1.rdbuf();
std::ifstream ifile2 ((location.data + "/pending.data").c_str(), std::ios_base::binary);
std::ofstream ofile2 ((uri.path + "/pending.data").c_str(), std::ios_base::binary);
std::ifstream ifile2 ((location._data + "/pending.data").c_str(), std::ios_base::binary);
std::ofstream ofile2 ((uri._path + "/pending.data").c_str(), std::ios_base::binary);
ofile2 << ifile2.rdbuf();
std::ifstream ifile3 ((location.data + "/completed.data").c_str(), std::ios_base::binary);
std::ofstream ofile3 ((uri.path + "/completed.data").c_str(), std::ios_base::binary);
std::ifstream ifile3 ((location._data + "/completed.data").c_str(), std::ios_base::binary);
std::ofstream ofile3 ((uri._path + "/completed.data").c_str(), std::ios_base::binary);
ofile3 << ifile3.rdbuf();
}
output += "Local tasks transferred to " + uri.data + "\n";
output += "Local tasks transferred to " + uri._data + "\n";
}
else
throw std::string ("No uri was specified for the push. Either specify "

View File

@@ -410,7 +410,7 @@ int CmdShow::execute (std::string& output)
{
Directory location (context.config.get ("data.location"));
if (location.data == "")
if (location._data == "")
out << STRING_CMD_SHOW_NO_LOCATION << "\n";
if (! location.exists ())

View File

@@ -63,13 +63,13 @@ int CmdStatistics::execute (std::string& output)
size_t dataSize = 0;
Directory location (context.config.get ("data.location"));
File pending (location.data + "/pending.data");
File pending (location._data + "/pending.data");
dataSize += pending.size ();
File completed (location.data + "/completed.data");
File completed (location._data + "/completed.data");
dataSize += completed.size ();
File undo (location.data + "/undo.data");
File undo (location._data + "/undo.data");
dataSize += undo.size ();
std::vector <std::string> undoTxns;