Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
RemoveFile Class Reference
Inheritance diagram for RemoveFile:
Inheritance graph
[legend]
Collaboration diagram for RemoveFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RemoveFile ()
int Parse (char *line)
int Prepare ()
int Execute ()
void Finish (int status)

Private Attributes

const char * mFile
int mSkip

Detailed Description

Definition at line 540 of file updater.cpp.


Constructor & Destructor Documentation

RemoveFile::RemoveFile ( ) [inline]

Definition at line 543 of file updater.cpp.

: mFile(NULL), mSkip(0) { }

Member Function Documentation

int RemoveFile::Execute ( ) [virtual]

Implements Action.

Definition at line 598 of file updater.cpp.

{
  LOG(("EXECUTE REMOVE %s\n", mFile));

  if (mSkip)
    return OK;

  // We expect the file to exist if we are to remove it.  We check here as well
  // as in PREPARE since we might have been asked to remove the same file more
  // than once: bug 311099.
  int rv = access(mFile, F_OK);
  if (rv) {
    LOG(("file cannot be removed because it does not exist; skipping\n"));
    mSkip = 1;
    return OK;
  }

  // save a complete copy of the old file, and then remove the
  // old file.  we'll clean up the copy in Finish.

  rv = backup_create(mFile);
  if (rv) {
    LOG(("backup_create failed: %d\n", rv));
    return rv;
  }

  rv = ensure_remove(mFile);
  if (rv)
    return WRITE_ERROR;

  return OK;
}

Here is the call graph for this function:

void RemoveFile::Finish ( int  status) [virtual]

Implements Action.

Definition at line 632 of file updater.cpp.

{
  LOG(("FINISH REMOVE %s\n", mFile));

  if (mSkip)
    return;

  backup_finish(mFile, status);
}

Here is the call graph for this function:

int RemoveFile::Parse ( char *  line) [virtual]

Implements Action.

Definition at line 556 of file updater.cpp.

{
  // format "<deadfile>"

  mFile = mstrtok(kQuote, &line);
  if (!mFile)
    return PARSE_ERROR;

  return OK;
}

Here is the call graph for this function:

int RemoveFile::Prepare ( ) [virtual]

Implements Action.

Definition at line 568 of file updater.cpp.

{
  LOG(("PREPARE REMOVE %s\n", mFile));

  // We expect the file to exist if we are to remove it.
  int rv = access(mFile, F_OK);
  if (rv) {
    LOG(("file cannot be removed because it does not exist; skipping\n"));
    mSkip = 1;
    return OK;
  }

  char *slash = (char *) strrchr(mFile, '/');
  if (slash) {
    *slash = '\0';
    rv = access(mFile, W_OK);
    *slash = '/';
  } else {
    rv = access(".", W_OK);
  }

  if (rv) {
    LOG(("access failed: %d\n", errno));
    return WRITE_ERROR;
  }

  return OK;
}

Member Data Documentation

const char* RemoveFile::mFile [private]

Definition at line 551 of file updater.cpp.

Definition at line 552 of file updater.cpp.


The documentation for this class was generated from the following file: