I run the Austin Swift meetup group, and a question came up about the /proc
filesystem on Linux:
The question involved the inability to get any useful information from Data
(contentsOf: URL(fileURLWithPath: "/proc/sys/fs/file-max")).
It turns out that Data(contentsOf:) does a stat() on the inode of the file
you give it, and then runs alloc()/read() for the specified number of
bytes. This works fine on normal files on normal file systems. But all the
files in /proc have a 0 length specified by their inodes, and you have to
actually read them until EOF to find out how much is there.
So the question is: Is that something the *Programmer* should be
responsible for knowing, or should *Foundation* be responsible for handling
I can see a case that we'd want to avoid embedding things this OS-specific
in Foundation, but on the other hand, I know that this is very confusing
for Darwin developers moving to Linux and expecting Data(contentsOf:) to
So I thought I'd ask the community and see if there was a consensus.