eric6/MicroPython/MicroPythonFileSystemUtilities.py

branch
micropython
changeset 7137
4ed2573947ff
parent 7084
3eddfc540614
child 7229
53054eb5b15a
diff -r bddcb634a9b8 -r 4ed2573947ff eric6/MicroPython/MicroPythonFileSystemUtilities.py
--- a/eric6/MicroPython/MicroPythonFileSystemUtilities.py	Tue Aug 13 16:39:31 2019 +0200
+++ b/eric6/MicroPython/MicroPythonFileSystemUtilities.py	Tue Aug 13 17:52:58 2019 +0200
@@ -62,16 +62,21 @@
         return name
 
 
-def isVisible(name):
+def isVisible(name, showHidden):
     """
     Function to check, if a filesystem entry is a hidden file or directory.
     
     @param name name to be checked
     @type str
+    @param showHidden flag indicating to show hidden files as well
+    @type bool
     @return flag indicating a visible filesystem entry
     @rtype bool
     """
-    return not name.startswith(".") and not name.endswith("~")
+    return (
+        showHidden or
+        (not name.startswith(".") and not name.endswith("~"))
+    )
 
 
 def fstat(filename):
@@ -90,12 +95,14 @@
     return tuple(rstat)
 
 
-def listdirStat(dirname):
+def listdirStat(dirname, showHidden=False):
     """
     Function to get a list of directory entries and associated stat() tuples.
     
     @param dirname name of the directory to list
     @type str
+    @param showHidden flag indicating to show hidden files as well
+    @type bool
     @return list of tuples containing the entry name and the associated
         stat() tuple
     @rtype list of tuple of (str, tuple)
@@ -109,7 +116,7 @@
         return []
     
     if dirname in ('', '/'):
-        return [(f, fstat(f)) for f in files if isVisible(f)]
+        return [(f, fstat(f)) for f in files if isVisible(f, showHidden)]
     
     return [(f, fstat(os.path.join(dirname, f))) for f in files
-            if isVisible(f)]
+            if isVisible(f, showHidden)]

eric ide

mercurial