emikulic / darkhttpd

When you need a web server in a hurry.
https://unix4lyfe.org/darkhttpd/
ISC License
1.05k stars 87 forks source link

[FR] Print IEC formatted file sizes in directory listing #59

Closed g-rden closed 8 months ago

g-rden commented 8 months ago

Idk if that is interesting for this project, but I have files from 0 bytes to dozens of GB and I can't read and parse the long strings of numbers.

I tried implementing it here: https://github.com/g-rden/darkhttpd/tree/print-iec-sizes

So far it is just a test and I wouldn't want to replace the old, verbose, version of displaying. But it would be nice as an option to toggle.

hhartzer commented 8 months ago

This is pretty cool! I am curious if that works with Kodi. I would be happy to test that unless you happen to have Kodi ready to go.

I personally don't have any objections to that being the default, especially if it plays nicely with Kodi. I do think it'd be a great candidate for a couple of unit tests as well.

g-rden commented 8 months ago

I don't use kodi. Please test it if you want. If it shouldn't work then it might be able to make it compatible. Or just use the old way of displaying.

emikulic commented 8 months ago

I'm sorry but I'm not thrilled about this functionality. :( I think just showing the number of bytes is fine.

The Kodi regex (https://github.com/xbmc/xbmc/pull/17652/files) is ([0-9]+)(B|K|M|G)?(?=\\s|<|$) - IIUC it won't match GiB, so it's not clear if it's 1000 or 1024.

Off-topic: I personally would prefer thousands-separators like 123,456 except:

g-rden commented 8 months ago

Understandable. I'll just keep it as a fork.