Lol my exact first thought. Also it's clearly a part of their code being used for directory iterating I think. So. That's a thing you do!! It's literally a thing people do
Dunno man lol. I windup making directory iterator functions a lot, mostly for stuff like making sure new views can be called without rewriting stuff after making a new view. Tbh if they're making an application that needs to communicate with something online could be useful for checking different file types exist in a directory, maybe to avoid overriding things or downloading stuff that doesn't need to.be downloaded if it's there. I can think of many reasons to need it. But it's super boring for a tv show lol
My point is that, in a lot of situations, you'll be reading the file anyway so the fact that you have to read it to identify the format is moot.
That overhead is pretty minimal since most file formats are pretty recognizable within the first dozen or so bytes. Libraries such as libmagic are specifically designed to identify file formats, and works pretty quickly.
Normally only need to read the first few bytes + cache = not as bad as you make it out to be. Not saying you are wrong... file extensions are good in my opinion, but yeah they are sort of a hack. It should have been just some meta-data that is stored by the file-system.. so like a file ext, but just store the mime type instead...
but then, at this point, you'd need to use a database to detect it when a new file is written and it doesn't have this proper meta-data... a "not-filesystem-embedded-mime-type-metadata-aware" program writes a file so then it would just be a pain in the ass when it wrongly detects it and things break anyway.
93
u/SplendidPunkinButter Mar 07 '21
So? Not every line of code does something brilliant.
30
u/crumpuppet Mar 07 '21
Why is working with MIME types always such a pain in the ass...
22
u/cfriel Mar 07 '21
They are making a web server in Java - section beginning at static void fillMap.
10
u/baldasheck Mar 07 '21
For the curious: https://github.com/cpleonardo/Energia/blob/75a8013eccc89e9a5c33da190973300c0fdebf70/app/src/processing/app/WebServer.java#L502
5
u/totally-not-god Mar 07 '21
What the fuck is wrong with you.
1
u/starm4nn Mar 08 '21
I guessed FTP because the FTP protocol doesn't know the difference between plaintext and binary.
1
u/RollinThundaga Mar 07 '21
Of course the printer has to get in the way
1
u/bi4_pake3 May 06 '21
Why the hell does he do printo and then does /n in that string