一个有趣的压缩包a.zip

下载地址:

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

一个有趣的压缩包a.zip》有27个想法

  1. swchzq

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

    回复
  2. Xiaoxia

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

    回复
  3. SunLiveon

    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次

    回复
  4. Kevin125

    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

    耗时很长- -!

    回复
  5. unzip

    @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比啊!!

    回复
  6. John

    参考了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

    回复

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据