Enhancement - Path integration
- Obsoleted util.cpp spit, slurp calls
This commit is contained in:
86
src/util.cpp
86
src/util.cpp
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user