/** * Sets this header with the values from the ezcArchiveEntry $entry. * * The values that are possible to set from the ezcArchiveEntry $entry are set in this header. * The properties that may change are: fileName, fileMode, userId, groupId, fileSize, modificationTime, * linkName, and type. * * @param ezcArchiveEntry $entry * @return void */ public function setHeaderFromArchiveEntry(ezcArchiveEntry $entry) { $this->splitFilePrefix($entry->getPath(false), $file, $filePrefix); $this->fileName = $file; $this->filePrefix = $filePrefix; $this->fileMode = $entry->getPermissions(); $this->userId = $entry->getUserId(); $this->groupId = $entry->getGroupId(); $this->fileSize = $entry->getSize(); $this->modificationTime = $entry->getModificationTime(); $this->linkName = $entry->getLink(false); switch ($entry->getType()) { case ezcArchiveEntry::IS_FILE: $this->type = 0; break; case ezcArchiveEntry::IS_LINK: $this->type = 1; break; case ezcArchiveEntry::IS_SYMBOLIC_LINK: $this->type = 2; break; case ezcArchiveEntry::IS_CHARACTER_DEVICE: $this->type = 3; break; case ezcArchiveEntry::IS_BLOCK_DEVICE: $this->type = 4; break; case ezcArchiveEntry::IS_DIRECTORY: $this->type = 5; break; case ezcArchiveEntry::IS_FIFO: $this->type = 6; break; // Devices, etc are set to \0. // Devices, etc are set to \0. default: $this->type = ""; break; // ends up as a \0 character. } $this->deviceMajorNumber = $entry->getMajor(); $this->deviceMinorNumber = $entry->getMinor(); $length = strlen($this->fileName); if ($entry->getType() == ezcArchiveEntry::IS_DIRECTORY) { // Make sure that the filename ends with a slash. if ($this->fileName[$length - 1] != "/") { $this->fileName .= "/"; } } else { if ($this->fileName[$length - 1] == "/") { $this->fileName = substr($this->fileName, 0, -1); // Remove last character. } } }
/** * Sets this header with the values from the ezcArchiveEntry $entry. * * The values that are possible to set from the ezcArchiveEntry $entry are set in this header. * The properties that change are: internalFileAttributes, relativeHeaderOffset, type, and mtime. * * @param ezcArchiveEntry $entry * @return void */ public function setHeaderFromArchiveEntry(ezcArchiveEntry $entry) { $this->properties["internalFileAttributes"] = 0; $this->setType($entry->getType()); $this->setPermissions($entry->getPermissions()); $this->properties["relativeHeaderOffset"] = 0; $this->properties["mtime"] = $entry->getModificationTime(); }
/** * Sets this header with the values from the ezcArchiveEntry $entry. * * The values that are possible to set from the ezcArchiveEntry $entry are set in this header. * The properties that may change are: fileName, fileMode, userId, groupId, fileSize, modificationTime, * linkName, and type. * * @param ezcArchiveEntry $entry * @return void */ public function setHeaderFromArchiveEntry(ezcArchiveEntry $entry) { $this->fileName = $entry->getPath(false); $this->fileMode = $entry->getPermissions(); $this->userId = $entry->getUserId(); $this->groupId = $entry->getGroupId(); $this->fileSize = $entry->getSize(); $this->modificationTime = $entry->getModificationTime(); $this->linkName = $entry->getLink(false); switch ($entry->getType()) { case ezcArchiveEntry::IS_FILE: $this->type = ""; break; // ends up as a \0 character. // ends up as a \0 character. case ezcArchiveEntry::IS_LINK: $this->type = 1; break; case ezcArchiveEntry::IS_SYMBOLIC_LINK: $this->type = 2; break; case ezcArchiveEntry::IS_DIRECTORY: $this->type = 5; break; // Devices, etc are set to \0. // Devices, etc are set to \0. default: $this->type = ""; break; // ends up as a \0 character. } $length = strlen($this->fileName); if ($entry->getType() == ezcArchiveEntry::IS_DIRECTORY) { // Make sure that the filename ends with a slash. if ($this->fileName[$length - 1] != "/") { $this->fileName .= "/"; } } else { if ($this->fileName[$length - 1] == "/") { $this->fileName = substr($header->fileName, 0, -1); // Remove last character. } } }