mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-23 06:46:02 +00:00
fix: keep manifest launch arguments to the installed build and their own additions
The manifest's arguments apply only when its build matches the installed version, only arguments the merge inserted are tracked as its own, escaped quotes split like a Windows command line, and the REDprelauncher rule needs Cyberpunk2077.exe beside it.
This commit is contained in:
1 parent
8209a707f4
commit
42026b382f
7 files changed
+56
-18
No files matched your search
@@ -167,7 +167,7 @@ synchronous on the calling thread (network calls block: call them off the main t
|
||||
body → `{"ok": true}` or an error. `nativeInspect` parses manifest bytes: `{"op":"summary"}` →
|
||||
`buildVersion`, `launchExe`, `prereqName`, `prereqPath`, `prereqRead`, `files[]` (`path`, `size`,
|
||||
`tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets;
|
||||
`{"op":"launch"}` → the manifest's `command` line and its `args[]`.
|
||||
`{"op":"launch"}` → the manifest's `buildVersion`, its `command` line and the `args[]` split from it.
|
||||
|
||||
### `nativeInstall`
|
||||
|
||||
|
||||
@@ -44,24 +44,37 @@ pub fn split_command(command: &str) -> Vec<String> {
|
||||
let mut current = String::new();
|
||||
let mut quoted = false;
|
||||
let mut started = false;
|
||||
let mut slashes = 0usize;
|
||||
for c in command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}') {
|
||||
match c {
|
||||
'"' => {
|
||||
if c == '\\' {
|
||||
slashes += 1;
|
||||
started = true;
|
||||
continue;
|
||||
}
|
||||
if c == '"' {
|
||||
current.extend(std::iter::repeat('\\').take(slashes / 2));
|
||||
if slashes % 2 == 1 {
|
||||
current.push('"');
|
||||
} else {
|
||||
quoted = !quoted;
|
||||
started = true;
|
||||
}
|
||||
' ' if !quoted => {
|
||||
if started {
|
||||
args.push(std::mem::take(&mut current));
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
current.push(c);
|
||||
started = true;
|
||||
slashes = 0;
|
||||
started = true;
|
||||
continue;
|
||||
}
|
||||
current.extend(std::iter::repeat('\\').take(slashes));
|
||||
slashes = 0;
|
||||
if c == ' ' && !quoted {
|
||||
if started {
|
||||
args.push(std::mem::take(&mut current));
|
||||
started = false;
|
||||
}
|
||||
} else {
|
||||
current.push(c);
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
current.extend(std::iter::repeat('\\').take(slashes));
|
||||
if started {
|
||||
args.push(current);
|
||||
}
|
||||
@@ -80,6 +93,10 @@ mod tests {
|
||||
split_command(" -a\t-b=\"c d\" \"-e f\" \"\" -g\r\n"),
|
||||
vec!["-a", "-b=c d", "-e f", "-g"]
|
||||
);
|
||||
assert_eq!(
|
||||
split_command(r#"-name="a\" b" -dir=C:\Games\ "-q=\\" -r"#),
|
||||
vec![r#"-name=a" b"#, r"-dir=C:\Games\", r"-q=\", "-r"]
|
||||
);
|
||||
assert!(split_command(" ").is_empty());
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,11 @@ pub fn inspect(bytes: &[u8], request: &str) -> String {
|
||||
.map(|a| a.iter().filter_map(|t| t.as_str()).map(str::to_string).collect());
|
||||
json!({ "indices": locale::select(&m.files, tags.as_deref()) })
|
||||
}
|
||||
"launch" => json!({ "command": m.launch_command, "args": launch::split_command(&m.launch_command) }),
|
||||
"launch" => json!({
|
||||
"buildVersion": m.build_version,
|
||||
"command": m.launch_command,
|
||||
"args": launch::split_command(&m.launch_command),
|
||||
}),
|
||||
_ => json!({
|
||||
"buildVersion": m.build_version,
|
||||
"launchExe": m.launch_exe,
|
||||
@@ -212,6 +216,7 @@ mod tests {
|
||||
let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"select","tags":["English"]}"#)).unwrap();
|
||||
assert_eq!(v["indices"], json!([0]));
|
||||
let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"launch"}"#)).unwrap();
|
||||
assert_eq!(v["buildVersion"], "b");
|
||||
assert_eq!(v["command"], "-PCStore=EGS \"-log=a b.txt\"");
|
||||
assert_eq!(v["args"], json!(["-PCStore=EGS", "-log=a b.txt"]));
|
||||
let v: Value = serde_json::from_str(&inspect(b"nonsense", "{}")).unwrap();
|
||||
|
||||
Reference in new issue
Block a user