Enhancement - Path integration

- Obsoleted util.cpp spit, slurp calls
This commit is contained in:
Paul Beckingham
2010-01-16 17:45:45 -05:00
parent a8f03679ed
commit abffaa184b
8 changed files with 19 additions and 110 deletions

View File

@@ -375,92 +375,6 @@ int flock (int fd, int operation)
}
#endif
////////////////////////////////////////////////////////////////////////////////
bool slurp (
const std::string& file,
std::vector <std::string>& contents,
bool trimLines /* = false */)
{
contents.clear ();
std::ifstream in (file.c_str ());
if (in.good ())
{
std::string line;
while (getline (in, line))
{
if (trimLines) line = trim (line);
contents.push_back (line);
}
in.close ();
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool slurp (
const std::string& file,
std::string& contents,
bool trimLines /* = false */)
{
contents = "";
std::ifstream in (file.c_str ());
if (in.good ())
{
std::string line;
while (getline (in, line))
{
if (trimLines) line = trim (line);
contents += line + "\n";
}
in.close ();
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
void spit (const std::string& file, const std::string& contents)
{
std::ofstream out (file.c_str ());
if (out.good ())
{
out << contents;
out.close ();
}
else
throw std::string ("Could not write file '") + file + "'"; // TODO i18n
}
////////////////////////////////////////////////////////////////////////////////
void spit (
const std::string& file,
const std::vector <std::string>& lines,
bool addNewlines /* = true */)
{
std::ofstream out (file.c_str ());
if (out.good ())
{
foreach (line, lines)
{
out << *line;
if (addNewlines)
out << "\n";
}
out.close ();
}
else
throw std::string ("Could not write file '") + file + "'"; // TODO i18n
}
////////////////////////////////////////////////////////////////////////////////
bool taskDiff (const Task& before, const Task& after)
{