1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std::{error::Error, ffi::CStr};

use crate::{ai_interface::AIInterface, get_callback};

impl AIInterface {
    pub fn config_dir(&self) -> Result<String, Box<dyn Error>> {
        let get_config_dir = get_callback!(self.ai_id, DataDirs_getConfigDir)?;
        Ok(String::from(
            unsafe { CStr::from_ptr(get_config_dir(self.ai_id)) }.to_str()?,
        ))
    }

    pub fn writeable_dir(&self) -> Result<String, Box<dyn Error>> {
        let get_writeable_dir = get_callback!(self.ai_id, DataDirs_getWriteableDir)?;
        Ok(String::from(
            unsafe { CStr::from_ptr(get_writeable_dir(self.ai_id)) }.to_str()?,
        ))
    }
}