use std::fmt::Debug;
use std::io;
#[repr(u32)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum DLFileSeekDirection {
Head = 0x0,
Current = 0x1,
Tail = 0x2,
}
#[repr(i32)]
pub enum DLIOResult {
DirNotEmpty = -17,
OutOfMemory = -13,
DiskFull = -12,
NotStreamed = -9,
AlreadyOpen = -6,
IsNotOpen = -5,
NotFound = -4,
AccessDenied = -3,
OperationUnsupported = -2,
Invalid = -1,
Success = 0,
NoMoreFiles = 1,
}
impl DLIOResult {
pub fn to_io_result(&self) -> io::Result<()> {
use io::ErrorKind::*;
let kind = match self {
DLIOResult::DirNotEmpty => DirectoryNotEmpty,
DLIOResult::OutOfMemory => OutOfMemory,
DLIOResult::DiskFull => StorageFull,
DLIOResult::IsNotOpen => BrokenPipe,
DLIOResult::NotFound => NotFound,
DLIOResult::AccessDenied => PermissionDenied,
DLIOResult::OperationUnsupported => Unsupported,
DLIOResult::Invalid => InvalidInput,
DLIOResult::AlreadyOpen => PermissionDenied,
DLIOResult::NotStreamed => NotConnected,
_ => return Ok(()),
};
Err(io::Error::from(kind))
}
}
bitflags::bitflags! {
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OpenFileMode: u32 {
const ReadOnly = 0b00000001;
const Write = 0b00000010;
const Append = 0b00000100;
const DetailedErrors = 0b00001000;
const AsyncIo = 0b00010000;
const Unk5 = 0b00100000;
const NoSharing = 0b01000000;
const Unk7 = 0b10000000;
}
}