emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to reading 0 byte files properly


From: Binbin YE
Subject: how to reading 0 byte files properly
Date: Thu, 17 Nov 2022 17:45:43 +0900

Hi devs!

I've been trying using emacs to view some files mounted by FUSE. Sadly file attr in the system says the file size is 0 bytes, just like files under /proc

emacs can open the file but only can open it partially. I've checked the code to handle find-file and narrow down to 

```c
/* 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

which seems to be not a very big number ( or not, I'm not sure)

```c
/* emacs/src/fileio.c:3692 */

enum { READ_BUF_SIZE = MAX_ALLOCA };
```

```h
/* emacs/src/lisp.h:5300 */

enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 };
```

since vscode, vim, cat, and less can read this file properly, I would like to clarify whether it is a bug to fix or there another way to open a big file like this (say the actual size is 2MB~ but showing as 0 byte on stat)

Best,

Binbin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]