mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Path Integration
- Replaced calls to ::access
This commit is contained in:
parent
5dbadda512
commit
c02cfd594c
1 changed files with 9 additions and 7 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 (expandPath (trim (line.substr (include + 7), " \t")));
|
||||
if (isAbsolutePath (included.data))
|
||||
{
|
||||
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 + "'";
|
||||
|
@ -293,7 +294,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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue