mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-29 02:53:06 +00:00
Lifetime-renaming action!
This commit is contained in:
parent
07ff10e550
commit
00ae71850b
12
src/file.rs
12
src/file.rs
@ -21,9 +21,9 @@ use self::fields as f;
|
|||||||
/// once, have its file extension extracted at least once, and have its stat
|
/// once, have its file extension extracted at least once, and have its stat
|
||||||
/// information queried at least once, so it makes sense to do all this at the
|
/// information queried at least once, so it makes sense to do all this at the
|
||||||
/// start and hold on to all the information.
|
/// start and hold on to all the information.
|
||||||
pub struct File<'a> {
|
pub struct File<'dir> {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub dir: Option<&'a Dir>,
|
pub dir: Option<&'dir Dir>,
|
||||||
pub ext: Option<String>,
|
pub ext: Option<String>,
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub stat: fs::Metadata,
|
pub stat: fs::Metadata,
|
||||||
@ -31,18 +31,18 @@ pub struct File<'a> {
|
|||||||
pub this: Option<Dir>,
|
pub this: Option<Dir>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> File<'a> {
|
impl<'dir> File<'dir> {
|
||||||
/// Create a new File object from the given Path, inside the given Dir, if
|
/// Create a new File object from the given Path, inside the given Dir, if
|
||||||
/// appropriate. Paths specified directly on the command-line have no Dirs.
|
/// appropriate. Paths specified directly on the command-line have no Dirs.
|
||||||
///
|
///
|
||||||
/// This uses `symlink_metadata` instead of `metadata`, which doesn't
|
/// This uses `symlink_metadata` instead of `metadata`, which doesn't
|
||||||
/// follow symbolic links.
|
/// follow symbolic links.
|
||||||
pub fn from_path(path: &Path, parent: Option<&'a Dir>, recurse: bool) -> io::Result<File<'a>> {
|
pub fn from_path(path: &Path, parent: Option<&'dir Dir>, recurse: bool) -> io::Result<File<'dir>> {
|
||||||
fs::symlink_metadata(path).map(|stat| File::with_stat(stat, path, parent, recurse))
|
fs::symlink_metadata(path).map(|stat| File::with_stat(stat, path, parent, recurse))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new File object from the given Stat result, and other data.
|
/// Create a new File object from the given Stat result, and other data.
|
||||||
pub fn with_stat(stat: fs::Metadata, path: &Path, parent: Option<&'a Dir>, recurse: bool) -> File<'a> {
|
pub fn with_stat(stat: fs::Metadata, path: &Path, parent: Option<&'dir Dir>, recurse: bool) -> File<'dir> {
|
||||||
let filename = path_filename(path);
|
let filename = path_filename(path);
|
||||||
|
|
||||||
// If we are recursing, then the `this` field contains a Dir object
|
// If we are recursing, then the `this` field contains a Dir object
|
||||||
@ -340,7 +340,7 @@ fn path_filename(path: &Path) -> String {
|
|||||||
/// ASCII lowercasing is used because these extensions are only compared
|
/// ASCII lowercasing is used because these extensions are only compared
|
||||||
/// against a pre-compiled list of extensions which are known to only exist
|
/// against a pre-compiled list of extensions which are known to only exist
|
||||||
/// within ASCII, so it's alright.
|
/// within ASCII, so it's alright.
|
||||||
fn ext<'a>(name: &'a str) -> Option<String> {
|
fn ext(name: &str) -> Option<String> {
|
||||||
name.rfind('.').map(|p| name[p+1..].to_ascii_lowercase())
|
name.rfind('.').map(|p| name[p+1..].to_ascii_lowercase())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -37,16 +37,16 @@ mod output;
|
|||||||
mod term;
|
mod term;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
struct Exa<'a> {
|
struct Exa<'dir> {
|
||||||
count: usize,
|
count: usize,
|
||||||
options: Options,
|
options: Options,
|
||||||
dirs: Vec<PathBuf>,
|
dirs: Vec<PathBuf>,
|
||||||
files: Vec<File<'a>>,
|
files: Vec<File<'dir>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
impl<'a> Exa<'a> {
|
impl<'dir> Exa<'dir> {
|
||||||
fn new(options: Options) -> Exa<'a> {
|
fn new(options: Options) -> Exa<'dir> {
|
||||||
Exa {
|
Exa {
|
||||||
count: 0,
|
count: 0,
|
||||||
options: options,
|
options: options,
|
||||||
@ -67,8 +67,8 @@ impl<'a> Exa<'a> {
|
|||||||
let (thread_capacity_tx, thread_capacity_rs) = sync_channel(8 * num_cpus::get());
|
let (thread_capacity_tx, thread_capacity_rs) = sync_channel(8 * num_cpus::get());
|
||||||
|
|
||||||
// Communication between consumer thread and producer threads
|
// Communication between consumer thread and producer threads
|
||||||
enum StatResult<'a> {
|
enum StatResult<'dir> {
|
||||||
File(File<'a>),
|
File(File<'dir>),
|
||||||
Path(PathBuf),
|
Path(PathBuf),
|
||||||
Error
|
Error
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user