0 字节文件

Zero Byte File

综合以下两篇文章的总结:

1、概念:0 字节文件是指在电脑上一个文件 包含真正 0 个字节的文件。一般文件都不大可能是 0 字节,因为,一个文件都会拥有一些属性来描述这个文件:如文件名、文件访问的模式和一些扩展属性。所有的这些属性都是需要空间来存储,所以会占一定的字节。一个文件可能包含的内容为 0字节,但是真正本身的大小一般不可能是 0 字节。

2、产生的原因:可能是一个应用程序创建了一个文件,但是当往文件中写内容时,程序被永久地中断或者退出了。因为,这些要写的内容先是缓存在内存中的,然后通过 flush 命令刷新缓存区,将写的内容刷到文件中,如果程序没将写的内容 flush 到文件中,那么就会出现 0 字节 文件。

3、目的:有时候可以通过 0 字节 文件来传递信息。我们可以使用文件名而不是往文件中写信息来传递简单的信息。例子在维基百科的段中有体现。

From 维基百科

  • A zero byte file or zero length file is a computer file containing no data; that is, it has a length or size of zero bytes.

  • Zero byte files cannot be loaded or used by most applications. Even a file describing an empty word processor document, an image file with zero by zero dimensions, or an audio file of length zero seconds usually still contains metadata identifying the file format and describing some basic attributes of the file. Some very simple file formats do not use metadata, such as ASCII text files; these may validly be zero bytes.

  • Zero byte files may arise in cases where a program creates a file but aborts or is interrupted prematurely while writing to it. Because writes are cached in memory and only flushed to disk at a later time (page cache), a program that does not flush its writes to disk or terminate normally may result in a zero byte file.

  • In some cases zero byte files may be used to convey information using file metadata (for example, its filename may contain an instruction to a user viewing a directory listing); or to ensure that a directory is nonempty, since some tools such as backup and revision control software treat empty directories differently from nonempty ones.

For example: 下面两个文件就是用来传递信息的(这两个文件均为 0 字节文件)

the-file-you-were-looking-for-has-been-moved-to-partition-D.txt
if-this-file-is-here-something-broke-in-the-last-run.txt


From wiseGEEK

  • 产生的原因:A zero byte file is a data file on a computer system, hard drive or other storage device that has an actual length of zero bytes. In many cases, a zero byte file is created because of an error — such as an interrupted network transfer, software crash or improperly written file handling routine — during the creation of a file. Other times, a zero byte file is created intentionally to send a message to a user viewing a file directory, to reserve a directory or filename to control automatic processes, or to indicate some immediate state or information to a program. There is a technical difference between a zero byte file whose file size is actually zero bytes and a file that contains no generated data, such as a document file with no textual content that still could contain metadata or other information from the program that created it. Occasionally, especially when a zero length file is created through an error, deleting a zero byte file can be very difficult because the corrupted file prevents the operating system from directly manipulating the file.

  • 文件的组成:Within a file system for a computer or other device, files have certain attributes — such as their name, extension and access properties — that are maintained by the operating system. The information the file contains beyond that is stored as bytes and can be counted to determine the size of a file. Most files contain some information, because creating a file is not always a trivial task. It is possible, however, for a file to be created within an operating system so it has a name and attributes but contains no data, making it a zero byte file.

  • 如何创建一个文件:Creating and writing information to a file on a storage device is a process that takes multiple steps to complete. In some cases, this process can be interrupted or not completed, leaving a file that does not contain any data. One common cause of this involves caching, a procedure operating systems use to collect a large amount of data in random access memory (RAM) before activating the physical storage device to perform the more time-consuming task of physically encoding and storing the information. The cache for data is not always automatically written to a file — a function called flushing — so a file can be created and then the cache not flushed, so the data is never physically written and an empty file is left. The same concept as flushing a cache during file creation can occur when data is being transmitted over a network, such as while downloading a file from the Internet. If the data transfer is not completed, then the information might never be written to the storage drive, leaving a zero byte file behind. Other causes for a zero length file include physical errors on a disk that prevent data from being written and corrupted file allocation table information that leaves zero length artifacts that are not really files.

  • 创建 0 字节的目的:A zero byte file sometimes can be created intentionally. This can be done to leave a message for a user by using the name of the file as opposed to storing information inside. They also are used as placeholders to indicate that a particular process, such as installation or registration, has been performed. A zero length file also sometimes can be made by a program that intends to write information but then receives nothing to write, leaving an empty file.



转载于:https://my.oschina.net/mopidick/blog/264126

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值