diff options
Diffstat (limited to 'crates/ra_vfs/src/io.rs')
-rw-r--r-- | crates/ra_vfs/src/io.rs | 72 |
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 @@ | |||
1 | use std::{ | ||
2 | fs, | ||
3 | path::{Path, PathBuf}, | ||
4 | thread::JoinHandle, | ||
5 | }; | ||
6 | |||
7 | use walkdir::WalkDir; | ||
8 | use crossbeam_channel::{Sender, Receiver}; | ||
9 | |||
10 | pub(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 | // } | ||