note 101883 added to function.filesize

From: Date: Sun, 16 Jan 2011 02:19:41 +0000
Subject: note 101883 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-175793@lists.php.net to get a copy of this message
I have a cli script running that use the filesize function on a ssh2_sftp connection. It has the >2Gb limit issue, while it does not have that issue locally. I have managed to get around this by doing a "du -sb" command through ssh2_shell. The following function takes the ssh2_connect resource and the path as input. It may not be neat, but it solves the problem for the moment. function fSSHFileSize($oConn, $sPath) { if(false !== ($oShell = @ssh2_shell($oConn, 'xterm', null, 500, 24, SSH2_TERM_UNIT_CHARS))) { fwrite($oShell, "du -sb '".$sPath."'".PHP_EOL); sleep(1); while($sLine = fgets($oShell)) { flush(); $aResult[] = $sLine; } fclose($oShell); $iSize = 0; if(count($aResult) > 1) { $sTemp = $aResult[count($aResult)-2]; $sSize = substr($sTemp, 0, strpos($sTemp, chr(9))); if(is_numeric(trim($sSize))) { $iTemp = (int)$sSize; if($iTemp > "2000000000") $iSize = $iTemp; } } return $iSize; } return 0; } ---- Server IP: 195.139.129.18 Probable Submitter: 84.215.34.167 ---- Manual Page -- http://www.php.net/manual/en/function.filesize.php Edit -- https://master.php.net/note/edit/101883 Del: integrated -- https://master.php.net/note/delete/101883/integrated Del: useless -- https://master.php.net/note/delete/101883/useless Del: bad code -- https://master.php.net/note/delete/101883/bad+code Del: spam -- https://master.php.net/note/delete/101883/spam Del: non-english -- https://master.php.net/note/delete/101883/non-english Del: in docs -- https://master.php.net/note/delete/101883/in+docs Del: other reasons-- https://master.php.net/note/delete/101883 Reject -- https://master.php.net/note/reject/101883 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175793) next »