From: Andreas Schwab <schwab@linux-m68k.org>
To: Binbin YE <phantom2501@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: how to reading 0 byte files properly
Date: Thu, 17 Nov 2022 11:15:50 +0100 [thread overview]
Message-ID: <87o7t5ubs9.fsf@igel.home> (raw)
In-Reply-To: <CABVdjjBbJDY1TaxP9s2H7qRyvWNkBZouxzB-OUtYZaKXN+0e8A@mail.gmail.com> (Binbin YE's message of "Thu, 17 Nov 2022 17:45:43 +0900")
On Nov 17 2022, Binbin YE wrote:
> /* emacs/src/fileio.c:4587 */
>
> if (seekable || !NILP (end))
> total = end_offset - beg_offset;
> else
> /* For a special file, all we can do is guess. */
> total = READ_BUF_SIZE;
> ```
> Judging from the code, it assume the total size would be READ_BUF_SIZE
For a non-seekable file this is just a buffer size, see the read loop
later in the function (how_much stays zero then).
If the file is seekable, the important part is this:
/* The file size returned from fstat may be zero, but data
may be readable nonetheless, for example when this is a
file in the /proc filesystem. */
if (end_offset == 0)
end_offset = READ_BUF_SIZE;
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
next prev parent reply other threads:[~2022-11-17 10:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 8:45 how to reading 0 byte files properly Binbin YE
2022-11-17 10:15 ` Andreas Schwab [this message]
2022-11-18 1:04 ` Binbin YE
2022-11-18 2:17 ` Binbin YE
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7t5ubs9.fsf@igel.home \
--to=schwab@linux-m68k.org \
--cc=emacs-devel@gnu.org \
--cc=phantom2501@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).