summaryrefslogtreecommitdiffstats
path: root/src/options.rs
diff options
context:
space:
mode:
authorBen S <ogham@bsago.me>2015-04-23 13:00:34 +0100
committerBen S <ogham@bsago.me>2015-04-23 13:00:34 +0100
commitadbaa51cb9421df43625b96ea3ea39b455fd5ee4 (patch)
tree769e5cc63ed3d5759743420a95520e2ccbb90fab /src/options.rs
parenteee49ecefea05025f94193d487d2dae561a8a8f1 (diff)
Use new io + path + fs libraries (LOTS OF CHANGES)
Exa now uses the new IO, Path, and Filesystem libraries that have been out for a while now. Unfortunately, the new libraries don't *entirely* cover the range of the old libraries just yet: in particular, to become more cross-platform, the data in `UnstableFileStat` isn't available in the Unix `MetadataExt` yet. Much of this is contained in rust-lang/rfcs#1044 (which is due to be implemented in rust-lang/rust#14711), but it's not *entirely* there yet. As such, this commits a serious loss of functionality: no symlink viewing, no hard links or blocks, or users or groups. Also, some of the code could now be optimised. I just wanted to commit this to sort out most of the 'teething problems' of having a different path system in advance. Here's an example problem that took ages to fix for you, just because you read this far: when I first got exa to compile, it worked mostly fine, except calling `exa` by itself didn't list the current directory. I traced where the command-line options were being generated, to where files and directories were sorted, to where the threads were spawned... and the problem turned out to be that it was using the full path as the file name, rather than just the last component, and these paths happened to begin with `.`, so it thought they were dotfiles.
Diffstat (limited to 'src/options.rs')
-rw-r--r--src/options.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/options.rs b/src/options.rs
index 9602a77..b2f2d91 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -137,15 +137,15 @@ impl FileFilter {
match self.sort_field {
SortField::Unsorted => {},
SortField::Name => files.sort_by(|a, b| natord::compare(&*a.name, &*b.name)),
- SortField::Size => files.sort_by(|a, b| a.stat.size.cmp(&b.stat.size)),
- SortField::FileInode => files.sort_by(|a, b| a.stat.unstable.inode.cmp(&b.stat.unstable.inode)),
+ SortField::Size => files.sort_by(|a, b| a.stat.len().cmp(&b.stat.len())),
+ SortField::FileInode => {}, // files.sort_by(|a, b| a.stat.unstable.inode.cmp(&b.stat.unstable.inode)),
SortField::Extension => files.sort_by(|a, b| match a.ext.cmp(&b.ext) {
Ordering::Equal => natord::compare(&*a.name, &*b.name),
order => order
}),
- SortField::ModifiedDate => files.sort_by(|a, b| a.stat.modified.cmp(&b.stat.modified)),
- SortField::AccessedDate => files.sort_by(|a, b| a.stat.accessed.cmp(&b.stat.accessed)),
- SortField::CreatedDate => files.sort_by(|a, b| a.stat.created.cmp(&b.stat.created)),
+ SortField::ModifiedDate => files.sort_by(|a, b| a.stat.modified().cmp(&b.stat.modified())),
+ SortField::AccessedDate => files.sort_by(|a, b| a.stat.accessed().cmp(&b.stat.accessed())),
+ SortField::CreatedDate => {}, // files.sort_by(|a, b| a.stat.created().cmp(&b.stat.created())),
}
if self.reverse {
@@ -443,6 +443,13 @@ impl DirAction {
}
}
+ pub fn is_as_file(&self) -> bool {
+ match *self {
+ DirAction::AsFile => true,
+ _ => false,
+ }
+ }
+
pub fn is_tree(&self) -> bool {
match *self {
DirAction::Recurse(RecurseOptions { max_depth: _, tree }) => tree,