mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
File Import
- Added format identifier code for task 1.4.3, task 1.5.0, todo.sh 2.0 and CSV. - Implemented import for type text. - Implemented util.cpp:slurp function. - Gathered sample input files for import testing, and later, unit tests.
This commit is contained in:
parent
db7b2dd9fe
commit
99dc72f26f
8 changed files with 239 additions and 24 deletions
26
src/util.cpp
26
src/util.cpp
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
|
@ -404,3 +405,28 @@ 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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue