mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Merge branch 'silver-bullet' into 1.7.0
Conflicts: src/command.cpp
This commit is contained in:
commit
4346f83f6e
6 changed files with 176 additions and 1 deletions
38
src/util.cpp
38
src/util.cpp
|
@ -434,3 +434,41 @@ bool slurp (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
}
|
||||
|
||||
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 + "'";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue