EOF实际上存在吗? [英] Does EOF actually exist?

查看:70
本文介绍了EOF实际上存在吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在PHP中使用文件功能时,我会检查EOF。我想知道EOF是否确实存在于文件中。当我创建一个空的文本文件时,它将显示0KB。 EOF在具有0KB的文件中如何存在?

When I use file functions in PHP, I check for EOF. I wonder if EOF actually exist in a file. When I create an empty text file, it displays 0KB. How does EOF exist in a file with 0KB?

推荐答案

文件尾有控制字符(ASCII字符)设置为CTRL + Z或26或0x1A),但自从80年代发布操作系统以来,实际上并不需要它来标记文件的结尾。所有现代的操作系统都将文件大小作为元数据存储在目录结构中(确切格式取决于文件系统),高级文件访问功能将检查文件大小,以决定何时向程序员(即程序员)指示EOF。

There is an end-of-file control character (in the ASCII character set it's CTRL+Z or 26 or 0x1A), but it hasn't actually been needed to mark the end of a file since OSes released in the 80's. All modern OSes store the file size as metadata in the directory structure (exact format depends on filesystem) and high level file access functions will check the file size to decide when to indicate EOF to you, the programmer.

如果数据中有文件结尾并且您已打开文本模式转换(在大多数语言中,这是控制NL<-> CRLF转换的相同设置),则碰到该EOF字符时,文件访问可能会停止。在二进制模式下,读取将继续进行,直到达到文件大小为止。

If there is an end-of-file in the data AND you have text-mode translations turned on (in most languages this is the same setting that controls NL <-> CRLF conversions), then the file access may stop when it hits that EOF character. In binary mode, reads will keep going until the file size is hit.

这篇关于EOF实际上存在吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆