1#![allow(clippy::too_many_arguments)]
7
8#[allow(unused_imports)]
11use crate::support::{BorrowedSlice, Bytes};
12
13#[repr(i32)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
16pub enum FormatVersion {
17 V1 = 0,
19 V2 = 1,
21}
22
23impl TryFrom<i32> for FormatVersion {
24 type Error = crate::Error;
25 fn try_from(v: i32) -> Result<Self, crate::Error> {
26 match v {
27 0 => Ok(FormatVersion::V1),
28 1 => Ok(FormatVersion::V2),
29 other => Err(crate::Error::UnknownEnum {
30 name: "FormatVersion",
31 value: other,
32 }),
33 }
34 }
35}
36
37#[repr(i32)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
40pub enum Compression {
41 None = 0,
43 Huffman = 1,
45 Zlib = 2,
47 PKware = 8,
49 BZip2 = 16,
51 Sparse = 32,
53 AdpcmMono = 64,
55 AdpcmStereo = -128,
57}
58
59impl TryFrom<i32> for Compression {
60 type Error = crate::Error;
61 fn try_from(v: i32) -> Result<Self, crate::Error> {
62 match v {
63 0 => Ok(Compression::None),
64 1 => Ok(Compression::Huffman),
65 2 => Ok(Compression::Zlib),
66 8 => Ok(Compression::PKware),
67 16 => Ok(Compression::BZip2),
68 32 => Ok(Compression::Sparse),
69 64 => Ok(Compression::AdpcmMono),
70 -128 => Ok(Compression::AdpcmStereo),
71 other => Err(crate::Error::UnknownEnum {
72 name: "Compression",
73 value: other,
74 }),
75 }
76 }
77}
78
79#[derive(Clone, Copy, PartialEq, Eq, Hash, Default)]
81pub struct FileFlags(pub i32);
82
83impl FileFlags {
84 pub const NONE: Self = Self(0);
85 pub const COMPRESSED: Self = Self(512);
87 pub const ENCRYPTED: Self = Self(65536);
89 pub const SINGLE_UNIT: Self = Self(16777216);
91 pub const EXISTS: Self = Self(-2147483648);
93
94 #[inline]
95 pub const fn contains(self, other: Self) -> bool {
96 (self.0 & other.0) == other.0
97 }
98
99 #[inline]
100 pub const fn is_empty(self) -> bool {
101 self.0 == 0
102 }
103}
104
105impl core::ops::BitOr for FileFlags {
106 type Output = Self;
107 #[inline]
108 fn bitor(self, rhs: Self) -> Self {
109 Self(self.0 | rhs.0)
110 }
111}
112
113impl core::ops::BitAnd for FileFlags {
114 type Output = Self;
115 #[inline]
116 fn bitand(self, rhs: Self) -> Self {
117 Self(self.0 & rhs.0)
118 }
119}
120
121impl core::ops::Not for FileFlags {
122 type Output = Self;
123 #[inline]
124 fn not(self) -> Self {
125 Self(!self.0)
126 }
127}
128
129impl core::fmt::Debug for FileFlags {
130 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
131 write!(f, "FileFlags({:#x})", self.0)
132 }
133}
134
135pub struct FileInfo {
137 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_MpqFileInfo>,
138}
139
140impl Drop for FileInfo {
141 fn drop(&mut self) {
142 unsafe { ffi::whiteout_mpq_MpqFileInfo_delete(self.raw.as_ptr()) }
144 }
145}
146
147impl FileInfo {
148 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_MpqFileInfo) -> Option<Self> {
152 core::ptr::NonNull::new(raw).map(|raw| FileInfo { raw })
153 }
154}
155
156unsafe impl Send for FileInfo {}
161
162impl core::fmt::Debug for FileInfo {
163 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
164 f.debug_struct("FileInfo").finish_non_exhaustive()
165 }
166}
167
168impl FileInfo {
169 pub fn new() -> Self {
172 unsafe {
175 let raw = ffi::whiteout_mpq_MpqFileInfo_new();
176 Self::from_raw(raw).expect("native FileInfo allocation failed")
177 }
178 }
179
180 pub fn name(&self) -> String {
182 unsafe {
184 crate::support::take_string(ffi::whiteout_mpq_MpqFileInfo_get_name(self.raw.as_ptr()))
185 }
186 }
187
188 pub fn set_name(&mut self, value: &str) {
189 let value = std::ffi::CString::new(value).unwrap_or_default();
190 unsafe { ffi::whiteout_mpq_MpqFileInfo_set_name(self.raw.as_ptr(), value.as_ptr()) }
192 }
193
194 pub fn compressed_size(&self) -> u32 {
196 unsafe { ffi::whiteout_mpq_MpqFileInfo_get_compressedSize(self.raw.as_ptr()) }
198 }
199
200 pub fn set_compressed_size(&mut self, value: u32) {
201 unsafe { ffi::whiteout_mpq_MpqFileInfo_set_compressedSize(self.raw.as_ptr(), value) }
203 }
204
205 pub fn uncompressed_size(&self) -> u32 {
207 unsafe { ffi::whiteout_mpq_MpqFileInfo_get_uncompressedSize(self.raw.as_ptr()) }
209 }
210
211 pub fn set_uncompressed_size(&mut self, value: u32) {
212 unsafe { ffi::whiteout_mpq_MpqFileInfo_set_uncompressedSize(self.raw.as_ptr(), value) }
214 }
215
216 pub fn flags(&self) -> FileFlags {
218 FileFlags(unsafe { ffi::whiteout_mpq_MpqFileInfo_get_flags(self.raw.as_ptr()) })
220 }
221
222 pub fn set_flags(&mut self, value: FileFlags) {
223 unsafe { ffi::whiteout_mpq_MpqFileInfo_set_flags(self.raw.as_ptr(), value.0) }
225 }
226
227 pub fn locale(&self) -> u16 {
229 unsafe { ffi::whiteout_mpq_MpqFileInfo_get_locale(self.raw.as_ptr()) }
231 }
232
233 pub fn set_locale(&mut self, value: u16) {
234 unsafe { ffi::whiteout_mpq_MpqFileInfo_set_locale(self.raw.as_ptr(), value) }
236 }
237}
238
239impl Default for FileInfo {
240 fn default() -> Self {
241 Self::new()
242 }
243}
244
245pub struct ArchiveInfo {
247 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_MpqArchiveInfo>,
248}
249
250impl Drop for ArchiveInfo {
251 fn drop(&mut self) {
252 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_delete(self.raw.as_ptr()) }
254 }
255}
256
257impl ArchiveInfo {
258 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_MpqArchiveInfo) -> Option<Self> {
262 core::ptr::NonNull::new(raw).map(|raw| ArchiveInfo { raw })
263 }
264}
265
266unsafe impl Send for ArchiveInfo {}
271
272impl core::fmt::Debug for ArchiveInfo {
273 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
274 f.debug_struct("ArchiveInfo").finish_non_exhaustive()
275 }
276}
277
278impl ArchiveInfo {
279 pub fn new() -> Self {
282 unsafe {
285 let raw = ffi::whiteout_mpq_MpqArchiveInfo_new();
286 Self::from_raw(raw).expect("native ArchiveInfo allocation failed")
287 }
288 }
289
290 pub fn format_version(&self) -> u16 {
292 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_get_formatVersion(self.raw.as_ptr()) }
294 }
295
296 pub fn set_format_version(&mut self, value: u16) {
297 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_set_formatVersion(self.raw.as_ptr(), value) }
299 }
300
301 pub fn hash_table_entries(&self) -> u32 {
303 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_get_hashTableEntries(self.raw.as_ptr()) }
305 }
306
307 pub fn set_hash_table_entries(&mut self, value: u32) {
308 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_set_hashTableEntries(self.raw.as_ptr(), value) }
310 }
311
312 pub fn block_table_entries(&self) -> u32 {
314 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_get_blockTableEntries(self.raw.as_ptr()) }
316 }
317
318 pub fn set_block_table_entries(&mut self, value: u32) {
319 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_set_blockTableEntries(self.raw.as_ptr(), value) }
321 }
322
323 pub fn sector_size(&self) -> u32 {
325 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_get_sectorSize(self.raw.as_ptr()) }
327 }
328
329 pub fn set_sector_size(&mut self, value: u32) {
330 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_set_sectorSize(self.raw.as_ptr(), value) }
332 }
333
334 pub fn archive_size(&self) -> u64 {
336 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_get_archiveSize(self.raw.as_ptr()) }
338 }
339
340 pub fn set_archive_size(&mut self, value: u64) {
341 unsafe { ffi::whiteout_mpq_MpqArchiveInfo_set_archiveSize(self.raw.as_ptr(), value) }
343 }
344}
345
346impl Default for ArchiveInfo {
347 fn default() -> Self {
348 Self::new()
349 }
350}
351
352pub struct WriteOptions {
354 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_MpqWriteOptions>,
355}
356
357impl Drop for WriteOptions {
358 fn drop(&mut self) {
359 unsafe { ffi::whiteout_mpq_MpqWriteOptions_delete(self.raw.as_ptr()) }
361 }
362}
363
364impl WriteOptions {
365 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_MpqWriteOptions) -> Option<Self> {
369 core::ptr::NonNull::new(raw).map(|raw| WriteOptions { raw })
370 }
371}
372
373unsafe impl Send for WriteOptions {}
378
379impl core::fmt::Debug for WriteOptions {
380 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
381 f.debug_struct("WriteOptions").finish_non_exhaustive()
382 }
383}
384
385impl WriteOptions {
386 pub fn new() -> Self {
389 unsafe {
392 let raw = ffi::whiteout_mpq_MpqWriteOptions_new();
393 Self::from_raw(raw).expect("native WriteOptions allocation failed")
394 }
395 }
396
397 pub fn compression(&self) -> Compression {
399 unsafe { ffi::whiteout_mpq_MpqWriteOptions_get_compression(self.raw.as_ptr()) }
401 .try_into()
402 .expect("unknown enum discriminant from the native library")
403 }
404
405 pub fn set_compression(&mut self, value: Compression) {
406 unsafe {
408 ffi::whiteout_mpq_MpqWriteOptions_set_compression(self.raw.as_ptr(), value as i32)
409 }
410 }
411
412 pub fn locale(&self) -> u16 {
414 unsafe { ffi::whiteout_mpq_MpqWriteOptions_get_locale(self.raw.as_ptr()) }
416 }
417
418 pub fn set_locale(&mut self, value: u16) {
419 unsafe { ffi::whiteout_mpq_MpqWriteOptions_set_locale(self.raw.as_ptr(), value) }
421 }
422
423 pub fn encrypt(&self) -> bool {
425 unsafe { ffi::whiteout_mpq_MpqWriteOptions_get_encrypt(self.raw.as_ptr()) != 0 }
427 }
428
429 pub fn set_encrypt(&mut self, value: bool) {
430 unsafe {
432 ffi::whiteout_mpq_MpqWriteOptions_set_encrypt(
433 self.raw.as_ptr(),
434 if value { 1 } else { 0 },
435 )
436 }
437 }
438
439 pub fn single_unit(&self) -> bool {
441 unsafe { ffi::whiteout_mpq_MpqWriteOptions_get_singleUnit(self.raw.as_ptr()) != 0 }
443 }
444
445 pub fn set_single_unit(&mut self, value: bool) {
446 unsafe {
448 ffi::whiteout_mpq_MpqWriteOptions_set_singleUnit(
449 self.raw.as_ptr(),
450 if value { 1 } else { 0 },
451 )
452 }
453 }
454}
455
456impl Default for WriteOptions {
457 fn default() -> Self {
458 Self::new()
459 }
460}
461
462pub struct CreateOptions {
464 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_MpqCreateOptions>,
465}
466
467impl Drop for CreateOptions {
468 fn drop(&mut self) {
469 unsafe { ffi::whiteout_mpq_MpqCreateOptions_delete(self.raw.as_ptr()) }
471 }
472}
473
474impl CreateOptions {
475 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_MpqCreateOptions) -> Option<Self> {
479 core::ptr::NonNull::new(raw).map(|raw| CreateOptions { raw })
480 }
481}
482
483unsafe impl Send for CreateOptions {}
488
489impl core::fmt::Debug for CreateOptions {
490 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
491 f.debug_struct("CreateOptions").finish_non_exhaustive()
492 }
493}
494
495impl CreateOptions {
496 pub fn new() -> Self {
499 unsafe {
502 let raw = ffi::whiteout_mpq_MpqCreateOptions_new();
503 Self::from_raw(raw).expect("native CreateOptions allocation failed")
504 }
505 }
506
507 pub fn version(&self) -> FormatVersion {
509 unsafe { ffi::whiteout_mpq_MpqCreateOptions_get_version(self.raw.as_ptr()) }
511 .try_into()
512 .expect("unknown enum discriminant from the native library")
513 }
514
515 pub fn set_version(&mut self, value: FormatVersion) {
516 unsafe { ffi::whiteout_mpq_MpqCreateOptions_set_version(self.raw.as_ptr(), value as i32) }
518 }
519
520 pub fn hash_table_size(&self) -> u32 {
522 unsafe { ffi::whiteout_mpq_MpqCreateOptions_get_hashTableSize(self.raw.as_ptr()) }
524 }
525
526 pub fn set_hash_table_size(&mut self, value: u32) {
527 unsafe { ffi::whiteout_mpq_MpqCreateOptions_set_hashTableSize(self.raw.as_ptr(), value) }
529 }
530
531 pub fn sector_size_shift(&self) -> u16 {
533 unsafe { ffi::whiteout_mpq_MpqCreateOptions_get_sectorSizeShift(self.raw.as_ptr()) }
535 }
536
537 pub fn set_sector_size_shift(&mut self, value: u16) {
538 unsafe { ffi::whiteout_mpq_MpqCreateOptions_set_sectorSizeShift(self.raw.as_ptr(), value) }
540 }
541}
542
543impl Default for CreateOptions {
544 fn default() -> Self {
545 Self::new()
546 }
547}
548
549pub struct Storage {
555 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_MpqStorage>,
556}
557
558impl Drop for Storage {
559 fn drop(&mut self) {
560 unsafe { ffi::whiteout_mpq_MpqStorage_delete(self.raw.as_ptr()) }
562 }
563}
564
565impl Storage {
566 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_MpqStorage) -> Option<Self> {
570 core::ptr::NonNull::new(raw).map(|raw| Storage { raw })
571 }
572}
573
574unsafe impl Send for Storage {}
579
580impl core::fmt::Debug for Storage {
581 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
582 f.debug_struct("Storage").finish_non_exhaustive()
583 }
584}
585
586impl Storage {
587 pub fn open(path: &str, pool: Option<&crate::interfaces::HostWorkerPool>) -> Option<Storage> {
589 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
590 unsafe {
592 Storage::from_raw(ffi::whiteout_mpq_MpqStorage_open(
593 path_cstr.as_ptr(),
594 pool.map_or(core::ptr::null_mut(), |v| v.as_ptr()),
595 ))
596 }
597 }
598
599 pub fn create(
601 opts: &CreateOptions,
602 pool: Option<&crate::interfaces::HostWorkerPool>,
603 ) -> Option<Storage> {
604 unsafe {
606 Storage::from_raw(ffi::whiteout_mpq_MpqStorage_create(
607 opts.raw.as_ptr(),
608 pool.map_or(core::ptr::null_mut(), |v| v.as_ptr()),
609 ))
610 }
611 }
612
613 pub fn close(&mut self) {
615 unsafe {
617 ffi::whiteout_mpq_MpqStorage_close(self.raw.as_ptr());
618 }
619 }
620
621 pub fn read_file(&self, name: &str) -> Option<Bytes> {
623 let name_cstr = std::ffi::CString::new(name).unwrap_or_default();
624 unsafe {
626 Bytes::from_raw(ffi::whiteout_mpq_MpqStorage_readFile(
627 self.raw.as_ptr(),
628 name_cstr.as_ptr(),
629 ))
630 }
631 }
632
633 pub fn read_file_name_locale(&self, name: &str, locale: u16) -> Option<Bytes> {
635 let name_cstr = std::ffi::CString::new(name).unwrap_or_default();
636 unsafe {
638 Bytes::from_raw(ffi::whiteout_mpq_MpqStorage_readFile_name_locale(
639 self.raw.as_ptr(),
640 name_cstr.as_ptr(),
641 locale,
642 ))
643 }
644 }
645
646 pub fn file_exists(&self, name: &str) -> bool {
648 let name_cstr = std::ffi::CString::new(name).unwrap_or_default();
649 unsafe {
651 ffi::whiteout_mpq_MpqStorage_fileExists(self.raw.as_ptr(), name_cstr.as_ptr()) != 0
652 }
653 }
654
655 pub fn file_info(&self, name: &str) -> Option<FileInfo> {
657 let name_cstr = std::ffi::CString::new(name).unwrap_or_default();
658 unsafe {
660 FileInfo::from_raw(ffi::whiteout_mpq_MpqStorage_fileInfo(
661 self.raw.as_ptr(),
662 name_cstr.as_ptr(),
663 ))
664 }
665 }
666
667 pub fn archive_info(&self) -> Option<ArchiveInfo> {
669 unsafe {
671 ArchiveInfo::from_raw(ffi::whiteout_mpq_MpqStorage_archiveInfo(self.raw.as_ptr()))
672 }
673 }
674
675 pub fn list_files(&self) -> Vec<String> {
677 unsafe {
679 let n = ffi::whiteout_mpq_MpqStorage_listFiles_count(self.raw.as_ptr());
680 (0..n)
681 .map(|i| {
682 crate::support::take_string(ffi::whiteout_mpq_MpqStorage_listFiles_at(
683 self.raw.as_ptr(),
684 i,
685 ))
686 })
687 .collect()
688 }
689 }
690
691 pub fn write_file(&mut self, name: &[u8], data: &[u8], opts: &WriteOptions) -> bool {
693 unsafe {
695 ffi::whiteout_mpq_MpqStorage_writeFile(
696 self.raw.as_ptr(),
697 name.as_ptr(),
698 name.len(),
699 data.as_ptr(),
700 data.len(),
701 opts.raw.as_ptr(),
702 ) != 0
703 }
704 }
705
706 pub fn delete_file(&mut self, name: &str) -> bool {
708 let name_cstr = std::ffi::CString::new(name).unwrap_or_default();
709 unsafe {
711 ffi::whiteout_mpq_MpqStorage_deleteFile(self.raw.as_ptr(), name_cstr.as_ptr()) != 0
712 }
713 }
714
715 pub fn save(&mut self) -> bool {
717 unsafe { ffi::whiteout_mpq_MpqStorage_save(self.raw.as_ptr()) != 0 }
719 }
720
721 pub fn save_path(&mut self, path: &str) -> bool {
723 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
724 unsafe {
726 ffi::whiteout_mpq_MpqStorage_save_path(self.raw.as_ptr(), path_cstr.as_ptr()) != 0
727 }
728 }
729}
730
731pub struct FileSystem {
741 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_MpqFileSystem>,
742}
743
744impl Drop for FileSystem {
745 fn drop(&mut self) {
746 unsafe { ffi::whiteout_mpq_MpqFileSystem_delete(self.raw.as_ptr()) }
748 }
749}
750
751impl FileSystem {
752 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_MpqFileSystem) -> Option<Self> {
756 core::ptr::NonNull::new(raw).map(|raw| FileSystem { raw })
757 }
758}
759
760unsafe impl Send for FileSystem {}
765
766impl core::fmt::Debug for FileSystem {
767 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
768 f.debug_struct("FileSystem").finish_non_exhaustive()
769 }
770}
771
772impl FileSystem {
773 pub fn read_file(&self, path: &str) -> Bytes {
775 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
776 unsafe {
778 Bytes::from_raw(ffi::whiteout_mpq_MpqFileSystem_readFile(
779 self.raw.as_ptr(),
780 path_cstr.as_ptr(),
781 ))
782 .unwrap_or_else(Bytes::empty)
783 }
784 }
785
786 pub fn write_file(&mut self, path: &str, data: &[u8]) -> bool {
788 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
789 unsafe {
791 ffi::whiteout_mpq_MpqFileSystem_writeFile(
792 self.raw.as_ptr(),
793 path_cstr.as_ptr(),
794 data.as_ptr(),
795 data.len(),
796 ) != 0
797 }
798 }
799
800 pub fn file_exists(&self, path: &str) -> bool {
802 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
803 unsafe {
805 ffi::whiteout_mpq_MpqFileSystem_fileExists(self.raw.as_ptr(), path_cstr.as_ptr()) != 0
806 }
807 }
808}
809
810#[doc(hidden)]
811pub mod ffi {
812 #![allow(missing_debug_implementations)]
813
814 #[allow(unused_imports)]
815 use crate::support::{RawBytes, RawCString};
816
817 #[repr(C)]
818 pub struct whiteout_MpqFileInfo {
819 _private: [u8; 0],
820 }
821 #[repr(C)]
822 pub struct whiteout_MpqArchiveInfo {
823 _private: [u8; 0],
824 }
825 #[repr(C)]
826 pub struct whiteout_MpqWriteOptions {
827 _private: [u8; 0],
828 }
829 #[repr(C)]
830 pub struct whiteout_MpqCreateOptions {
831 _private: [u8; 0],
832 }
833 #[repr(C)]
834 pub struct whiteout_MpqStorage {
835 _private: [u8; 0],
836 }
837 #[repr(C)]
838 pub struct whiteout_MpqFileSystem {
839 _private: [u8; 0],
840 }
841
842 extern "C" {
843 pub fn whiteout_mpq_MpqFileInfo_new() -> *mut whiteout_MpqFileInfo;
845 pub fn whiteout_mpq_MpqFileInfo_delete(self_: *mut whiteout_MpqFileInfo);
846 pub fn whiteout_mpq_MpqFileInfo_get_name(self_: *mut whiteout_MpqFileInfo) -> RawCString;
847 pub fn whiteout_mpq_MpqFileInfo_set_name(
848 self_: *mut whiteout_MpqFileInfo,
849 value: *const core::ffi::c_char,
850 );
851 pub fn whiteout_mpq_MpqFileInfo_get_compressedSize(self_: *mut whiteout_MpqFileInfo)
852 -> u32;
853 pub fn whiteout_mpq_MpqFileInfo_set_compressedSize(
854 self_: *mut whiteout_MpqFileInfo,
855 value: u32,
856 );
857 pub fn whiteout_mpq_MpqFileInfo_get_uncompressedSize(
858 self_: *mut whiteout_MpqFileInfo,
859 ) -> u32;
860 pub fn whiteout_mpq_MpqFileInfo_set_uncompressedSize(
861 self_: *mut whiteout_MpqFileInfo,
862 value: u32,
863 );
864 pub fn whiteout_mpq_MpqFileInfo_get_flags(self_: *mut whiteout_MpqFileInfo) -> i32;
865 pub fn whiteout_mpq_MpqFileInfo_set_flags(self_: *mut whiteout_MpqFileInfo, value: i32);
866 pub fn whiteout_mpq_MpqFileInfo_get_locale(self_: *mut whiteout_MpqFileInfo) -> u16;
867 pub fn whiteout_mpq_MpqFileInfo_set_locale(self_: *mut whiteout_MpqFileInfo, value: u16);
868 pub fn whiteout_mpq_MpqArchiveInfo_new() -> *mut whiteout_MpqArchiveInfo;
870 pub fn whiteout_mpq_MpqArchiveInfo_delete(self_: *mut whiteout_MpqArchiveInfo);
871 pub fn whiteout_mpq_MpqArchiveInfo_get_formatVersion(
872 self_: *mut whiteout_MpqArchiveInfo,
873 ) -> u16;
874 pub fn whiteout_mpq_MpqArchiveInfo_set_formatVersion(
875 self_: *mut whiteout_MpqArchiveInfo,
876 value: u16,
877 );
878 pub fn whiteout_mpq_MpqArchiveInfo_get_hashTableEntries(
879 self_: *mut whiteout_MpqArchiveInfo,
880 ) -> u32;
881 pub fn whiteout_mpq_MpqArchiveInfo_set_hashTableEntries(
882 self_: *mut whiteout_MpqArchiveInfo,
883 value: u32,
884 );
885 pub fn whiteout_mpq_MpqArchiveInfo_get_blockTableEntries(
886 self_: *mut whiteout_MpqArchiveInfo,
887 ) -> u32;
888 pub fn whiteout_mpq_MpqArchiveInfo_set_blockTableEntries(
889 self_: *mut whiteout_MpqArchiveInfo,
890 value: u32,
891 );
892 pub fn whiteout_mpq_MpqArchiveInfo_get_sectorSize(
893 self_: *mut whiteout_MpqArchiveInfo,
894 ) -> u32;
895 pub fn whiteout_mpq_MpqArchiveInfo_set_sectorSize(
896 self_: *mut whiteout_MpqArchiveInfo,
897 value: u32,
898 );
899 pub fn whiteout_mpq_MpqArchiveInfo_get_archiveSize(
900 self_: *mut whiteout_MpqArchiveInfo,
901 ) -> u64;
902 pub fn whiteout_mpq_MpqArchiveInfo_set_archiveSize(
903 self_: *mut whiteout_MpqArchiveInfo,
904 value: u64,
905 );
906 pub fn whiteout_mpq_MpqWriteOptions_new() -> *mut whiteout_MpqWriteOptions;
908 pub fn whiteout_mpq_MpqWriteOptions_delete(self_: *mut whiteout_MpqWriteOptions);
909 pub fn whiteout_mpq_MpqWriteOptions_get_compression(
910 self_: *mut whiteout_MpqWriteOptions,
911 ) -> i32;
912 pub fn whiteout_mpq_MpqWriteOptions_set_compression(
913 self_: *mut whiteout_MpqWriteOptions,
914 value: i32,
915 );
916 pub fn whiteout_mpq_MpqWriteOptions_get_locale(self_: *mut whiteout_MpqWriteOptions)
917 -> u16;
918 pub fn whiteout_mpq_MpqWriteOptions_set_locale(
919 self_: *mut whiteout_MpqWriteOptions,
920 value: u16,
921 );
922 pub fn whiteout_mpq_MpqWriteOptions_get_encrypt(
923 self_: *mut whiteout_MpqWriteOptions,
924 ) -> i32;
925 pub fn whiteout_mpq_MpqWriteOptions_set_encrypt(
926 self_: *mut whiteout_MpqWriteOptions,
927 value: i32,
928 );
929 pub fn whiteout_mpq_MpqWriteOptions_get_singleUnit(
930 self_: *mut whiteout_MpqWriteOptions,
931 ) -> i32;
932 pub fn whiteout_mpq_MpqWriteOptions_set_singleUnit(
933 self_: *mut whiteout_MpqWriteOptions,
934 value: i32,
935 );
936 pub fn whiteout_mpq_MpqCreateOptions_new() -> *mut whiteout_MpqCreateOptions;
938 pub fn whiteout_mpq_MpqCreateOptions_delete(self_: *mut whiteout_MpqCreateOptions);
939 pub fn whiteout_mpq_MpqCreateOptions_get_version(
940 self_: *mut whiteout_MpqCreateOptions,
941 ) -> i32;
942 pub fn whiteout_mpq_MpqCreateOptions_set_version(
943 self_: *mut whiteout_MpqCreateOptions,
944 value: i32,
945 );
946 pub fn whiteout_mpq_MpqCreateOptions_get_hashTableSize(
947 self_: *mut whiteout_MpqCreateOptions,
948 ) -> u32;
949 pub fn whiteout_mpq_MpqCreateOptions_set_hashTableSize(
950 self_: *mut whiteout_MpqCreateOptions,
951 value: u32,
952 );
953 pub fn whiteout_mpq_MpqCreateOptions_get_sectorSizeShift(
954 self_: *mut whiteout_MpqCreateOptions,
955 ) -> u16;
956 pub fn whiteout_mpq_MpqCreateOptions_set_sectorSizeShift(
957 self_: *mut whiteout_MpqCreateOptions,
958 value: u16,
959 );
960 pub fn whiteout_mpq_MpqStorage_delete(self_: *mut whiteout_MpqStorage);
962 pub fn whiteout_mpq_MpqStorage_open(
963 path: *const core::ffi::c_char,
964 pool: *mut core::ffi::c_void,
965 ) -> *mut whiteout_MpqStorage;
966 pub fn whiteout_mpq_MpqStorage_create(
967 opts: *mut whiteout_MpqCreateOptions,
968 pool: *mut core::ffi::c_void,
969 ) -> *mut whiteout_MpqStorage;
970 pub fn whiteout_mpq_MpqStorage_close(self_: *mut whiteout_MpqStorage);
971 pub fn whiteout_mpq_MpqStorage_readFile(
972 self_: *mut whiteout_MpqStorage,
973 name: *const core::ffi::c_char,
974 ) -> RawBytes;
975 pub fn whiteout_mpq_MpqStorage_readFile_name_locale(
976 self_: *mut whiteout_MpqStorage,
977 name: *const core::ffi::c_char,
978 locale: u16,
979 ) -> RawBytes;
980 pub fn whiteout_mpq_MpqStorage_fileExists(
981 self_: *mut whiteout_MpqStorage,
982 name: *const core::ffi::c_char,
983 ) -> i32;
984 pub fn whiteout_mpq_MpqStorage_fileInfo(
985 self_: *mut whiteout_MpqStorage,
986 name: *const core::ffi::c_char,
987 ) -> *mut whiteout_MpqFileInfo;
988 pub fn whiteout_mpq_MpqStorage_archiveInfo(
989 self_: *mut whiteout_MpqStorage,
990 ) -> *mut whiteout_MpqArchiveInfo;
991 pub fn whiteout_mpq_MpqStorage_listFiles_count(self_: *mut whiteout_MpqStorage) -> usize;
992 pub fn whiteout_mpq_MpqStorage_listFiles_at(
993 self_: *mut whiteout_MpqStorage,
994 index: usize,
995 ) -> RawCString;
996 pub fn whiteout_mpq_MpqStorage_writeFile(
997 self_: *mut whiteout_MpqStorage,
998 name: *const u8,
999 name_size: usize,
1000 data: *const u8,
1001 data_size: usize,
1002 opts: *mut whiteout_MpqWriteOptions,
1003 ) -> i32;
1004 pub fn whiteout_mpq_MpqStorage_deleteFile(
1005 self_: *mut whiteout_MpqStorage,
1006 name: *const core::ffi::c_char,
1007 ) -> i32;
1008 pub fn whiteout_mpq_MpqStorage_save(self_: *mut whiteout_MpqStorage) -> i32;
1009 pub fn whiteout_mpq_MpqStorage_save_path(
1010 self_: *mut whiteout_MpqStorage,
1011 path: *const core::ffi::c_char,
1012 ) -> i32;
1013 pub fn whiteout_mpq_MpqFileSystem_new_storage(
1015 _0: *mut core::ffi::c_void,
1016 ) -> *mut whiteout_MpqFileSystem;
1017 pub fn whiteout_mpq_MpqFileSystem_delete(self_: *mut whiteout_MpqFileSystem);
1018 pub fn whiteout_mpq_MpqFileSystem_readFile(
1019 self_: *mut whiteout_MpqFileSystem,
1020 path: *const core::ffi::c_char,
1021 ) -> RawBytes;
1022 pub fn whiteout_mpq_MpqFileSystem_writeFile(
1023 self_: *mut whiteout_MpqFileSystem,
1024 path: *const core::ffi::c_char,
1025 data: *const u8,
1026 data_size: usize,
1027 ) -> i32;
1028 pub fn whiteout_mpq_MpqFileSystem_fileExists(
1029 self_: *mut whiteout_MpqFileSystem,
1030 path: *const core::ffi::c_char,
1031 ) -> i32;
1032 }
1033}