Bug - File open issue

- If a file (pending.data) is open and locked, trying to open it again
  caused an error, whereas is now does nothing and reports success.
- Corrected timing info in Command::filter.
This commit is contained in:
Paul Beckingham 2011-08-14 21:23:01 -04:00
parent e403574c34
commit ad38d5b92e
2 changed files with 20 additions and 17 deletions

View file

@ -111,20 +111,25 @@ bool File::remove ()
////////////////////////////////////////////////////////////////////////////////
bool File::open ()
{
if (data != "" && fh == NULL)
if (data != "")
{
bool already_exists = exists ();
if (already_exists)
if (!readable () || !writable ())
throw std::string (format (STRING_FILE_PERMS, data));
fh = fopen (data.c_str (), (already_exists ? "r+" : "w+"));
if (fh)
if (! fh)
{
h = fileno (fh);
locked = false;
return true;
bool already_exists = exists ();
if (already_exists)
if (!readable () || !writable ())
throw std::string (format (STRING_FILE_PERMS, data));
fh = fopen (data.c_str (), (already_exists ? "r+" : "w+"));
if (fh)
{
h = fileno (fh);
locked = false;
return true;
}
}
else
return true;
}
return false;