Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (idx, line) in content.lines().enumerate() {
- if idx == 0 {
- continue;
- }
- let line_parts = line.split(' ').collect::<Vec<_>>();
- if line.starts_with('$') {
- if line_parts[1].eq("cd") {
- if line_parts[2].eq("..") {
- if let Some(x) = current_dir.get_parent() {
- current_dir = x;
- }
- } else {
- current_dir = current_dir.get_directory(line_parts[2]);
- }
- }
- } else if line.starts_with("dir") {
- let new_directory = Directory::create(line);
- current_dir.add_directory(new_directory);
- } else {
- current_dir.add_file(AdventFile::create(line));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment