163 @param recursive flag indicating a recursive scan |
163 @param recursive flag indicating a recursive scan |
164 @type bool |
164 @type bool |
165 @param withHidden flag indicating to list hidden files and directories |
165 @param withHidden flag indicating to list hidden files and directories |
166 as well (defaults to False) |
166 as well (defaults to False) |
167 @type bool (optional) |
167 @type bool (optional) |
|
168 @return list of file and directory entries |
|
169 @rtype list of dict |
168 """ |
170 """ |
169 listing = [] |
171 listing = [] |
170 for dirEntry in os.scandir(directory): |
172 for dirEntry in os.scandir(directory): |
171 filestat = dirEntry.stat() |
173 filestat = dirEntry.stat() |
172 if withHidden or not dirEntry.name.startswith("."): |
174 if withHidden or not dirEntry.name.startswith("."): |
183 "mtime_str": time.strftime( |
185 "mtime_str": time.strftime( |
184 "%Y-%m-%d %H:%M:%S", time.localtime(filestat.st_mtime) |
186 "%Y-%m-%d %H:%M:%S", time.localtime(filestat.st_mtime) |
185 ), |
187 ), |
186 } |
188 } |
187 listing.append(entry) |
189 listing.append(entry) |
188 |
190 |
189 if entry["is_dir"] and recursive: |
191 if entry["is_dir"] and recursive: |
190 listing += self.__scanDirectory(dirEntry.path, recursive) |
192 listing += self.__scanDirectory(dirEntry.path, recursive) |
191 |
193 |
192 return listing |
194 return listing |
193 |
195 |