第三方统一类型标识符实现?
文件扩展名、MIME 类型以及用于确定文件类型的创建者代码和幻数的疯狂程度是一团糟。 来自 Cocoa 编程的背景,我想我被宠坏了:在 Tiger 中,OS X 添加了一个名为 的系统统一类型标识符 (UTI) 使整个过程保持理智。
鉴于我正在进行大量 Web 开发(在此插入您最喜欢的 Web 开发环境),是否有类似的东西不依赖于运行 OS X 并且 - 更好 - 可在多种编程语言中工作?
现在,我在 Linux 上使用 file
命令来复制一些功能,但它只是不一样。 当然,每个人都有他们的巨大的查找表,但没有什么是中心化的。
有人做过这个或以前遇到过这个吗?
The madness of file extensions and MIME types and creator codes and magic numbers to determine file types is a huge mess. Coming from a background of Cocoa programming, I supposed I'm spoiled: in Tiger, OS X added a system called Uniform Type Identifiers (UTIs) that makes the entire process sane.
Given that I'm doing a bunch of web development in (insert your favorite web development environment here), is there anything similar that's not dependent on running OS X and - better yet - works in multiple programming languages?
Right now, I'm using the file
command on Linux to replicate some of the functionality, but it's just not the same. And, of course, everybody has their huge lookup tables, but nothing is centralized.
Has anybody done this or run across this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 OS X 之外似乎没有任何这样的东西。
file
命令是你在 Linux 上可以做的最好的命令,我在 Linux 上见过的所有文件类型识别系统都使用它内部(当他们不只是使用文件扩展名时)。特别是,您可以使用 file -i 输出 MIME 类型,而不是简单的人类可读字符串。
UTI 系统似乎有很多有用的功能,也许如果您能告诉我们您特别错过了哪些您发现的其他方法无法提供的功能,我们可能会更容易为您找到一些东西有用。
There just doesn't seem to be any such thing outside of OS X. The
file
command is the best that you can do on linux, all the file type identification systems I've seen on linux use it internally (when they aren't just using the file extension).In particular you can use
file -i
to output a MIME type rather than the plain human-readable strings.The UTI system seems to have a great deal of useful functionality, maybe if you could tell us what in particular you miss about it that the other methods you've found don't give you, it might be easier for us to find you something useful.