Skip to main content

luaur_bytecode_cli/functions/
escape_filename.rs

1use alloc::string::String;
2
3pub(crate) fn escape_filename(filename: &str) -> String {
4    let mut escaped = String::with_capacity(filename.len());
5
6    for ch in filename.chars() {
7        match ch {
8            '\\' => {
9                escaped.push('/');
10            }
11            '"' => {
12                escaped.push('\\');
13                escaped.push(ch);
14            }
15            _ => {
16                escaped.push(ch);
17            }
18        }
19    }
20
21    escaped
22}