(
order: &arg_parser::Order,
output_folder_path: &Path,
)
| 108 | } |
| 109 | |
| 110 | pub fn rename_source_binary( |
| 111 | order: &arg_parser::Order, |
| 112 | output_folder_path: &Path, |
| 113 | ) -> io::Result<()> { |
| 114 | let source_binary = get_source_binary_filename(order, output_folder_path); |
| 115 | |
| 116 | if !source_binary.exists() { |
| 117 | return Err(io::Error::new( |
| 118 | io::ErrorKind::NotFound, |
| 119 | format!("Source file does not exist: {:?}", source_binary), |
| 120 | )); |
| 121 | } |
| 122 | |
| 123 | let random_filename = generate_random_filename(order); |
| 124 | let release_dir = source_binary |
| 125 | .parent() |
| 126 | .expect("Source binary has no parent directory"); |
| 127 | let new_path = release_dir.join(random_filename); |
| 128 | |
| 129 | fs::rename(&source_binary, &new_path)?; |
| 130 | println!("[+] Source binary has been renamed to: {:?}", new_path); |
| 131 | |
| 132 | Ok(()) |
| 133 | } |
| 134 | |
| 135 | #[cfg(test)] |
| 136 | mod tests { |
no test coverage detected