-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bindings for the new game dir detection
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use std::ffi::c_char; | ||
use std::mem; | ||
use std::ptr::null_mut; | ||
use physis::existing_dirs::{ExistingInstallType, find_existing_game_dirs, find_existing_user_dirs}; | ||
use crate::ffi_to_c_string; | ||
|
||
/// An existing install location on disk | ||
#[repr(C)] | ||
pub struct physis_ExistingGameDirectory { | ||
/// The application where this installation was from | ||
pub install_type : ExistingInstallType, | ||
/// The path to the "main folder" where "game" and "boot" sits | ||
pub path: *const c_char | ||
} | ||
|
||
#[repr(C)] | ||
pub struct physis_ExistingGameDirectories { | ||
pub count: u32, | ||
pub entries: *mut physis_ExistingGameDirectory | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn physis_find_existing_game_dirs() -> physis_ExistingGameDirectories { | ||
let dirs = find_existing_user_dirs(); | ||
|
||
let mut c_dirs = Vec::new(); | ||
for dir in dirs { | ||
c_dirs.push(physis_ExistingGameDirectory { | ||
path: ffi_to_c_string(&dir.path), | ||
install_type: dir.install_type | ||
}); | ||
} | ||
|
||
let new_dirs = physis_ExistingGameDirectories { | ||
count: c_dirs.len() as u32, | ||
entries: c_dirs.as_mut_ptr() | ||
}; | ||
|
||
mem::forget(c_dirs); | ||
|
||
new_dirs | ||
} | ||
|
||
/// An existing user directory | ||
#[repr(C)] | ||
pub struct physis_ExistingUserDirectory { | ||
/// The application where this directory was from | ||
pub install_type : ExistingInstallType, | ||
/// The path to the user folder | ||
pub path: *const c_char | ||
} | ||
|
||
#[repr(C)] | ||
pub struct physis_ExistingUserDirectories { | ||
pub count: u32, | ||
pub entries: *mut physis_ExistingUserDirectory | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn physis_find_existing_user_dirs() -> physis_ExistingUserDirectories { | ||
let dirs = find_existing_user_dirs(); | ||
|
||
let mut c_dirs = Vec::new(); | ||
for dir in dirs { | ||
c_dirs.push(physis_ExistingUserDirectory { | ||
path: ffi_to_c_string(&dir.path), | ||
install_type: dir.install_type | ||
}); | ||
} | ||
|
||
let new_dirs = physis_ExistingUserDirectories { | ||
count: c_dirs.len() as u32, | ||
entries: c_dirs.as_mut_ptr() | ||
}; | ||
|
||
mem::forget(c_dirs); | ||
|
||
new_dirs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,3 +141,4 @@ mod index; | |
mod logging; | ||
|
||
mod schd; | ||
mod existing_dirs; |