Page 1 of 1

How to compress files with a size of zero bytes using winrar

Posted: 29 Jan 2015 05:54
by hacker
Hi

I have several files with a size of zero bytes that I want to compress them using compression tools. So that the files compressed with the same amount of current (current size:0 byte).
Please suggest a solution that solve my problem.

thanks in advance

Re: How to compress files with a size of zero bytes using wi

Posted: 29 Jan 2015 06:41
by dbenham
The "compressed" version of a 0 length file cannot be 0 because it must contain the name (and possibly the full path) of the file :!:

The original file has length 0 because the name (and path) is separate from the file itself.

This leads me to question something I never thought about before - How does the OS handle directory information with regard to reporting disk usage :?:


Dave Benham

Re: How to compress files with a size of zero bytes using wi

Posted: 29 Jan 2015 08:11
by Squashman
dbenham wrote:This leads me to question something I never thought about before - How does the OS handle directory information with regard to reporting disk usage :?:
Dave Benham

That is an intriguing thought. You would think it has to take up at least a couple of bits bytes just to catalog the file name in the file system.

I think we could test this theory just by creating a couple of zero byte files with really long file names. Then check the disk usage.

Re: How to compress files with a size of zero bytes using wi

Posted: 29 Jan 2015 08:16
by Squashman
hacker wrote:Hi

I have several files with a size of zero bytes that I want to compress them using compression tools. So that the files compressed with the same amount of current (current size:0 byte).
Please suggest a solution that solve my problem.

thanks in advance

If you open a compressed file in a hex viewer you will see some header information. As Dave pointed out to, it shows the original file name that it compressed.

Code: Select all

00000000  50 4B 03 04 0A 00 00 00 00 00 E9 40 3D 46 00 00    PK........é@=F..
00000010  00 00 00 00 00 00 00 00 00 00 0C 00 00 00 7A 65    ..............ze
00000020  72 6F 62 79 74 65 2E 74 78 74 50 4B 01 02 14 00    robyte.txtPK....
00000030  0A 00 00 00 00 00 E9 40 3D 46 00 00 00 00 00 00    ......é@=F......
00000040  00 00 00 00 00 00 0C 00 24 00 00 00 00 00 00 00    ........$.......
00000050  20 00 00 00 00 00 00 00 7A 65 72 6F 62 79 74 65     .......zerobyte
00000060  2E 74 78 74 0A 00 20 00 00 00 00 00 01 00 18 00    .txt.. .........
00000070  A0 8D B9 E3 CC 3B D0 01 A0 8D B9 E3 CC 3B D0 01     ¹ãÌ;Ð. ¹ãÌ;Ð.
00000080  A0 8D B9 E3 CC 3B D0 01 50 4B 05 06 00 00 00 00     ¹ãÌ;Ð.PK......
00000090  01 00 01 00 5E 00 00 00 2A 00 00 00 00 00          ....^...*..... 


The PK is the initials of the creator of the zip file format. Phil Katz.

Re: How to compress files with a size of zero bytes using wi

Posted: 02 Feb 2015 10:58
by Samir
Squashman wrote:The PK is the initials of the creator of the zip file format. Phil Katz.
And PKware's headquarters a just a short drive from me. Ran into it by accident when I saw this building with a 'PKWARE' on it, but looked just like the non-chalant name of a building. It got me wondering, and after a quick Internet search, low-and-behold the building is the Pkware world headquarters. :shock:

Re: How to compress files with a size of zero bytes using wi

Posted: 02 Feb 2015 16:05
by foxidrive
Squashman wrote:That is an intriguing thought. You would think it has to take up at least a couple of bits bytes just to catalog the file name in the file system.


In the FAT file system you could create zero byte files and it would use no disk space, until an extra cluster was needed to expand the table because it used the last entry in the current block.

I don't know how the NTFS handles it though...

Re: How to compress files with a size of zero bytes using wi

Posted: 02 Feb 2015 19:49
by Ed Dyreen
dBenham wrote:This leads me to question something I never thought about before - How does the OS handle directory information with regard to reporting disk usage :?:
like FAT NTFS uses the Master File Table (MFT) to store metadata ( name, size, acces rights, directory structure, .. ).