Skip to content

Commit

Permalink
Basic walk_directories implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Jul 12, 2024
1 parent a71bc3f commit f35e232
Show file tree
Hide file tree
Showing 6 changed files with 999 additions and 54 deletions.
2 changes: 1 addition & 1 deletion crates/ruff_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ insta = { workspace = true }
tempfile = { workspace = true }

[features]
os = []
os = ["ignore"]
16 changes: 11 additions & 5 deletions crates/ruff_db/src/system.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::fmt::Debug;

pub use memory_fs::MemoryFileSystem;
#[cfg(feature = "os")]
pub use os::OsSystem;
use std::fmt::Debug;
pub use test::{DbWithTestSystem, TestSystem};
use walk_directory::WalkDirectoryBuilder;

use crate::file_revision::FileRevision;

Expand All @@ -13,6 +15,7 @@ mod memory_fs;
mod os;
mod path;
mod test;
pub mod walk_directory;

pub type Result<T> = std::io::Result<T>;

Expand Down Expand Up @@ -85,6 +88,9 @@ pub trait System: Debug {
path: &SystemPath,
) -> Result<Box<dyn Iterator<Item = Result<DirectoryEntry>> + 'a>>;

/// Recursively walks the content of `path`.
fn walk_directory(&self, path: &SystemPath) -> WalkDirectoryBuilder;

fn as_any(&self) -> &dyn std::any::Any;
}

Expand Down Expand Up @@ -133,20 +139,20 @@ impl FileType {
#[derive(Debug)]
pub struct DirectoryEntry {
path: SystemPathBuf,
file_type: Result<FileType>,
file_type: FileType,
}

impl DirectoryEntry {
pub fn new(path: SystemPathBuf, file_type: Result<FileType>) -> Self {
pub fn new(path: SystemPathBuf, file_type: FileType) -> Self {
Self { path, file_type }
}

pub fn path(&self) -> &SystemPath {
&self.path
}

pub fn file_type(&self) -> &Result<FileType> {
&self.file_type
pub fn file_type(&self) -> FileType {
self.file_type
}
}

Expand Down
Loading

0 comments on commit f35e232

Please sign in to comment.