List the files in the remote directory -t: sort by timestamp -S: sort by size -r: reverse while sorting
(self, parent=None)
| 1384 | |
| 1385 | @CLIUtil.addcommand(spaces=True) |
| 1386 | def ls(self, parent=None): |
| 1387 | """ |
| 1388 | List the files in the remote directory |
| 1389 | -t: sort by timestamp |
| 1390 | -S: sort by size |
| 1391 | -r: reverse while sorting |
| 1392 | """ |
| 1393 | if self._require_share(): |
| 1394 | return |
| 1395 | # Get pwd of the ls |
| 1396 | pwd = self.pwd |
| 1397 | if parent is not None: |
| 1398 | pwd /= parent |
| 1399 | pwd = self.normalize_path(pwd) |
| 1400 | # Poll the cache |
| 1401 | if self.ls_cache and pwd in self.ls_cache: |
| 1402 | return self.ls_cache[pwd] |
| 1403 | self.smbsock.set_TID(self.current_tree) |
| 1404 | # Open folder |
| 1405 | fileId = self.smbsock.create_request( |
| 1406 | pwd, |
| 1407 | type="folder", |
| 1408 | extra_create_options=self.extra_create_options, |
| 1409 | ) |
| 1410 | # Query the folder |
| 1411 | files = self.smbsock.query_directory(fileId) |
| 1412 | # Close the folder |
| 1413 | self.smbsock.close_request(fileId) |
| 1414 | self.ls_cache[pwd] = files # Store cache |
| 1415 | return files |
| 1416 | |
| 1417 | @CLIUtil.addoutput(ls) |
| 1418 | def ls_output(self, results, *, t=False, S=False, r=False): |
no test coverage detected