Skip to content

Commit

Permalink
Request #11258 - allow setting of custom date/time
Browse files Browse the repository at this point in the history
  • Loading branch information
mrook committed Nov 12, 2012
1 parent 205c354 commit f536af7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Archive/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();

Expand Down Expand Up @@ -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');
Expand All @@ -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;
Expand Down

0 comments on commit f536af7

Please sign in to comment.