Skip to content
Myr

rename module entry -> dir_entry

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jonathan Goren · committed by Jonathan Goren · parent 1153e3e · Browse files · 8 files+70 added−70 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+70 added−70 removed

  • other:+70 added−70 removed

8 files+70 added−70 removed

modified:src/exec/job.rs+1 added-1 removed
1use std::sync::{Arc, Mutex};23use crossbeam_channel::Receiver;45use crate::entry::DirEntry;5use crate::dir_entry::DirEntry;6use crate::error::print_error;7use crate::exit_codes::{merge_exitcodes, ExitCode};8use crate::walk::WorkerResult;9
69 unmodified lines
added:src/dir_entry.rs+62 added
1use std::{2 fs::{FileType, Metadata},3 path::{Path, PathBuf},4};56use once_cell::unsync::OnceCell;78enum DirEntryInner {9 Normal(ignore::DirEntry),10 BrokenSymlink(PathBuf),11}1213pub struct DirEntry {14 inner: DirEntryInner,15 metadata: OnceCell<Option<Metadata>>,16}1718impl DirEntry {19 pub fn normal(e: ignore::DirEntry) -> Self {20 Self {21 inner: DirEntryInner::Normal(e),22 metadata: OnceCell::new(),23 }24 }2526 pub fn broken_symlink(path: PathBuf) -> Self {27 Self {28 inner: DirEntryInner::BrokenSymlink(path),29 metadata: OnceCell::new(),30 }31 }3233 pub fn path(&self) -> &Path {34 match &self.inner {35 DirEntryInner::Normal(e) => e.path(),36 DirEntryInner::BrokenSymlink(pathbuf) => pathbuf.as_path(),37 }38 }3940 pub fn file_type(&self) -> Option<FileType> {41 match &self.inner {42 DirEntryInner::Normal(e) => e.file_type(),43 DirEntryInner::BrokenSymlink(_) => self.metadata().map(|m| m.file_type()),44 }45 }4647 pub fn metadata(&self) -> Option<&Metadata> {48 self.metadata49 .get_or_init(|| match &self.inner {50 DirEntryInner::Normal(e) => e.metadata().ok(),51 DirEntryInner::BrokenSymlink(path) => path.symlink_metadata().ok(),52 })53 .as_ref()54 }5556 pub fn depth(&self) -> Option<usize> {57 match &self.inner {58 DirEntryInner::Normal(e) => Some(e.depth()),59 DirEntryInner::BrokenSymlink(_) => None,60 }61 }62}
deleted:src/entry.rs-62 removed
1use std::{2 fs::{FileType, Metadata},3 path::{Path, PathBuf},4};56use once_cell::unsync::OnceCell;78enum DirEntryInner {9 Normal(ignore::DirEntry),10 BrokenSymlink(PathBuf),11}1213pub struct DirEntry {14 inner: DirEntryInner,15 metadata: OnceCell<Option<Metadata>>,16}1718impl DirEntry {19 pub fn normal(e: ignore::DirEntry) -> Self {20 Self {21 inner: DirEntryInner::Normal(e),22 metadata: OnceCell::new(),23 }24 }2526 pub fn broken_symlink(path: PathBuf) -> Self {27 Self {28 inner: DirEntryInner::BrokenSymlink(path),29 metadata: OnceCell::new(),30 }31 }3233 pub fn path(&self) -> &Path {34 match &self.inner {35 DirEntryInner::Normal(e) => e.path(),36 DirEntryInner::BrokenSymlink(pathbuf) => pathbuf.as_path(),37 }38 }3940 pub fn file_type(&self) -> Option<FileType> {41 match &self.inner {42 DirEntryInner::Normal(e) => e.file_type(),43 DirEntryInner::BrokenSymlink(_) => self.metadata().map(|m| m.file_type()),44 }45 }4647 pub fn metadata(&self) -> Option<&Metadata> {48 self.metadata49 .get_or_init(|| match &self.inner {50 DirEntryInner::Normal(e) => e.metadata().ok(),51 DirEntryInner::BrokenSymlink(path) => path.symlink_metadata().ok(),52 })53 .as_ref()54 }5556 pub fn depth(&self) -> Option<usize> {57 match &self.inner {58 DirEntryInner::Normal(e) => Some(e.depth()),59 DirEntryInner::BrokenSymlink(_) => None,60 }61 }62}
modified:src/filesystem.rs+2 added-2 removed
7 unmodified lines
8use std::path::{Path, PathBuf};910use normpath::PathExt;1112use crate::entry;12use crate::dir_entry;1314pub fn path_absolute_form(path: &Path) -> io::Result<PathBuf> {15 if path.is_absolute() {16 return Ok(path.to_path_buf());
33 unmodified lines
50pub fn is_executable(_: &fs::Metadata) -> bool {51 false52}5354pub fn is_empty(entry: &entry::DirEntry) -> bool {54pub fn is_empty(entry: &dir_entry::DirEntry) -> bool {55 if let Some(file_type) = entry.file_type() {56 if file_type.is_dir() {57 if let Ok(mut entries) = fs::read_dir(entry.path()) {58 entries.next().is_none()
90 unmodified lines
modified:src/filetypes.rs+2 added-2 removed
1use crate::entry;1use crate::dir_entry;2use crate::filesystem;34/// Whether or not to show5#[derive(Default)]
7 unmodified lines
13 pub empty_only: bool,14}1516impl FileTypes {17 pub fn should_ignore(&self, entry: &entry::DirEntry) -> bool {17 pub fn should_ignore(&self, entry: &dir_entry::DirEntry) -> bool {18 if let Some(ref entry_type) = entry.file_type() {19 (!self.files && entry_type.is_file())20 || (!self.directories && entry_type.is_dir())21 || (!self.symlinks && entry_type.is_symlink())
18 unmodified lines
modified:src/main.rs+1 added-1 removed
1mod app;2mod config;3mod entry;3mod dir_entry;4mod error;5mod exec;6mod exit_codes;7mod filesystem;
563 unmodified lines
modified:src/output.rs+1 added-1 removed
4 unmodified lines
5use lscolors::{Indicator, LsColors, Style};6use once_cell::sync::Lazy;78use crate::config::Config;9use crate::entry::DirEntry;9use crate::dir_entry::DirEntry;10use crate::error::print_error;11use crate::exit_codes::ExitCode;12use crate::filesystem::strip_current_dir;13
165 unmodified lines
modified:src/walk.rs+1 added-1 removed
13 unmodified lines
14use ignore::{self, WalkBuilder};15use regex::bytes::Regex;1617use crate::config::Config;18use crate::entry::DirEntry;18use crate::dir_entry::DirEntry;19use crate::error::print_error;20use crate::exec;21use crate::exit_codes::{merge_exitcodes, ExitCode};22use crate::filesystem;
548 unmodified lines