Small suggested change to File/stat port

Message ID
DKIM signature
Download raw message
Hi everyone,

Sorry I've been quiet on the list, I've been working hard at improving
the varvara docs and creating examples for the different devices and
things. There has been a lot of activity lately, between the FPGA
port, the WASM implementation, etc.. I wanted to do a little change to
the File device and I wanted to know what you thought, so those who
don't know, the File device has a stat* port:

> The directory listing for a single file or directory can be obtained when File/stat* is written, and will write the same format as above, including the newline, into the memory buffer. If File/success* reads zero, the file or directory doesn't exist or the region is too small to fit the line.

The only usage I've ever had of the port was ever to get the first 4
characters, which look like these:

001a file.txt
---- directory/
???? large file.mp4

But the file device won't write anything unless the length of the
buffer to write into is long enough to accomodate the full result, so
if you have a very long file name, you need an extra long buffer, and
in 99.9999% of the cases, you already know the file name, you just
want to know its 4-byte code, to know if it's a folder, or a large
file. I was thinking that maybe the stat port should always ever only
write these 4 bytes and ignore the length value. That would simplify
things a lot for me, so let me know if anyone has any issue with this

So, yeah! Here's some unrelated fun things that might be of interest:

- https://taylor.town/pardon-2023 A nice blog post about some of the
reason why we started uxn in the first place
- https://100r.co/site/computing_and_sustainability.html The
transcription of the Strange Loop talk
- http://wiki.xxiivv.com/site/ulz_format A compression format for uxn
files that was implemented in uxn itself
- https://git.sr.ht/~rabbits/uxn-utils/tree/main/item/cli/opctest/opctest.tal
Much improved opcode test rom, thanks to remko!
- https://rabbits.srht.site/uxn5/ Vanilla Javascript implementation
that works in your browser

Have a good one :)

Message ID
<CAE2DaSRUMqLnsmdJ_c=JR-WA3ikpRY3VprbGWS7wUUEkcM1qYw@mail.gmail.com> (view parent)
DKIM signature
Download raw message
I went ahead and implement the change to the stat port last month. Not 
only does it allow to poll only the 4 bytes of the string representation 
of the file, but you can poll a single one as well, so if you stat a 
file with a length of one, you would get '-' for a folder, for example, 
limiting the need for excessive buffer size.

While implementing that change, it gave me an idea. I was thinking, it 
would be quite trivial to make it so a length of 8, would give us the 
32-bit int length of a file:


This would allow Uxn to know the file length of files larger than a 
short, if the file size is larger than the length, then you get a bunch 
of '?' as is the current behavior.

Let me know what you think :)

Reply to thread Export thread (mbox)