Xiaoxia[PG]

一个有趣的压缩包a.zip

我的代码27 条评论

下载地址:

http://blog.xiaoxia.org/upfiles/a.zip

不知道谁那么无聊,做个这么好玩的东东。像潘多拉的盒子,里面是另外一个世界。解压a.zip之后得到b.zip,解压b.zip之后得到a.zip,,,,解压到尽头,一定会有惊喜!

出于好奇,想揭开里面的秘密,写了个php脚本来解压文件。

注意,代码很烂,心脏不好的人勿看。

<?php
$a = "./a.zip";
$b = "./b.zip";

$t = "b";
$s = 1000000;
$i = 1;
while(1){
        if($t=="a"){
                if(filesize($b)<$s){
                        system("unzip -o {$b}");
                        $t="b";
                        $s = filesize($b);
                }else break;
        }else{
                if(filesize($a)<$s){
                        system("unzip -o {$a}");
                        $t="a";
                        $s = filesize($a);
                }else break;
        }
	print "unzipping ".$t." ".$i." times\n";

        $i++;
}
?>
执行该脚本:
 
xiaoxia@VMNAME:~/test$ time php -ftest.php > tmp

real    0m4.715s
user    0m2.240s
sys     0m2.450s
 
xiaoxia@VMNAME:~/test$ tail tmp
Archive:  ./a.zip
  inflating: b.zip
unzipping a 995 times
Archive:  ./a.zip
  inflating: b.zip
unzipping a 996 times
Archive:  ./b.zip
  inflating: a.zip
unzipping b 997 times
 

据统计,一共进行了997次解压。可能原始文件压缩了999或者1000次,后来该文件被人工解压了几次。耗时4.7秒。使用机器配置的CPU为2.4GHz的Xeon:

xiaoxia@VMNAME:~/test$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Xeon(R) CPU           X3220  @ 2.40GHz
stepping        : 11
cpu MHz         : 2393.998
cache size      : 4096 KB
 

解压到最后,得到一个img.jpg。打开下面的链接可以看到内容:

http://blog.xiaoxia.org/images/10/img.jpg

另外,我也好奇使用一张有趣的个人肖像照片制作了一个压缩包,有兴趣的朋友可以试一试解压它。

原始文件大小为13068字节,压缩后多次后为684193字节,压缩用时3分钟。

下载地址 http://blog.xiaoxia.org/upfiles/test1w.zip

27 条评论

  1. 对个人肖像感兴趣~!

  2. 我想知道是谁的肖像
    不是你的 那就没兴趣了

  3. 😀 是我的哦!!!真的很有趣哦!!!

  4. 用gzip呀,程序编好了,开始解压...

  5. 靠,实在有趣,害我抱着希望解压了一段时间...
    居然有一块神秘的黑色物体挡在小虾的脸颊前....

  6. 恭喜ls!
    忘了说,照片部分打码了。。。

  7. 真是'不清晰有码PP'...

  8. 压缩次数大概(没写计数,估计的...):10156次,请勿准确的是多少

  9. 10000次吧。我解压用了1分钟。代码如下:
    <?php
    $i=0;
    while(file_exists("./test")){
    system("mv ./test ./test.gz");
    system("gunzip test.gz");
    print " ".$i++;
    }
    ?>

  10. 确实有够无聊的哎 lol

    可以做个解压一次的算法的话就很强了

  11. :(我写个VBS调用haozip耗时900+

  12. python a.zip 0.8s test1w.zip 17s....
    小虾居然发有码图...我伤心了

  13. D:\Works\C++\zlibtest\bin\Release>ZlibTest.exe
    iter: 10000, size: 13068, time: 5740

  14. C++。。。
    膜拜5740毫秒!!!

  15. 无聊python了个,7458ms

  16. perl 加7zip 3m36s
    #! /bin/perl
    while(-e "./test.zip"){

    system("mv test.zip a.zip");

    system("7z -y x a.zip");

    system("rm a.zip");

    print $i++;

    }

    竟然10000次

  17. 用winrar手点出来了,耗时30分钟。

  18. 楼上毅力帝!

  19. 支持半小时的牛人·

  20. if exist a.zip goto a
    :a
    winrar e -o+ a.zip
    del a.zip
    if exist b.zip goto b
    goto end
    :b
    winrar e -o+ b.zip
    del b.zip
    if exist a.zip goto a
    goto end
    :end
    pause

    耗时很长- -!

  21. 有什么好方法制作这类压缩包?

  22. 好方法是,写个脚本,写一个循环调用压缩命令。。。

  23. 那样也太慢了……

  24. 其实也不慢吧。。。看你压缩多少次,和压缩文件的体积。。。

  25. @echo on
    winrar x a.zip -y
    del a.zip /f /s /q
    winrar x b.zip -y
    del b.zip
    call r.bat /f /s /q

    所有人都可以看懂的,不确定用了多久,没去测试!咱在P3 800上速度不能和xeon比啊!!

  26. 参考了unzip和Kevin125增加后台解压开关“-ibck”因为实在是看不下去

    @echo off&setlocal enabledelayedexpansion

    title 解压a.zip和b.zip

    set a=0

    if exist a.zip goto a
    if exist b.zip goto b
    :end
    echo 一共解压了 !a! 次
    echo 请按任意键退出...
    pause>nul
    exit

    :a
    set /a a+=1
    WinRAR.exe x -y -ibck a.zip
    del /f /s /q a.zip
    if exist b.zip goto b
    goto end

    :b
    set /a a+=1
    WinRAR.exe x -y -ibck b.zip
    del /f /s /q b.zip
    if exist a.zip goto a
    goto end

发表评论

评论会经过自动审核,链接请勿超过 3 个。