跨平台隐藏文件检测 [英] Cross platform hidden file detection
问题描述
(最好在Python中,但其他的解决方案仍然值得赞赏)
简单地检查一个领先的。适用于* nix / Mac,文件属性视窗。然而,这似乎有点简单,也没有考虑隐藏的东西(。隐藏文件等)的替代方法。有没有一个标准的方式来处理这个问题?
我们实际上是在我们编写的一个项目中解决这个问题。我们所做的是有一个不同的隐藏文件检查器,这是与主检查器注册。我们通过每一个文件,通过这些,看它是否应该被隐藏。
这些棋子不仅对不同的操作系统等,但我们插入的版本控制忽略不计文件,并通过水珠或正则表达式可选用户覆盖。
这主要是相当于你做了什么,而是在一个可插拔的,灵活的和可扩展的方式。
这里请参阅源代码: https://bitbucket.org/aafshar/pida-main/src/tip/pida/services/filemanager/filemanager.py
What is the best way to do cross-platform handling of hidden files? (preferably in Python, but other solutions still appreciated)
Simply checking for a leading '.' works for *nix/Mac, and file attributes work on Windows. However, this seems a little simplistic, and also doesn't account for alternative methods of hiding things (.hidden files, etc.). Is there a standard way to deal with this?
We actually address this in a project we write. What we do is have a number of different "hidden file checkers" that are registered with a main checker. We pass each file through these to see if it should be hidden or not.
These checkers are not only for different OS's etc, but we plug into version control "ignored" files, and optional user overrides by glob or regular expression.
It mostly amounts to what you have done, but in a pluggable, flexible and extensible way.
See source code here: https://bitbucket.org/aafshar/pida-main/src/tip/pida/services/filemanager/filemanager.py
这篇关于跨平台隐藏文件检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!