mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-30 22:43:24 +02:00
Merge branch '1.9.0' of tasktools.org:task into 1.9.0
This commit is contained in:
commit
b001c2f40b
8 changed files with 37 additions and 323 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include "Path.h"
|
||||
#include "Config.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
@ -99,16 +100,16 @@ bool Config::load (const std::string& file, int nest /* = 1 */)
|
|||
std::string::size_type include = line.find ("include"); // no i18n.
|
||||
if (include != std::string::npos)
|
||||
{
|
||||
std::string included = expandPath ( trim ( line.substr (include + 7), " \t"));
|
||||
if (isAbsolutePath (included))
|
||||
Path included (trim (line.substr (include + 7), " \t"));
|
||||
if (included.is_absolute ())
|
||||
{
|
||||
if (!access (included.c_str (), F_OK | R_OK))
|
||||
this->load (included, nest + 1);
|
||||
if (included.readable ())
|
||||
this->load (included.data, nest + 1);
|
||||
else
|
||||
throw std::string ("Could not read include file '") + included + "'";
|
||||
throw std::string ("Could not read include file '") + included.data + "'";
|
||||
}
|
||||
else
|
||||
throw std::string ("Can only include files with absolute paths, not '") + included + "'";
|
||||
throw std::string ("Can only include files with absolute paths, not '") + included.data + "'";
|
||||
}
|
||||
else
|
||||
throw std::string ("Malformed entry in ") + file + ": '" + line + "'";
|
||||
|
@ -294,7 +295,8 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Config::createDefaultData (const std::string& data)
|
||||
{
|
||||
if (access (data.c_str (), F_OK))
|
||||
Path p (data);
|
||||
if (! p.exists ())
|
||||
mkdir (data.c_str (), S_IRWXU);
|
||||
}
|
||||
|
||||
|
|
|
@ -121,6 +121,15 @@ bool Path::is_directory () const
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::is_absolute () const
|
||||
{
|
||||
if (data.length () && data.substr (0, 1) == "/")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Path::readable () const
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
std::string extension () const;
|
||||
bool exists () const;
|
||||
bool is_directory () const;
|
||||
bool is_absolute () const;
|
||||
bool readable () const;
|
||||
bool writable () const;
|
||||
bool executable () const;
|
||||
|
|
|
@ -33,7 +33,7 @@ Context context;
|
|||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (26);
|
||||
UnitTest t (31);
|
||||
|
||||
// Path ();
|
||||
Path p0;
|
||||
|
@ -101,6 +101,13 @@ int main (int argc, char** argv)
|
|||
t.ok (out.size () == 1, "/[s-u]mp -> 1 result");
|
||||
t.is (out[0], "/tmp", "/[s-u]mp -> /tmp");
|
||||
|
||||
// bool is_absolute () const;
|
||||
t.notok (p0.is_absolute (), "'' !is_absolute");
|
||||
t.notok (p1.is_absolute (), "foo !is_absolute");
|
||||
t.ok (p2.is_absolute (), "~ is_absolute (after expansion)");
|
||||
t.ok (p3.is_absolute (), "/tmp is_absolute");
|
||||
t.ok (p4.is_absolute (), "/a/b/c/file.ext is_absolute");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue