在php中检查jar文件是否已损坏?(Check jar file is corrupted or not in php?)
我正在使用函数exec()执行jar文件:
但是我需要检查jar文件是否已损坏或使用php函数。
I am executing jar file through php using function exec();
However i need to check whether jar file corrupted or not using php function.
最满意答案
你可以使用zip检查损坏的jar,因为jar文件是一个压缩文件,所以这会给你一个想法:
$myfile = '/my/jar/file.jar'; $zip = new ZipArchive(); $res = $zip->open($myfile, ZipArchive::CHECKCONS); if ($res !== TRUE) { switch($res) { case ZipArchive::ER_NOZIP: die('not a zip archive'); case ZipArchive::ER_INCONS : die('consistency check failed'); case ZipArchive::ER_CRC : die('checksum failed'); default: die('error ' . $res); } }要使用zip文件,您需要安装php zip扩展
You can check for corrupted jar using zip because the jar file is a zipped file, so this will give you an idea:
$myfile = '/my/jar/file.jar'; $zip = new ZipArchive(); $res = $zip->open($myfile, ZipArchive::CHECKCONS); if ($res !== TRUE) { switch($res) { case ZipArchive::ER_NOZIP: die('not a zip archive'); case ZipArchive::ER_INCONS : die('consistency check failed'); case ZipArchive::ER_CRC : die('checksum failed'); default: die('error ' . $res); } }For working with zip files you will need to install the php zip extension
更多推荐
jar,php,exec,函数,使用,电脑培训,计算机培训,IT培训"/> <meta name="descriptio
发布评论