This commit is contained in:
+11
-6
@@ -3,10 +3,15 @@ use crate::handle::*;
|
||||
use crate::interop::*;
|
||||
use crate::misc::*;
|
||||
use crate::sys::*;
|
||||
use std::ffi::{CStr, CString, c_char, c_int, c_ulong, c_void};
|
||||
use std::ffi::{CStr, CString, c_char, c_int, c_void};
|
||||
use std::mem::{ManuallyDrop, MaybeUninit};
|
||||
use std::ops::Deref;
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
type WChar = u32;
|
||||
#[cfg(target_os = "windows")]
|
||||
type WChar = u16;
|
||||
|
||||
/// Release the memory - this function is to be used for freeing memory allocated by the libCZIApi-library
|
||||
/// (and returned to the caller).
|
||||
///
|
||||
@@ -25,7 +30,7 @@ pub fn free<T: Ptr>(data: T) {
|
||||
pub fn allocate_memory<T: Ptr>(size: usize) -> Result<MaybeUninit<T>, Error> {
|
||||
let mut data = MaybeUninit::<T>::uninit();
|
||||
let mut ptr = data.as_mut_ptr() as *mut c_void;
|
||||
lib_czi_error(unsafe { libCZI_AllocateMemory(size as c_ulong, &mut ptr) })?;
|
||||
lib_czi_error(unsafe { libCZI_AllocateMemory(size as u64, &mut ptr) })?;
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
@@ -356,7 +361,7 @@ impl InputStream {
|
||||
/// \\param \[out\] stream_object The output stream object that will hold the created stream.
|
||||
/// \\return An error-code that indicates whether the operation is successful or not. Non-positive values indicates successful, positive values
|
||||
/// indicates unsuccessful operation.
|
||||
pub fn create_from_file_wide(file_name: Vec<u32>) -> Result<Self, Error> {
|
||||
pub fn create_from_file_wide(file_name: Vec<WChar>) -> Result<Self, Error> {
|
||||
let mut stream = MaybeUninit::uninit();
|
||||
let ptr = stream.as_mut_ptr();
|
||||
lib_czi_error(unsafe { libCZI_CreateInputStreamFromFileWide(file_name.as_ptr(), ptr) })?;
|
||||
@@ -464,7 +469,7 @@ impl SubBlock {
|
||||
/// \\returns An error-code indicating success or failure of the operation.
|
||||
pub fn get_raw_data(&self, tp: RawDataType, size: i32) -> Result<(i32, Vec<u8>), Error> {
|
||||
let mut data = vec![0u8; size as usize];
|
||||
let size = Box::into_raw(Box::new(size as c_ulong));
|
||||
let size = Box::into_raw(Box::new(size as u64));
|
||||
lib_czi_error(unsafe {
|
||||
libCZI_SubBlockGetRawData(**self, tp as c_int, size, data.as_mut_ptr() as *mut c_void)
|
||||
})?;
|
||||
@@ -511,7 +516,7 @@ impl Attachment {
|
||||
/// \\returns An error-code indicating success or failure of the operation.
|
||||
pub fn get_raw_data(&self, size: i32) -> Result<(i32, Vec<u8>), Error> {
|
||||
let mut data = vec![0u8; size as usize];
|
||||
let size = Box::into_raw(Box::new(size as c_ulong));
|
||||
let size = Box::into_raw(Box::new(size as u64));
|
||||
lib_czi_error(unsafe {
|
||||
libCZI_AttachmentGetRawData(**self, size, data.as_mut_ptr() as *mut c_void)
|
||||
})?;
|
||||
@@ -827,7 +832,7 @@ impl OutputStream {
|
||||
///
|
||||
/// \\return An error-code that indicates whether the operation is successful or not. Non-positive values indicates successful, positive values
|
||||
/// indicates unsuccessful operation.
|
||||
pub fn create_for_file_wide(file_name: Vec<u32>, overwrite: bool) -> Result<Self, Error> {
|
||||
pub fn create_for_file_wide(file_name: Vec<WChar>, overwrite: bool) -> Result<Self, Error> {
|
||||
let mut output_stream = MaybeUninit::uninit();
|
||||
let ptr = output_stream.as_mut_ptr();
|
||||
lib_czi_error(unsafe {
|
||||
|
||||
Reference in New Issue
Block a user