2

Why can't I unlink the tar file that I created via PharData?

try
{
    $a = new PharData('archive.tar');

    // ADD FILES TO archive.tar FILE
    $a->addFile('manifest.json');

}
catch (Exception $e)
{
    echo "Exception : " . $e;
}

//Now compress to tar.gz
file_put_contents('archive.tgz' , gzencode(file_get_contents('archive.tar')));

chmod('archive.tar', 0777);
unlink('archive.tar');

Error,

Warning: unlink(archive.tar): Permission denied in C:...

I have forced the tar file to 777 but it still does not work.

Any ideas?

Run
  • 54,938
  • 169
  • 450
  • 748

1 Answers1

1

Try using Phar::unlinkArchive(); After removing all references to your archive:

unset($a);
Phar::unlinkArchive('archive.tar');

Note: I think Phar provides a method to compress an archive:

$a->compress(Phar::GZ)
Sciid
  • 39
  • 1
  • 10