{"id":8014,"date":"2011-10-20T21:00:39","date_gmt":"2011-10-20T12:00:39","guid":{"rendered":"http:\/\/www.sssg.org\/blogs\/hiro345\/?p=8014"},"modified":"2011-10-30T15:20:18","modified_gmt":"2011-10-30T06:20:18","slug":"php%e3%81%a7zip%e3%82%92%e5%b1%95%e9%96%8b%e3%81%99%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/8014.html","title":{"rendered":"Windows\u3067\u5727\u7e2e\u3055\u308c\u305fZip\u30d5\u30a1\u30a4\u30eb\u3092Linux\u3067PHP\u3092\u4f7f\u3063\u3066\u5c55\u958b\u3059\u308b\u306b\u306f\uff1f"},"content":{"rendered":"<p>Windows\u3067\u5727\u7e2e\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092Linux\u3067\u5c55\u958b\u3059\u308b\u306b\u306f\u3001\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u3002\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3063\u3066\u3001\u56f0\u3063\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u305b\u3093\u304b\uff1f\u3000\u5c55\u958b\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u3064\u3044\u3066 convmv \u30b3\u30de\u30f3\u30c9\u3067\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u3061\u3087\u3063\u3068\u3057\u305fPHP\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u7528\u610f\u3057\u3066\u5bfe\u5fdc\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<a href=\"\/\/www.sssg.org\/blogs\/hiro345\/archives\/8017.html\">Windows\u3067\u5727\u7e2e\u3055\u308c\u305fZip\u30d5\u30a1\u30a4\u30eb\u3092Linux\u306ePerl\u3067\u5c55\u958b\u3059\u308b\u306b\u306f\uff1f | hiro345<\/a>\u306b\u306fPerl\u7248\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><!--more-->Perl\u3067\u3067\u304d\u308b\u306a\u3089\u3001PHP5\u3067\u3082\u3067\u304d\u308b\u3060\u308d\u3046\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002Java\u3068\u540c\u3058\u3088\u3046\u306a\u611f\u3058\u3067\u30d5\u30a1\u30a4\u30eb\u66f8\u304d\u8fbc\u307f\u307e\u3067\u81ea\u5206\u3067\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u9762\u5012\u306a\u306e\u3067\u30aa\u30ea\u30b8\u30ca\u30eb\u306eZIP\u30d5\u30a1\u30a4\u30eb\u306b\u4fee\u6b63\u304c\u5165\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001ZipArchive\u306erenameName\u3092\u4f7f\u3063\u3066\u5bfe\u5fdc\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: php; gutter: true\">\r\n&lt;?php\r\n&#x24;archive_file&nbsp;=&nbsp;&#x24;argv[1]&#x3b;\r\n&#x24;destination_path&nbsp;=&nbsp;&quot;.&quot;&#x3b;\r\n&#x24;encodeCharset=&quot;UTF&#x2d;8&quot;&#x3b;\r\n&#x24;decodeCharset=&quot;CP932&quot;&#x3b;\r\n\r\n&#x24;zip&nbsp;=&nbsp;new&nbsp;ZipArchive&#x3b;\r\nif&nbsp;(&#x24;zip&#x2d;&gt;open(&quot;&#x24;archive_file&quot;)&nbsp;===&nbsp;TRUE)&nbsp;{\r\n&nbsp;&nbsp;&#x24;index&nbsp;=&nbsp;0&#x3b;\r\n&nbsp;&nbsp;while(&#x24;zip&#x2d;&gt;statIndex(&#x24;index))&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&#x24;zipEntry&nbsp;=&nbsp;&#x24;zip&#x2d;&gt;statIndex(&#x24;index)&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&#x24;zipEntryName&nbsp;=&nbsp;&#x24;zipEntry[&#x27;name&#x27;]&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&#x24;destName&nbsp;=&nbsp;mb_convert_encoding(&#x24;zipEntry[&#x27;name&#x27;],&nbsp;&#x24;encodeCharset,&nbsp;&#x24;decodeCharset)&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&#x24;zipEntryName&nbsp;.&nbsp;&quot;&#x5c;n&quot;&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&#x24;destName&nbsp;.&nbsp;&quot;&#x5c;n&quot;&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&#x24;zip&#x2d;&gt;renameName(&#x24;zipEntryName,&nbsp;&#x24;destName)&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&#x24;zip&#x2d;&gt;extractTo(&#x24;destination_path,&nbsp;&#x24;destName)&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&#x24;zip&#x2d;&gt;renameName(&#x24;destName,&nbsp;&#x24;zipEntryName)&#x3b;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&#x24;index++&#x3b;\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&#x24;zip&#x2d;&gt;close()&#x3b;\r\n}\r\n?&gt;\r\n<\/pre>\n<p>\u4f7f\u3044\u65b9\u306f\u4e0b\u8a18\u306e\u3068\u304a\u308a\u3002PHP\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u30d5\u30a1\u30a4\u30eb\u306funzip.php \u3068\u3044\u3046\u540d\u524d\u3067\u7528\u610f\u3057\u3066\u3042\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<div class=\"code\" style=\"overflow: scroll; width: 490px; white-space: nowrap;background-color:black;color:white;padding:4px;\">\n$ php -f unzip.php sample.zip\n<\/div>\n<p>\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3082\u3069\u3046\u305e\u3002<a href=\"\/\/www.sssg.org\/blogs\/hiro345\/archives\/7973.html\">Windows\u3067\u5727\u7e2e\u3055\u308c\u305fZip\u30d5\u30a1\u30a4\u30eb\u3092Linux\u3067PHP\u3092\u4f7f\u3063\u3066\u5c55\u958b\u3059\u308b\u306b\u306f\uff1f \u305d\u306e2 | hiro345<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows\u3067\u5727\u7e2e\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092Linux\u3067\u5c55\u958b\u3059\u308b\u306b\u306f\u3001\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u3002\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3063\u3066\u3001\u56f0\u3063\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u305b\u3093\u304b\uff1f\u3000\u5c55\u958b\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u3064\u3044\u3066 convmv \u30b3\u30de\u30f3\u30c9\u3067\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059 &hellip; <a href=\"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/8014.html\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[1209,295,593,595],"class_list":["post-8014","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-php","tag-zip","tag-ziparchive"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/8014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=8014"}],"version-history":[{"count":6,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/8014\/revisions"}],"predecessor-version":[{"id":8027,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/8014\/revisions\/8027"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=8014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=8014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=8014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}