Node.js fs获取目录中文件的图标 [英] Node.js fs get icon of files in directory

查看:1213
本文介绍了Node.js fs获取目录中文件的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个文件系统浏览器应用程序,我想用图标列出文件。我使用node-webkit。
文件可以是可执行文件,目录和正常文件。在文件列表中,我想显示文件图标和名称。

我可以使用node.js fs模块获取图标吗?或者有一个阅读图标的模块?



我怎样才能得到文件的图标?

解决方案

图标取决于操作系统/浏览器应用程序,而不是由node.js提供的通用接口 - 您需要首先解析文件类型,然后选择并显示该类型的图标文件。

您可以使用 fs 模块来解析类型 - 特别是 stats



要显示的图标类型取决于您 - 某些操作系统可能会为您提供这些操作系统,但是您可以根据自己的位置找到它们。


I want to build a file system explorer app, and I want to list files with icons. I use node-webkit. And files can be executables, directories and normally files. In file list I want to diplay files icon and name.

Can I use node.js fs module for getting icons? Or there a module for reading icons?

How can I get icon of file?

解决方案

Icons are dependent on the operating system / browser application and aren't a generic interface provided by node.js - you instead need to first resolve the type of file, then pick and show the icon for that type of file.

You can use the fs module for resolving the type - especially stats.

The type of icon to show is up to you - some operating systems may provide these for you, but it is up to you to find their location.

这篇关于Node.js fs获取目录中文件的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆