Skip to content

Commit

Permalink
Merge pull request #22 from PHPOffice/develop
Browse files Browse the repository at this point in the history
Release 0.2.8
  • Loading branch information
Progi1984 authored Jul 12, 2018
2 parents d5992c9 + d489595 commit 028970e
Show file tree
Hide file tree
Showing 17 changed files with 642 additions and 155 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ php:
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

matrix:
allow_failures:
- php: 7.1
- php: 7.2
- php: hhvm

env:
Expand Down
13 changes: 0 additions & 13 deletions src/Common/Adapter/Zip/PclZipAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,18 @@ class PclZipAdapter implements ZipInterface
*/
protected $tmpDir;

/**
* @param $filename
* @return $this
*/
public function open($filename)
{
$this->oPclZip = new PclZip($filename);
$this->tmpDir = sys_get_temp_dir();
return $this;
}

/**
* @return $this
*/
public function close()
{
return $this;
}

/**
* @param $localname
* @param $contents
* @return $this
* @throws \Exception
*/
public function addFromString($localname, $contents)
{
$pathData = pathinfo($localname);
Expand Down
20 changes: 5 additions & 15 deletions src/Common/Adapter/Zip/ZipArchiveAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ class ZipArchiveAdapter implements ZipInterface
*/
protected $filename;

/**
* @param string $filename
* @throws \Exception Could not open $this->filename for writing.
* @return mixed
*/
public function open($filename)
{
$this->filename = $filename;
Expand All @@ -35,10 +30,6 @@ public function open($filename)
throw new \Exception("Could not open $this->filename for writing.");
}

/**
* @return $this
* @throws \Exception Could not close zip file $this->filename.
*/
public function close()
{
if ($this->oZipArchive->close() === false) {
Expand All @@ -47,13 +38,12 @@ public function close()
return $this;
}

/**
* @param $localname
* @param $contents
* @return bool
*/
public function addFromString($localname, $contents)
{
return $this->oZipArchive->addFromString($localname, $contents);
if ($this->oZipArchive->addFromString($localname, $contents) === false) {
throw new \Exception("Error zipping files : " . $localname);
}

return $this;
}
}
20 changes: 20 additions & 0 deletions src/Common/Adapter/Zip/ZipInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@

interface ZipInterface
{
/**
* Open a ZIP file archive
* @param string $filename
* @return $this
* @throws \Exception
*/
public function open($filename);

/**
* Close the active archive (opened or newly created)
* @return $this
* @throws \Exception
*/
public function close();

/**
* Add a file to a ZIP archive using its contents
* @param string $localname The name of the entry to create.
* @param string $contents The contents to use to create the entry. It is used in a binary safe mode.
* @return $this
* @throws \Exception
*/
public function addFromString($localname, $contents);
}
10 changes: 5 additions & 5 deletions src/Common/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public static function fileExists($pFilename)
$zip->close();

return $returnValue;
} else {
return false;
}
} else {
// Regular file_exists
return file_exists($pFilename);

return false;
}

// Regular file_exists
return file_exists($pFilename);
}
/**
* Returns the content of a file
Expand Down
34 changes: 17 additions & 17 deletions src/Common/Microsoft/OLERead.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,26 @@ public function getStream($stream)
}

return $streamData;
} else {
$numBlocks = $this->props[$stream]['size'] / self::BIG_BLOCK_SIZE;
if ($this->props[$stream]['size'] % self::BIG_BLOCK_SIZE != 0) {
++$numBlocks;
}
}

if ($numBlocks == 0) {
return '';
}
$numBlocks = $this->props[$stream]['size'] / self::BIG_BLOCK_SIZE;
if ($this->props[$stream]['size'] % self::BIG_BLOCK_SIZE != 0) {
++$numBlocks;
}

$block = $this->props[$stream]['startBlock'];
if ($numBlocks == 0) {
return '';
}

while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::getInt4d($this->bigBlockChain, $block*4);
}
$block = $this->props[$stream]['startBlock'];

return $streamData;
while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::getInt4d($this->bigBlockChain, $block*4);
}

return $streamData;
}

/**
Expand Down Expand Up @@ -259,10 +259,10 @@ private function readPropertySets()
'type' => $type,
'startBlock' => $startBlock,
'size' => $size);

// tmp helper to simplify checks
$upName = strtoupper($name);

switch ($upName) {
case 'ROOT ENTRY':
case 'R':
Expand Down
Loading

0 comments on commit 028970e

Please sign in to comment.