makepad_platform/os/
cx_native.rs1use {
2 std::{
3 io::prelude::*,
4 fs::File,
5 rc::Rc,
6 time::{SystemTime}
7 },
8 crate::{
9 cx::{Cx},
10 }
11};
12
13#[derive(PartialEq, Eq, Clone, Copy, Debug)]
14pub enum EventFlow{
15 Poll,
16 Wait,
17 Exit
18}
19
20impl Cx {
24
25 pub fn native_load_dependencies(&mut self){
26 for (path,dep) in &mut self.dependencies{
27 if let Ok(mut file_handle) = File::open(path) {
28 let mut buffer = Vec::<u8>::new();
29 if file_handle.read_to_end(&mut buffer).is_ok() {
30 dep.data = Some(Ok(Rc::new(buffer)));
31 }
32 else{
33 dep.data = Some(Err("read_to_end failed".to_string()));
34 }
35 }
36 else{
37 println!("Could not load resource {}", path);
38 dep.data = Some(Err("File! open failed".to_string()));
39 }
40 }
41 }
42
43 pub fn time_now()->f64{
44 if let Ok(elapsed) = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH){
45 return elapsed.as_secs_f64();
46 }
47 return 0.0
48 }
49}