Home » File Formats » Archive_Tar » Bug #8114
Files added on-the-fly not storing date
Details
| Submitted | 2006-07-04 14:20 UTC |
|---|---|
| From | jfernandez at electronic-group dot com |
| Assigned | vblavet |
| Status | Closed |
| Package | Archive_Tar |
| PHP Version | 4.4.1 |
| OS | RHEL |
| Roadmaps | (Not assigned) |
Comments
[2006-07-04 14:20 UTC] jfernandez at electronic-group dot com
Description:
------------
Whenever a tar file is created on-the-fly and some files are stored in by using the addString method, neither the date nor any permissions are stored for each inserted file.
This is a patch that makes those files to be created with the system timestamp and with permissions of rw-r----
Test script:
---------------
--- Tar.php 2005-03-17 22:02:31.000000000 +0100
+++ TarModif.php 2006-07-04 16:15:20.000000000 +0200
@@ -973,7 +973,7 @@
$p_filename = $this->_translateWinPath($p_filename, false);;
if (!$this->_writeHeaderBlock($p_filename, strlen($p_string),
- 0, 0, "", 0, 0))
+ time (), 438 - umask (), "", 0, 0))
return false;
$i=0;
Expected result:
----------------
The files created from memory have timestamps and permissions set.
[2006-09-01 21:17 UTC] adam at pilorz dot net
Sometimes (I have such situation in my script) it is better, when you can specify the date yourself. I've made a modification, which allows you do that. This patch allow you to specify the date in third parameter, and when the date is not specified, it uses the current timestamp. It is modified version of patched (with Juan Fernández-Rebollos's patch) Tar.php (the diff from original Tar.php)
As the file is a bit bigger than original patch I have uploaded it on my server. It is available at http://adam.pilorz.net/files/tar.php.patch