(components: &OwnedComponents)
| 103 | #[pure] |
| 104 | #[trusted] |
| 105 | pub fn min_depth(components: &OwnedComponents) -> isize { |
| 106 | let mut curr_depth = 0; |
| 107 | let mut idx = 0; |
| 108 | while idx < components.len() { |
| 109 | body_invariant!(curr_depth >= 0); |
| 110 | match components.lookup(idx) { |
| 111 | OwnedComponent::RootDir => { |
| 112 | return DEPTH_ERR; |
| 113 | } // hacky, but fine for now |
| 114 | OwnedComponent::CurDir => {} |
| 115 | OwnedComponent::ParentDir => { |
| 116 | curr_depth -= 1; |
| 117 | } |
| 118 | OwnedComponent::Normal(_) => { |
| 119 | curr_depth += 1; |
| 120 | } |
| 121 | }; |
| 122 | // if curr_depth ever dips below 0, it is illegal |
| 123 | // this prevents paths like ../other_sandbox_home |
| 124 | if curr_depth < 0 { |
| 125 | return curr_depth; |
| 126 | } |
| 127 | idx += 1; |
| 128 | } |
| 129 | curr_depth |
| 130 | } |
| 131 | |
| 132 | #[trusted] |
| 133 | #[ensures(result.is_none() ==> old(!is_symlink(out_path)) )] |
no test coverage detected