posixutils-rs
posixutils-rs copied to clipboard
[Draft] Improve file to support modern os
this is a very early draft
Great start. One early file organization comment:
Prefer to follow the ls style of:
- toplevel source in $category/src/$utility.rs
- secondary sources in $category/src/$utility_util/ directory.,
through many research and scouring(the code of linux file utility v5.41) i've come to following high level conclusions
To make a "file" utility means to "abide" by the code of the linux "file" utility of a certain version(not the man page specification of magic)
Let me clarify what i mean: Let's start with what's a compiled magic file
It's simply nothing but a file that has those lines of of text based magic file laid in a a C struct called struct magic and placed in a binary file
So to parse the binary magic file means to simply parse it to the struct magic, parsing the binary magic file is as simple as that and for each version of "file" utility this struct changes(it's size, it has new fields)...for example for 5.45 and 5.41 the binary magic file isn't compatible with each other. Why? Because the structure of the struct magic has been changed and having a supporting every single version is very painful as we need to be up to date with the "file" utility of as it's responsible for creating those compiled magic files
the complexity however comes in the raw magic file, the specification is not the "man page" itself but rather the code, without the code writing the "file" utility is absolutely impossible i.e parsing the raw magic file.
So, here' some details of this file utility:
It's planning to parse binary magic file and the text based magic file supported by file 5.41 as it's the version currently being used in OS X
Referenced permanently in issue #144, so closing this PR.