rbat 0.1.1

A terminal-native binary analysis tool for security researchers and reverse engineers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::rbat::{Asset, RbatError, Result};

pub fn get_txt_from_file(file: &str) -> Result<Vec<String>> {
    let file = Asset::get(file).ok_or_else(|| RbatError::MissingAsset(file.to_string()))?;

    // converts bytes to string
    let content = String::from_utf8(file.data.to_vec())?;

    // inserts string from each line to texts vec
    let mut texts = Vec::new();
    for line in content.lines() {
        texts.extend(line.split_whitespace().map(|text| text.to_string()));
    }
    Ok(texts)
}