There isn’t a tag to specify z/os but most of the oddity described here seems specific to z/os not Linux/Mac/Windows.
Yeah, I’m reading that article getting steadily more confused until the point where the author casually mentions they’re using some OS I’ve never heard of that uses EBCDIC 🤯
I can only assume this is some legacy system running on an IBM mainframe?
For those of us who have no real experience outside of Unix (and various microprocessor OSes), it can be a surprise how complex mainframe filesystems are. Plain “stream files” are often the least common types of file in that environment. Instead most data files have a “type” which defines the size of each record (or “row”), and even the sizes of the fields that make up each record. Files can even have an internally defined primary index field, allowing the filesystem itself to enforce the index’s uniqueness and keep records sorted.
It’s not surprising that there is considerable friction in using such files via the standard C/Unix API.
At the point where you’re actually iterating over multiple data streams in a single named bundle, I think that shoehorning it into the standard fread is just making everything harder for no reason.
Make a client library in a higher-level language like C++, Rust, or Go that lets you Open a bundle and get an iterator over Read handles.
The C++ APIs are a bit confusing, even, so we had to write some driver programs to help intro to CS students learning C++.