aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/src/io.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-18 09:29:14 +0000
committerAleksey Kladov <[email protected]>2018-12-20 09:15:23 +0000
commit7509901fa0985f8fc4893a83e0275a063f072dda (patch)
treec39da5c7459d633772c50df1135a3653cb506903 /crates/ra_vfs/src/io.rs
parentdbb62b5baa36783bbca06f09c77794fce3ceff0c (diff)
wip
Diffstat (limited to 'crates/ra_vfs/src/io.rs')
-rw-r--r--crates/ra_vfs/src/io.rs72
1 files changed, 72 insertions, 0 deletions
diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs
new file mode 100644
index 000000000..f90fe0e84
--- /dev/null
+++ b/crates/ra_vfs/src/io.rs
@@ -0,0 +1,72 @@
1use std::{
2 fs,
3 path::{Path, PathBuf},
4 thread::JoinHandle,
5};
6
7use walkdir::WalkDir;
8use crossbeam_channel::{Sender, Receiver};
9
10pub(crate) fn start_io() -> (JoinHandle<(), Sender<()>, Receiver()>) {}
11
12// use crate::thread_watcher::{ThreadWatcher, Worker};
13
14// #[derive(Debug)]
15// pub struct FileEvent {
16// pub path: PathBuf,
17// pub kind: FileEventKind,
18// }
19
20// #[derive(Debug)]
21// pub enum FileEventKind {
22// Add(String),
23// }
24
25// pub fn roots_loader() -> (Worker<PathBuf, (PathBuf, Vec<FileEvent>)>, ThreadWatcher) {
26// Worker::<PathBuf, (PathBuf, Vec<FileEvent>)>::spawn(
27// "roots loader",
28// 128,
29// |input_receiver, output_sender| {
30// input_receiver
31// .map(|path| {
32// log::debug!("loading {} ...", path.as_path().display());
33// let events = load_root(path.as_path());
34// log::debug!("... loaded {}", path.as_path().display());
35// (path, events)
36// })
37// .for_each(|it| output_sender.send(it))
38// },
39// )
40// }
41
42// fn load_root(path: &Path) -> Vec<FileEvent> {
43// let mut res = Vec::new();
44// for entry in WalkDir::new(path) {
45// let entry = match entry {
46// Ok(entry) => entry,
47// Err(e) => {
48// log::warn!("watcher error: {}", e);
49// continue;
50// }
51// };
52// if !entry.file_type().is_file() {
53// continue;
54// }
55// let path = entry.path();
56// if path.extension().and_then(|os| os.to_str()) != Some("rs") {
57// continue;
58// }
59// let text = match fs::read_to_string(path) {
60// Ok(text) => text,
61// Err(e) => {
62// log::warn!("watcher error: {}", e);
63// continue;
64// }
65// };
66// res.push(FileEvent {
67// path: path.to_owned(),
68// kind: FileEventKind::Add(text),
69// })
70// }
71// res
72// }