diff -r 8264ea1f42e5 -r 2114cc7275e8 src/eric7/SystemUtilities/FileSystemUtilities.py --- a/src/eric7/SystemUtilities/FileSystemUtilities.py Sat Feb 17 11:26:37 2024 +0100 +++ b/src/eric7/SystemUtilities/FileSystemUtilities.py Sat Feb 17 19:46:33 2024 +0100 @@ -501,30 +501,37 @@ followsymlinks=True, checkStop=None, ignore=None, + recursive=True, + dirsonly=False, ): """ Function returning a list of all files and directories. @param path root of the tree to check @type str - @param filesonly flag indicating that only files are wanted - @type bool + @param filesonly flag indicating that only files are wanted (defaults to False) + @type bool (optional) @param pattern a filename pattern or list of filename patterns to check - against - @type str or list of str + against (defaults to None) + @type str or list of str (optional) @param followsymlinks flag indicating whether symbolic links - should be followed + should be followed (defaults to True) + @type bool (optional) + @param checkStop function to be called to check for a stop (defaults to None) + @type function (optional) + @param ignore list of entries to be ignored (defaults to None) + @type list of str (optional) + @param recursive flag indicating a recursive search (defaults to True) + @type bool (optional) + @param dirsonly flag indicating to return only directories. When True it has + precedence over the 'filesonly' parameter ((defaults to False) @type bool - @param checkStop function to be called to check for a stop - @type function - @param ignore list of entries to be ignored - @type list of str @return list of all files and directories in the tree rooted at path. The names are expanded to start with path. @rtype list of str """ patterns = pattern if isinstance(pattern, list) else [pattern] - files = [] if filesonly else [path] + files = [] if (filesonly and not dirsonly) else [path] ignoreList = [ ".svn", ".hg", @@ -556,18 +563,22 @@ continue if dirEntry.is_dir(): - if dirEntry.path in ignoreList: - continue - if dirEntry.is_symlink() and not followsymlinks: + if ( + dirEntry.path in ignoreList + or dirEntry.is_symlink() and not followsymlinks + ): continue - files += direntries( - dirEntry.path, - filesonly=filesonly, - pattern=pattern, - followsymlinks=followsymlinks, - checkStop=checkStop, - ignore=ignore, - ) + if recursive: + files += direntries( + dirEntry.path, + filesonly=filesonly, + pattern=pattern, + followsymlinks=followsymlinks, + checkStop=checkStop, + ignore=ignore, + ) + elif dirsonly: + files.append(dirEntry.path) else: files.append(dirEntry.path) return files