Signed-off-by: yjhmelody <465402634@qq.com>
This commit is contained in:
yjhmelody
2019-08-17 17:14:10 +08:00
parent 11ba8468ff
commit f288e7c0b2

View File

@@ -6,6 +6,8 @@ use std::fs::OpenOptions;
use std::io::{self, Error, ErrorKind, Read, Write};
#[cfg(unix)]
use std::os::unix::fs::OpenOptionsExt;
#[cfg(windows)]
use std::os::windows::fs::OpenOptionsExt;
use std::time::{Duration, SystemTime};
use std::{env, fs};
@@ -91,6 +93,7 @@ pub fn os_close(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
Ok(vm.get_none())
}
#[cfg(any(unix, windows))]
pub fn os_open(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(
vm,
@@ -126,6 +129,11 @@ pub fn os_open(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
Ok(vm.ctx.new_int(raw_file_number(handle)))
}
#[cfg(all(not(unix), not(windows)))]
pub fn os_open(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
unimplemented!()
}
pub fn convert_io_error(vm: &VirtualMachine, err: io::Error) -> PyObjectRef {
let os_error = match err.kind() {
ErrorKind::NotFound => {