You are here

public function ArchiveTar::setAttribute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Archiver/ArchiveTar.php \Drupal\Core\Archiver\ArchiveTar::setAttribute()

This method set specific attributes of the archive. It uses a variable list of parameters, in the format attribute code + attribute values : $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ',');

Return value

true on success, false on error.

File

core/lib/Drupal/Core/Archiver/ArchiveTar.php, line 704

Class

ArchiveTar

Namespace

Drupal\Core\Archiver

Code

public function setAttribute() {
  $v_result = true;

  // ----- Get the number of variable list of arguments
  if (($v_size = func_num_args()) == 0) {
    return true;
  }

  // ----- Get the arguments
  $v_att_list =& func_get_args();

  // ----- Read the attributes
  $i = 0;
  while ($i < $v_size) {

    // ----- Look for next option
    switch ($v_att_list[$i]) {

      // ----- Look for options that request a string value
      case ARCHIVE_TAR_ATT_SEPARATOR:

        // ----- Check the number of parameters
        if ($i + 1 >= $v_size) {
          $this
            ->_error('Invalid number of parameters for ' . 'attribute ARCHIVE_TAR_ATT_SEPARATOR');
          return false;
        }

        // ----- Get the value
        $this->_separator = $v_att_list[$i + 1];
        $i++;
        break;
      default:
        $this
          ->_error('Unknown attribute code ' . $v_att_list[$i] . '');
        return false;
    }

    // ----- Next attribute
    $i++;
  }
  return $v_result;
}