Skip to content

add seek constants, resolves #1348 #1349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion vm/src/stdlib/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use nix::errno::Errno;
#[cfg(all(unix, not(target_os = "redox")))]
use nix::pty::openpty;
#[cfg(unix)]
use nix::unistd::{self, Gid, Pid, Uid};
use nix::unistd::{self, Gid, Pid, Uid, Whence};
use num_traits::cast::ToPrimitive;

use bitflags::bitflags;
Expand Down Expand Up @@ -1215,6 +1215,9 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
"access" => ctx.new_rustfunc(os_access),
"chmod" => ctx.new_rustfunc(os_chmod),
"ttyname" => ctx.new_rustfunc(os_ttyname),
"SEEK_SET" => ctx.new_int(Whence::SeekSet as i8),
"SEEK_CUR" => ctx.new_int(Whence::SeekCur as i8),
"SEEK_END" => ctx.new_int(Whence::SeekEnd as i8)
});

#[cfg(not(target_os = "redox"))]
Expand All @@ -1226,6 +1229,12 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
"openpty" => ctx.new_rustfunc(os_openpty),
});

#[cfg(not(target_os = "macos"))]
extend_module!(vm, module, {
"SEEK_DATA" => ctx.new_int(Whence::SeekData as i8),
"SEEK_HOLE" => ctx.new_int(Whence::SeekHole as i8)
});

module
}

Expand Down