EOF真的存在吗?

发布于 2024-08-24 07:49:13 字数 91 浏览 3 评论 0原文

当我在 PHP 中使用文件函数时,我会检查 EOF。我想知道 EOF 是否真的存在于文件中。当我创建一个空文本文件时,它显示 0KB。 0KB的文件中怎么存在EOF呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七七 2024-08-31 07:49:13

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

如果数据中有文件结尾并且您打开了文本模式翻译(在大多数语言中,这与控制 NL <-> CRLF 转换的设置相同),则文件访问可能会在以下情况下停止:击中 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.

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.

紫﹏色ふ单纯 2024-08-31 07:49:13

在现代文件系统中,磁盘上没有实际的 EOF 字符。它在某些文件读取函数中通过返回 4 字节值而不是 1 字节值来实现,但大多数函数不使用该概念。

In modern filesystems there is no actual EOF character on the disk. It's implemented in some file reading functions by returning a 4 byte value instead of a 1 byte value, but most functions don't use the concept.

欢烬 2024-08-31 07:49:13

它不存在..但文件大小确实存在,这就是你知道 eof 在哪里的方式

it doesn't exist.. but file size does, and that's how you know where is eof

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文