/**
* Method to retrieve the current working directory on the FTP server
*
* @return string Current working directory
*
* @since 1.5
*/
public function pwd()
{
// If native FTP support is enabled let's use it...
if (FTP_NATIVE) {
if (($ret = @ftp_pwd($this->_conn)) === false) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_BAD_RESPONSE', __METHOD__), Log::WARNING, 'jerror');
return false;
}
return $ret;
}
$match = array(null);
// Send print working directory command and verify success
if (!$this->_putCmd('PWD', 257)) {
Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_NOT_EXPECTED_RESPONSE', __METHOD__, $this->_response, 257), Log::WARNING, 'jerror');
return false;
}
// Match just the path
preg_match('/"[^"\\r\\n]*"/', $this->_response, $match);
// Return the cleaned path
return preg_replace("/\"/", '', $match[0]);
}