Enhancement - Path, File, Directory integration

- Replaced all access calls.
- Replaced all stat calls.
- Obsoleted util.cpp isAbsoluteDirectory calls.
- Obsoleted util.cpp expandPath calls.
This commit is contained in:
Paul Beckingham 2010-01-16 10:27:31 -05:00
parent 8e47342a18
commit b596e96b43
9 changed files with 66 additions and 120 deletions

View file

@ -33,6 +33,7 @@
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include "Directory.h"
#include "Date.h"
#include "Duration.h"
#include "text.h"
@ -521,13 +522,13 @@ static void parseTask (Task& task, const std::string& after)
void editFile (Task& task)
{
// Check for file permissions.
std::string dataLocation = expandPath (context.config.get ("data.location"));
if (access (dataLocation.c_str (), X_OK))
Directory location (context.config.get ("data.location"));
if (! location.writable ())
throw std::string ("Your data.location directory is not writable.");
// Create a temp file name in data.location.
std::stringstream file;
file << dataLocation << "/task." << getpid () << "." << task.id << ".task";
file << location.data << "/task." << getpid () << "." << task.id << ".task";
// Format the contents, T -> text, write to a file.
std::string before = formatTask (task);