use std::{fs::read_to_string, path::Path};
use log::info;
pub fn open_project(filepaths: &[String]) -> String {
let mut files = vec![];
for i in 1..filepaths.len() {
let res = read_to_string(&filepaths[i]).expect("cannot read file");
let path = &filepaths[i];
let path = Path::new(&path);
let mut filename = path.file_stem().unwrap().to_str().unwrap().to_owned();
info!("Filename: {filename}");
filename = format!("mod {filename} {{\n") + &res;
let updated_file = filename + "\n}";
info!("Updated Mod:\n{updated_file}");
files.push(updated_file);
}
let res = combine_files(&files);
res
}
pub fn open_project_file(filepath: &str) -> String {
let x = [filepath.to_string()];
open_project(&x)
}
pub fn combine_files(files: &Vec<String>) -> String {
files.iter().fold("".to_owned(), |acc, next| acc + next)
}