Allow ls -tr to allow sorting by time and reverse order#1578
Allow ls -tr to allow sorting by time and reverse order#1578
ls -tr to allow sorting by time and reverse order#1578Conversation
dissect/target/tools/utils/fs.py
Outdated
| entry = target_path.get() | ||
| entry_stat = entry.lstat() |
There was a problem hiding this comment.
| entry = target_path.get() | |
| entry_stat = entry.lstat() | |
| entry_stat = target_path.lstat() |
I think this works too.
There was a problem hiding this comment.
later in the loop the lstat() and entry() is again looked up for printing the data, maybe we can just put them directly in the contents list as a tuple so we don't have to call it again.
There was a problem hiding this comment.
I now return a DirScanEntry namedtuple with some commonly used fields. Which includes lstat(), note this means when doing a ls_scandir this is always called per entry, even if the timestamp is not used in the display.
I'm not sure if this is a big issue but otherwise we could add a boolean to the function to make this optional.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1578 +/- ##
==========================================
- Coverage 81.02% 81.00% -0.03%
==========================================
Files 400 400
Lines 34965 34985 +20
==========================================
+ Hits 28332 28340 +8
- Misses 6633 6645 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
954731e to
a6779a5
Compare
|
I still have some outstanding changes locally and that I want to test, so i'm putting this PR in Draft until those are pushed and is in reviewable state. |
This PR allows you to sort the
lsoutput based on time and also able to reverse the order via:ls -tsort by timels -rreverse sortls -trsort by time in reverse.resolves #1577