mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2025-12-27 07:45:28 +00:00
WIP gallery app
This commit is contained in:
@@ -30,6 +30,7 @@ pub enum CallAbiTable {
|
||||
GenRand = 5,
|
||||
ListDir = 6,
|
||||
ReadFile = 7,
|
||||
FileLen = 8,
|
||||
}
|
||||
|
||||
pub type PrintAbi = extern "C" fn(ptr: *const u8, len: usize);
|
||||
@@ -95,11 +96,15 @@ pub fn gen_rand(req: &mut RngRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
pub type ListDir =
|
||||
extern "C" fn(str: *const u8, len: usize, files: *mut Option<DirEntry>, file_len: usize);
|
||||
pub type ListDir = extern "C" fn(
|
||||
str: *const u8,
|
||||
len: usize,
|
||||
files: *mut Option<DirEntry>,
|
||||
file_len: usize,
|
||||
) -> usize;
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn list_dir(path: &str, files: &mut [Option<DirEntry>]) {
|
||||
pub fn list_dir(path: &str, files: &mut [Option<DirEntry>]) -> usize {
|
||||
unsafe {
|
||||
let ptr = CALL_ABI_TABLE[CallAbiTable::ListDir as usize];
|
||||
let f: ListDir = core::mem::transmute(ptr);
|
||||
@@ -129,3 +134,14 @@ pub fn read_file(file: &str, read_from: usize, buf: &mut [u8]) -> usize {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub type FileLen = extern "C" fn(str: *const u8, len: usize) -> usize;
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn file_len(file: &str) -> usize {
|
||||
unsafe {
|
||||
let ptr = CALL_ABI_TABLE[CallAbiTable::FileLen as usize];
|
||||
let f: FileLen = core::mem::transmute(ptr);
|
||||
f(file.as_ptr(), file.len())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user