blob: c0aed36ab27f1f6cbb277ce42bf540fca16ceaca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
pub mod zip;
// File system related utility functions
pub mod file_utils {
use std::fs;
use std::io::{self, Write};
pub fn read_file_to_string(path: &str) -> io::Result<String> {
fs::read_to_string(path)
}
pub fn write_string_to_file(path: &str, content: &str) -> io::Result<()> {
let mut file = fs::File::create(path)?;
file.write_all(content.as_bytes())
}
}
// Configuration parsing utilities
pub mod config_parser {
use std::collections::HashMap;
pub fn parse_config(content: &str) -> HashMap<String, String> {
let mut config = HashMap::new();
for line in content.lines() {
let mut parts = line.splitn(2, '=');
if let (Some(key), Some(value)) = (parts.next(), parts.next()) {
config.insert(key.trim().to_string(), value.trim().to_string());
}
}
config
}
}
|