mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-25 03:16:02 +00:00
SFTP: add enableDatePreservation() / disableDatePreservation()
This commit is contained in:
parent
d077c7b296
commit
ea653e1b01
@ -300,6 +300,16 @@ class Net_SFTP extends Net_SSH2
|
||||
*/
|
||||
var $requestBuffer = array();
|
||||
|
||||
/**
|
||||
* Preserve timestamps on file downloads / uploads
|
||||
*
|
||||
* @see self::get()
|
||||
* @see self::put()
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $preserveTime = false;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
@ -2136,6 +2146,11 @@ class Net_SFTP extends Net_SSH2
|
||||
}
|
||||
|
||||
if ($mode & NET_SFTP_LOCAL_FILE) {
|
||||
if ($this->preserveTime) {
|
||||
$stat = fstat($fp);
|
||||
$this->touch($remote_file, $stat['mtime'], $stat['atime']);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
@ -2353,6 +2368,11 @@ class Net_SFTP extends Net_SSH2
|
||||
|
||||
if ($fclose_check) {
|
||||
fclose($fp);
|
||||
|
||||
if ($this->preserveTime) {
|
||||
$stat = $this->stat($remote_file);
|
||||
touch($local_file, $stat['mtime'], $stat['atime']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->_close_handle($handle)) {
|
||||
@ -3237,4 +3257,24 @@ class Net_SFTP extends Net_SSH2
|
||||
$this->pwd = false;
|
||||
parent::_disconnect($reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Date Preservation
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function enableDatePreservation()
|
||||
{
|
||||
$this->preserveTime = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable Date Preservation
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function disableDatePreservation()
|
||||
{
|
||||
$this->preserveTime = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user