Permalink
Browse files

Request #11258 - allow setting of custom date/time

  • Loading branch information...
1 parent 205c354 commit f536af75b70308f4ccd6718073992e6481f34cd8 @mrook mrook committed Nov 12, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 Archive/Tar.php
View
@@ -407,11 +407,13 @@ function addModify($p_filelist, $p_add_dir, $p_remove_dir='')
* with the string.
* @param string $p_string The content of the file added in
* the archive.
+ * @param int $p_datetime A custom date/time (unix timestamp)
+ * for the file (optional).
*
* @return true on success, false on error.
* @access public
*/
- function addString($p_filename, $p_string)
+ function addString($p_filename, $p_string, $p_datetime = false)
{
$v_result = true;
@@ -426,7 +428,7 @@ function addString($p_filename, $p_string)
return false;
// Need to check the get back to the temporary file ? ....
- $v_result = $this->_addString($p_filename, $p_string);
+ $v_result = $this->_addString($p_filename, $p_string, $p_datetime);
$this->_writeFooter();
@@ -1050,7 +1052,7 @@ function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir)
// }}}
// {{{ _addString()
- function _addString($p_filename, $p_string)
+ function _addString($p_filename, $p_string, $p_datetime = false)
{
if (!$this->_file) {
$this->_error('Invalid file descriptor');
@@ -1064,9 +1066,14 @@ function _addString($p_filename, $p_string)
// ----- Calculate the stored filename
$p_filename = $this->_translateWinPath($p_filename, false);;
+
+ // ----- If datetime is not specified, set current time
+ if ($p_datetime === false) {
+ $p_datetime = time();
+ }
if (!$this->_writeHeaderBlock($p_filename, strlen($p_string),
- time(), 384, "", 0, 0))
+ $p_datetime, 384, "", 0, 0))
return false;
$i=0;

0 comments on commit f536af7

Please sign in to comment.