pub fn from_path(tsk_fs: &'fs TskFs, path: &str) -> Result<Self, TskError> {
        // Create a CString for the provided source
        let path_c = CString::new(path)
            .map_err(|e| TskError::generic(format!("Unable to create CString from path {}: {:?}", path, e)))?;

        // Get a pointer to the TSK_FS_FILE sturct
        let tsk_fs_file_ptr = unsafe {tsk::tsk_fs_file_open(
            tsk_fs.into(),
            null_mut(),
            path_c.as_ptr() as _
        )};

        if tsk_fs_file_ptr.is_null() {
            // Get a ptr to the error msg
            let error_msg_ptr = unsafe { tsk::tsk_error_get() };
            // Get the error message from the string
            let error_msg = unsafe { CStr::from_ptr(error_msg_ptr) }.to_string_lossy();
            // Return an error which includes the TSK error message
            return Err(TskError::lib_tsk_error(
                format!("There was an error opening {}: {}", path, error_msg)
            ));
        }

        Ok( Self { 
            tsk_fs_info_ptr: tsk_fs.into(),
            tsk_fs_file_ptr, 
            _release: true
        } )
    }
/// Create a TSK_FS_FILE wrapper given TskFs and path
Create a TSK_FS_FILE wrapper given TskFs and path
Create a TSK_FS_FILE wrapper given TskFs and path
pub fn from_path(tsk_fs: &'fs TskFs, path: &str) -> Result<Self, TskError> {
        // Create a CString for the provided source
        let path_c = CString::new(path)
            .map_err(|e| TskError::generic(format!("Unable to create CString from path {}: {:?}", path, e)))?;
        // Get a pointer to the TSK_FS_FILE sturct
        let tsk_fs_file_ptr = unsafe {tsk::tsk_fs_file_open(
            tsk_fs.into(),
            null_mut(),
            path_c.as_ptr() as _
        )};
        if tsk_fs_file_ptr.is_null() {
            // Get a ptr to the error msg
            let error_msg_ptr = unsafe { tsk::tsk_error_get() };
            // Get the error message from the string
            let error_msg = unsafe { CStr::from_ptr(error_msg_ptr) }.to_string_lossy();
            // Return an error which includes the TSK error message
            return Err(TskError::lib_tsk_error(
                format!("There was an error opening {}: {}", path, error_msg)
            ));
        }
        Ok( Self { 
            tsk_fs_info_ptr: tsk_fs.into(),
            tsk_fs_file_ptr, 
            _release: true
        } )
    }
pub fn from_path ( tsk_fs : & ' fs TskFs , path : & str ) -> Result < Self , TskError > { // Create a CString for the provided source let path_c = CString :: new ( path ) . map_err ( | e | TskError :: generic ( format ! ( " " path e ) ) ) ? ; // Get a pointer to the TSK_FS_FILE sturct let tsk_fs_file_ptr = unsafe { tsk :: tsk_fs_file_open ( tsk_fs . into ( ) , null_mut ( ) , path_c . as_ptr ( ) as _ ) } ; if tsk_fs_file_ptr . is_null ( ) { // Get a ptr to the error msg let error_msg_ptr = unsafe { tsk :: tsk_error_get ( ) } ; // Get the error message from the string let error_msg = unsafe { CStr :: from_ptr ( error_msg_ptr ) } . to_string_lossy ( ) ; // Return an error which includes the TSK error message return Err ( TskError :: lib_tsk_error ( format ! ( " " path error_msg ) ) ) ; } Ok ( Self { tsk_fs_info_ptr : tsk_fs . into ( ) , tsk_fs_file_ptr , _release : true } ) }
Create a TSK_FS_FILE wrapper given TskFs and path
Create a TSK_FS_FILE wrapper given TskFs and path
tsk_fs
&'fs TskFs
path
&str