std: more windows fixes to os.rs and run.rs
This commit is contained in:
@@ -640,7 +640,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
|
|||||||
use os::win32::as_utf16_p;
|
use os::win32::as_utf16_p;
|
||||||
// FIXME: turn mode into something useful? #2623
|
// FIXME: turn mode into something useful? #2623
|
||||||
do as_utf16_p(p.to_str()) |buf| {
|
do as_utf16_p(p.to_str()) |buf| {
|
||||||
libc::CreateDirectoryW(buf, ptr::null() as LPCWSTR)
|
libc::CreateDirectoryW(buf, ptr::mut_null())
|
||||||
!= (0 as libc::BOOL)
|
!= (0 as libc::BOOL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1080,8 +1080,8 @@ pub fn last_os_error() -> ~str {
|
|||||||
|
|
||||||
let mut buf = [0 as c_char, ..TMPBUF_SZ];
|
let mut buf = [0 as c_char, ..TMPBUF_SZ];
|
||||||
|
|
||||||
do buf.as_mut_buf |buf, len| {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
do buf.as_mut_buf |buf, len| {
|
||||||
let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
|
let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
ptr::mut_null(),
|
ptr::mut_null(),
|
||||||
@@ -1093,7 +1093,9 @@ pub fn last_os_error() -> ~str {
|
|||||||
if res == 0 {
|
if res == 0 {
|
||||||
fail!("[%?] FormatMessage failure", errno());
|
fail!("[%?] FormatMessage failure", errno());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
do buf.as_imm_buf |buf, _len| {
|
||||||
str::raw::from_c_str(buf)
|
str::raw::from_c_str(buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ use prelude::*;
|
|||||||
use ptr;
|
use ptr;
|
||||||
use task;
|
use task;
|
||||||
use vec::ImmutableVector;
|
use vec::ImmutableVector;
|
||||||
use vec;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A value representing a child process.
|
* A value representing a child process.
|
||||||
@@ -691,6 +690,8 @@ fn spawn_process_os(prog: &str, args: &[~str],
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
|
fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
|
||||||
|
use vec;
|
||||||
|
|
||||||
// We can't directly convert `str`s into `*char`s, as someone needs to hold
|
// We can't directly convert `str`s into `*char`s, as someone needs to hold
|
||||||
// a reference to the intermediary byte buffers. So first build an array to
|
// a reference to the intermediary byte buffers. So first build an array to
|
||||||
// hold all the ~[u8] byte strings.
|
// hold all the ~[u8] byte strings.
|
||||||
@@ -717,6 +718,8 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
|
fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
|
||||||
|
use vec;
|
||||||
|
|
||||||
// On posixy systems we can pass a char** for envp, which is a
|
// On posixy systems we can pass a char** for envp, which is a
|
||||||
// null-terminated array of "k=v\n" strings. Like `with_argv`, we have to
|
// null-terminated array of "k=v\n" strings. Like `with_argv`, we have to
|
||||||
// have a temporary buffer to hold the intermediary `~[u8]` byte strings.
|
// have a temporary buffer to hold the intermediary `~[u8]` byte strings.
|
||||||
|
|||||||
Reference in New Issue
Block a user