MCPcopy Create free account
hub / github.com/Nariod/RustPacker / rename_source_binary

Function rename_source_binary

src/tools.rs:110–133  ·  view source on GitHub ↗
(
    order: &arg_parser::Order,
    output_folder_path: &Path,
)

Source from the content-addressed store, hash-verified

108}
109
110pub 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)]
136mod tests {

Callers 1

mainFunction · 0.85

Calls 2

generate_random_filenameFunction · 0.85

Tested by

no test coverage detected